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,28 +82,34 @@ 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(
decoration: InputDecoration(labelText: tr('theme')), var themeDropdown = FutureBuilder(
value: settingsProvider.theme, builder: (ctx, val) {
items: [ return DropdownButtonFormField(
DropdownMenuItem( decoration: InputDecoration(labelText: tr('theme')),
value: ThemeSettings.dark, value: settingsProvider.theme,
child: Text(tr('dark')), items: [
), DropdownMenuItem(
DropdownMenuItem( value: ThemeSettings.light,
value: ThemeSettings.light, child: Text(tr('light')),
child: Text(tr('light')), ),
), DropdownMenuItem(
DropdownMenuItem( value: ThemeSettings.dark,
value: ThemeSettings.system, child: Text(tr('dark')),
child: Text(tr('followSystem')), ),
) if ((val.data?.version.sdkInt ?? 0) >= 29) DropdownMenuItem(
], value: ThemeSettings.system,
onChanged: (value) { child: Text(tr('followSystem')),
if (value != null) { )
settingsProvider.theme = value; ],
} onChanged: (value) {
}); if (value != null) {
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) {