Add system theme api level check

This commit is contained in:
Gregory Velichko
2024-04-20 11:57:12 +03:00
parent 285530784d
commit fb206aee84
2 changed files with 30 additions and 24 deletions

View File

@@ -82,19 +82,22 @@ class _SettingsPageState extends State<SettingsPage> {
if (settingsProvider.prefs == null) settingsProvider.initializeSettings(); if (settingsProvider.prefs == null) settingsProvider.initializeSettings();
initUpdateIntervalInterpolator(); initUpdateIntervalInterpolator();
processIntervalSliderValue(settingsProvider.updateIntervalSliderVal); processIntervalSliderValue(settingsProvider.updateIntervalSliderVal);
var themeDropdown = DropdownButtonFormField(
var themeDropdown = FutureBuilder(
builder: (ctx, val) {
return DropdownButtonFormField(
decoration: InputDecoration(labelText: tr('theme')), decoration: InputDecoration(labelText: tr('theme')),
value: settingsProvider.theme, value: settingsProvider.theme,
items: [ items: [
DropdownMenuItem(
value: ThemeSettings.dark,
child: Text(tr('dark')),
),
DropdownMenuItem( DropdownMenuItem(
value: ThemeSettings.light, value: ThemeSettings.light,
child: Text(tr('light')), child: Text(tr('light')),
), ),
DropdownMenuItem( DropdownMenuItem(
value: ThemeSettings.dark,
child: Text(tr('dark')),
),
if ((val.data?.version.sdkInt ?? 0) >= 29) DropdownMenuItem(
value: ThemeSettings.system, value: ThemeSettings.system,
child: Text(tr('followSystem')), child: Text(tr('followSystem')),
) )
@@ -104,6 +107,9 @@ class _SettingsPageState extends State<SettingsPage> {
settingsProvider.theme = value; settingsProvider.theme = value;
} }
}); });
},
future: DeviceInfoPlugin().androidInfo
);
var colourDropdown = DropdownButtonFormField( var colourDropdown = DropdownButtonFormField(
decoration: InputDecoration(labelText: tr('colour')), decoration: InputDecoration(labelText: tr('colour')),

View File

@@ -18,7 +18,7 @@ String obtainiumTempId = 'imranr98_obtainium_${GitHub().hosts[0]}';
String obtainiumId = 'dev.imranr.obtainium'; String obtainiumId = 'dev.imranr.obtainium';
String obtainiumUrl = 'https://github.com/ImranR98/Obtainium'; String obtainiumUrl = 'https://github.com/ImranR98/Obtainium';
enum ThemeSettings { system, light, dark } enum ThemeSettings { light, dark, system }
enum ColourSettings { basic, materialYou } enum ColourSettings { basic, materialYou }
@@ -60,7 +60,7 @@ class SettingsProvider with ChangeNotifier {
ThemeSettings get theme { ThemeSettings get theme {
return ThemeSettings return ThemeSettings
.values[prefs?.getInt('theme') ?? ThemeSettings.system.index]; .values[prefs?.getInt('theme') ?? ThemeSettings.light.index];
} }
set theme(ThemeSettings t) { set theme(ThemeSettings t) {