From 176243b881b4f23545c7164374f901ed9fdbacb8 Mon Sep 17 00:00:00 2001 From: Kima Date: Tue, 6 Jun 2023 21:46:10 +0200 Subject: [PATCH] started uwu mode --- .../lib/screens/settings/settings_helper.dart | 124 +++++++++++++----- .../lib/screens/settings/settings_screen.dart | 26 +++- .../settings/settings_screen.i18n.dart | 6 + 3 files changed, 121 insertions(+), 35 deletions(-) diff --git a/filcnaplo_mobile_ui/lib/screens/settings/settings_helper.dart b/filcnaplo_mobile_ui/lib/screens/settings/settings_helper.dart index 465d67d..7f6a325 100755 --- a/filcnaplo_mobile_ui/lib/screens/settings/settings_helper.dart +++ b/filcnaplo_mobile_ui/lib/screens/settings/settings_helper.dart @@ -30,7 +30,11 @@ import 'package:filcnaplo/utils/format.dart'; import 'package:filcnaplo_premium/ui/mobile/settings/theme.dart'; class SettingsHelper { - static const Map langMap = {"en": "🇬🇧 English", "hu": "🇭🇺 Magyar", "de": "🇩🇪 Deutsch"}; + static const Map langMap = { + "en": "🇬🇧 English", + "hu": "🇭🇺 Magyar", + "de": "🇩🇪 Deutsch" + }; static const Map pageTitle = { Pages.home: "home", @@ -47,9 +51,11 @@ class SettingsHelper { VibrationStrength.strong: "vstrong", }; - static Map localizedPageTitles() => pageTitle.map((key, value) => MapEntry(key, ScreensLocalization(value).i18n)); + static Map localizedPageTitles() => pageTitle + .map((key, value) => MapEntry(key, ScreensLocalization(value).i18n)); static Map localizedVibrationTitles() => - vibrationTitle.map((key, value) => MapEntry(key, SettingsLocalization(value).i18n)); + vibrationTitle + .map((key, value) => MapEntry(key, SettingsLocalization(value).i18n)); static void language(BuildContext context) { showBottomSheetMenu( @@ -58,7 +64,8 @@ class SettingsHelper { String lang = langMap.keys.toList()[index]; return BottomSheetMenuItem( onPressed: () { - Provider.of(context, listen: false).update(language: lang); + Provider.of(context, listen: false) + .update(language: lang); I18n.of(context).locale = Locale(lang, lang.toUpperCase()); Navigator.of(context).maybePop(); if (Platform.isAndroid || Platform.isIOS) { @@ -81,6 +88,19 @@ class SettingsHelper { ); } + static void uwuMode(BuildContext context, value) { + final settings = Provider.of(context, listen: false); + if (value) { + I18n.of(context).locale = const Locale('uw', 'UW'); + } else { + I18n.of(context).locale = + Locale(settings.language, settings.language.toUpperCase()); + } + if (Platform.isAndroid || Platform.isIOS) { + setupQuickActions(); + } + } + static void iconPack(BuildContext context) { final settings = Provider.of(context, listen: false); showBottomSheetMenu( @@ -122,16 +142,20 @@ class SettingsHelper { items: List.generate(Pages.values.length, (index) { return BottomSheetMenuItem( onPressed: () { - Provider.of(context, listen: false).update(startPage: Pages.values[index]); + Provider.of(context, listen: false) + .update(startPage: Pages.values[index]); Navigator.of(context).maybePop(); }, title: Row( children: [ - Icon(pageIcons[Pages.values[index]], size: 20.0, color: Theme.of(context).colorScheme.secondary), + Icon(pageIcons[Pages.values[index]], + size: 20.0, color: Theme.of(context).colorScheme.secondary), const SizedBox(width: 16.0), Text(localizedPageTitles()[Pages.values[index]] ?? ""), const Spacer(), - if (Pages.values[index] == Provider.of(context, listen: false).startPage) + if (Pages.values[index] == + Provider.of(context, listen: false) + .startPage) Icon( Icons.check_circle, color: Theme.of(context).colorScheme.secondary, @@ -165,7 +189,8 @@ class SettingsHelper { children: [ Padding( padding: const EdgeInsets.only(right: 16.0), - child: Icon(FeatherIcons.smartphone, size: 20.0, color: Theme.of(context).colorScheme.secondary), + child: Icon(FeatherIcons.smartphone, + size: 20.0, color: Theme.of(context).colorScheme.secondary), ), Text(SettingsLocalization("system").i18n), const Spacer(), @@ -183,7 +208,8 @@ class SettingsHelper { children: [ Padding( padding: const EdgeInsets.only(right: 16.0), - child: Icon(FeatherIcons.sun, size: 20.0, color: Theme.of(context).colorScheme.secondary), + child: Icon(FeatherIcons.sun, + size: 20.0, color: Theme.of(context).colorScheme.secondary), ), Text(SettingsLocalization("light").i18n), const Spacer(), @@ -201,7 +227,8 @@ class SettingsHelper { children: [ Padding( padding: const EdgeInsets.only(right: 16.0), - child: Icon(FeatherIcons.moon, size: 20.0, color: Theme.of(context).colorScheme.secondary), + child: Icon(FeatherIcons.moon, + size: 20.0, color: Theme.of(context).colorScheme.secondary), ), Text(SettingsLocalization("dark").i18n), const Spacer(), @@ -219,7 +246,8 @@ class SettingsHelper { static void accentColor(BuildContext context) { Navigator.of(context, rootNavigator: true).push( PageRouteBuilder( - pageBuilder: (context, _, __) => const PremiumCustomAccentColorSetting(), + pageBuilder: (context, _, __) => + const PremiumCustomAccentColorSetting(), transitionDuration: Duration.zero, reverseTransitionDuration: Duration.zero, ), @@ -241,7 +269,8 @@ class SettingsHelper { return BottomSheetMenuItem( onPressed: () { - Provider.of(context, listen: false).update(vibrate: value); + Provider.of(context, listen: false) + .update(vibrate: value); Navigator.of(context).maybePop(); }, title: Row( @@ -250,14 +279,18 @@ class SettingsHelper { width: 12.0, height: 12.0, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.secondary.withOpacity((index + 1) / (vibrationTitle.length + 1)), + color: Theme.of(context) + .colorScheme + .secondary + .withOpacity((index + 1) / (vibrationTitle.length + 1)), shape: BoxShape.circle, ), ), const SizedBox(width: 16.0), Text(localizedVibrationTitles()[value] ?? "?"), const Spacer(), - if (value == Provider.of(context, listen: false).vibrate) + if (value == + Provider.of(context, listen: false).vibrate) Icon( Icons.check_circle, color: Theme.of(context).colorScheme.secondary, @@ -291,7 +324,8 @@ class _RoundingSettingState extends State { @override void initState() { super.initState(); - rounding = Provider.of(context, listen: false).rounding / 10; + rounding = + Provider.of(context, listen: false).rounding / 10; } @override @@ -336,12 +370,14 @@ class _RoundingSettingState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text("4.5", style: TextStyle(fontSize: 26.0, fontWeight: FontWeight.w500)), + const Text("4.5", + style: TextStyle(fontSize: 26.0, fontWeight: FontWeight.w500)), const Padding( padding: EdgeInsets.symmetric(horizontal: 24.0), child: Icon(FeatherIcons.arrowRight, color: Colors.grey), ), - GradeValueWidget(GradeValue(roundingResult, "", "", 100), fill: true, size: 32.0), + GradeValueWidget(GradeValue(roundingResult, "", "", 100), + fill: true, size: 32.0), ], ), Padding( @@ -349,7 +385,8 @@ class _RoundingSettingState extends State { child: MaterialActionButton( child: Text(SettingsLocalization("done").i18n), onPressed: () { - Provider.of(context, listen: false).update(rounding: (rounding * 10).toInt()); + Provider.of(context, listen: false) + .update(rounding: (rounding * 10).toInt()); Navigator.of(context).maybePop(); }, ), @@ -367,15 +404,24 @@ class BellDelaySetting extends StatefulWidget { State createState() => _BellDelaySettingState(); } -class _BellDelaySettingState extends State with SingleTickerProviderStateMixin { +class _BellDelaySettingState extends State + with SingleTickerProviderStateMixin { late TabController _tabController; late Duration currentDelay; @override void initState() { super.initState(); - _tabController = TabController(length: 2, vsync: this, initialIndex: Provider.of(context, listen: false).bellDelay > 0 ? 1 : 0); - currentDelay = Duration(seconds: Provider.of(context, listen: false).bellDelay); + _tabController = TabController( + length: 2, + vsync: this, + initialIndex: + Provider.of(context, listen: false).bellDelay > 0 + ? 1 + : 0); + currentDelay = Duration( + seconds: + Provider.of(context, listen: false).bellDelay); } @override @@ -416,7 +462,10 @@ class _BellDelaySettingState extends State with SingleTickerPr ), Text(SettingsLocalization("sync_help").i18n, textAlign: TextAlign.center, - style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w500, color: AppColors.of(context).text.withOpacity(.75))), + style: TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.w500, + color: AppColors.of(context).text.withOpacity(.75))), Padding( padding: const EdgeInsets.only(bottom: 12.0, top: 6.0), child: Column( @@ -425,21 +474,25 @@ class _BellDelaySettingState extends State with SingleTickerPr backgroundColor: AppColors.of(context).filc, child: Text(SettingsLocalization("sync").i18n), onPressed: () { - final lessonProvider = Provider.of(context, listen: false); + final lessonProvider = + Provider.of(context, listen: false); Duration? closest; DateTime now = DateTime.now(); - for (var lesson in lessonProvider.getWeek(Week.current()) ?? []) { + for (var lesson + in lessonProvider.getWeek(Week.current()) ?? []) { Duration sdiff = lesson.start.difference(now); Duration ediff = lesson.end.difference(now); - if (closest == null || sdiff.abs() < closest.abs()) closest = sdiff; + if (closest == null || sdiff.abs() < closest.abs()) + closest = sdiff; if (ediff.abs() < closest.abs()) closest = ediff; } if (closest != null) { if (closest.inHours.abs() >= 1) return; currentDelay = closest; - Provider.of(context, listen: false).update(bellDelay: currentDelay.inSeconds); + Provider.of(context, listen: false) + .update(bellDelay: currentDelay.inSeconds); _tabController.index = currentDelay.inSeconds > 0 ? 1 : 0; setState(() {}); } @@ -449,7 +502,8 @@ class _BellDelaySettingState extends State with SingleTickerPr child: Text(SettingsLocalization("done").i18n), onPressed: () { //Provider.of(context, listen: false).update(context, rounding: (r * 10).toInt()); - Provider.of(context, listen: false).update(bellDelay: currentDelay.inSeconds); + Provider.of(context, listen: false) + .update(bellDelay: currentDelay.inSeconds); Navigator.of(context).maybePop(); }, ), @@ -513,8 +567,11 @@ class _GradeColorsSettingState extends State { children: [ MaterialActionButton( onPressed: () { - List colors = List.castFrom(settings.gradeColors); - var defaultColors = SettingsProvider.defaultSettings().gradeColors; + List colors = + List.castFrom(settings.gradeColors); + var defaultColors = + SettingsProvider.defaultSettings() + .gradeColors; colors[index] = defaultColors[index]; settings.update(gradeColors: colors); Navigator.of(context).maybePop(); @@ -523,9 +580,11 @@ class _GradeColorsSettingState extends State { ), MaterialActionButton( onPressed: () { - List colors = List.castFrom(settings.gradeColors); + List colors = + List.castFrom(settings.gradeColors); colors[index] = currentColor.withAlpha(255); - settings.update(gradeColors: settings.gradeColors); + settings.update( + gradeColors: settings.gradeColors); Navigator.of(context).maybePop(); }, child: Text(SettingsLocalization("done").i18n), @@ -536,7 +595,8 @@ class _GradeColorsSettingState extends State { ]), ).then((value) => setState(() {})); }, - child: GradeValueWidget(GradeValue(index + 1, "", "", 0), fill: true, size: 36.0), + child: GradeValueWidget(GradeValue(index + 1, "", "", 0), + fill: true, size: 36.0), ), ), ); diff --git a/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart b/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart index bda6fae..ae014bf 100755 --- a/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart +++ b/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart @@ -51,7 +51,7 @@ class SettingsScreen extends StatefulWidget { class _SettingsScreenState extends State with SingleTickerProviderStateMixin { - int devmodeCountdown = 3; + int devmodeCountdown = 5; bool __ss = false; // secret settings Future? futureRelease; @@ -529,14 +529,34 @@ class _SettingsScreenState extends State contentPadding: const EdgeInsets.only(left: 12.0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0)), - title: const Text("Presentation Mode", - style: TextStyle(fontWeight: FontWeight.w500)), + title: Text("presentation".i18n, + style: + const TextStyle(fontWeight: FontWeight.w500)), onChanged: (v) => settings.update(presentationMode: v), value: settings.presentationMode, activeColor: Theme.of(context).colorScheme.secondary, ), ), + + // UwU-fied mode (why????) + // Material( + // type: MaterialType.transparency, + // child: SwitchListTile( + // contentPadding: const EdgeInsets.only(left: 12.0), + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(12.0)), + // title: Text("uwufymode".i18n, + // style: + // const TextStyle(fontWeight: FontWeight.w500)), + // onChanged: (v) { + // SettingsHelper.uwuMode(context, v); + // setState(() {}); + // }, + // value: settings.presentationMode, + // activeColor: Theme.of(context).colorScheme.secondary, + // ), + // ), ], ), ), diff --git a/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.i18n.dart b/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.i18n.dart index b2b9ff6..8126d58 100755 --- a/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.i18n.dart +++ b/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.i18n.dart @@ -64,6 +64,8 @@ extension SettingsLocalization on String { "Background Color": "Background Color", "Highlight Color": "Highlight Color", "Adaptive Theme": "Adaptive Theme", + "presentation": "Presentation mode", + "uwufymode": "UwU-fied mode (hungarian)", }, "hu_hu": { "personal_details": "Személyes információk", @@ -126,6 +128,8 @@ extension SettingsLocalization on String { "Background Color": "Háttér színe", "Highlight Color": "Panelek színe", "Adaptive Theme": "Adaptív téma", + "presentation": "Bemutató mód", + "uwufymode": "UwU mód (magyar)", }, "de_de": { "personal_details": "Persönliche Angaben", @@ -187,6 +191,8 @@ extension SettingsLocalization on String { "Background Color": "Background Color", "Highlight Color": "Highlight Color", "Adaptive Theme": "Adaptive Theme", + "presentation": "Präsentationsmodus", + "uwufymode": "UwU-Modus (ungarisch)", }, };