From 40d303fb57149dc350a5a7f8cd2fed90e8696430 Mon Sep 17 00:00:00 2001 From: Gregory Velichko Date: Sun, 21 Apr 2024 16:31:55 +0300 Subject: [PATCH] Partially rollback system theme (#1552) --- assets/translations/en.json | 1 + assets/translations/ru.json | 1 + lib/pages/settings.dart | 54 +++++++++++++++------------- lib/providers/settings_provider.dart | 4 +-- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 8006c94..104d1c2 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -113,6 +113,7 @@ "dark": "Dark", "light": "Light", "followSystem": "Follow System", + "followSystemThemeExplanation": "Following system theme is possible only by using third-party applications", "useBlackTheme": "Use pure black dark theme", "appSortBy": "App Sort By", "authorName": "Author/Name", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 6ce3b47..4135c1c 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -113,6 +113,7 @@ "dark": "Тёмная", "light": "Светлая", "followSystem": "Системная", + "followSystemThemeExplanation": "Следование системной теме возможно только при использовании сторонних приложений", "useBlackTheme": "Использовать чёрную тему", "appSortBy": "Сортировка приложений", "authorName": "Автор/Название", diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart index 372088d..367e842 100644 --- a/lib/pages/settings.dart +++ b/lib/pages/settings.dart @@ -88,30 +88,12 @@ class _SettingsPageState extends State { initUpdateIntervalInterpolator(); processIntervalSliderValue(settingsProvider.updateIntervalSliderVal); - var themeDropdown = FutureBuilder( + var followSystemThemeExplanation = FutureBuilder( builder: (ctx, val) { - return DropdownButtonFormField( - decoration: InputDecoration(labelText: tr('theme')), - value: settingsProvider.theme, - items: [ - DropdownMenuItem( - value: ThemeSettings.light, - child: Text(tr('light')), - ), - DropdownMenuItem( - value: ThemeSettings.dark, - child: Text(tr('dark')), - ), - if ((val.data?.version.sdkInt ?? 0) >= 29) DropdownMenuItem( - value: ThemeSettings.system, - child: Text(tr('followSystem')), - ) - ], - onChanged: (value) { - if (value != null) { - settingsProvider.theme = value; - } - }); + return ((val.data?.version.sdkInt ?? 30) < 29) ? + Text(tr('followSystemThemeExplanation'), + style: Theme.of(context).textTheme.labelSmall) + : const SizedBox.shrink(); }, future: DeviceInfoPlugin().androidInfo ); @@ -583,7 +565,31 @@ class _SettingsPageState extends State { fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.primary), ), - themeDropdown, + DropdownButtonFormField( + decoration: InputDecoration(labelText: tr('theme')), + value: settingsProvider.theme, + items: [ + DropdownMenuItem( + value: ThemeSettings.system, + child: Text(tr('followSystem')), + ), + DropdownMenuItem( + value: ThemeSettings.light, + child: Text(tr('light')), + ), + DropdownMenuItem( + value: ThemeSettings.dark, + child: Text(tr('dark')), + ) + ], + onChanged: (value) { + if (value != null) { + settingsProvider.theme = value; + } + }), + height8, + if (settingsProvider.theme == ThemeSettings.system) + followSystemThemeExplanation, height16, if (settingsProvider.theme != ThemeSettings.light) Row( diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index 31838bb..f12dfbe 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -19,7 +19,7 @@ String obtainiumId = 'dev.imranr.obtainium'; String obtainiumUrl = 'https://github.com/ImranR98/Obtainium'; Color obtainiumThemeColor = const Color(0xFF6438B5); -enum ThemeSettings { light, dark, system } +enum ThemeSettings { system, light, dark } enum SortColumnSettings { added, nameAuthor, authorName, releaseDate } @@ -59,7 +59,7 @@ class SettingsProvider with ChangeNotifier { ThemeSettings get theme { return ThemeSettings - .values[prefs?.getInt('theme') ?? ThemeSettings.light.index]; + .values[prefs?.getInt('theme') ?? ThemeSettings.system.index]; } set theme(ThemeSettings t) {