diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 94e3fa17..3adf83b9 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -110,14 +110,15 @@ class SettingsListState extends State { }, ); + var brightness = DynamicTheme.of(context).brightness; + return PreferencePage([ SettingsHeader('Display Settings'), - DropdownPreference( - 'Theme', - 'theme', - defaultVal: "Light", - values: ["Light", "Dark"], - onChange: (newVal) { + ListPreference( + title: "Theme", + currentOption: brightness == Brightness.light ? "Light" : "Dark", + options: ["Light", "Dark"], + onChange: (String newVal) { var dynamicTheme = DynamicTheme.of(context); switch (newVal) { case "Dark": @@ -315,3 +316,53 @@ class FontSizeSettingsDialog extends StatelessWidget { ); } } + +class ListPreference extends StatelessWidget { + final String title; + final String currentOption; + final List options; + Function onChange; + + ListPreference({ + @required this.title, + @required this.currentOption, + @required this.options, + @required this.onChange, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + title: Text(title), + subtitle: Text(currentOption), + onTap: () async { + var option = await showDialog( + context: context, + builder: (BuildContext context) { + var children = []; + for (var o in options) { + var tile = ListTile( + title: Text(o), + onTap: () { + Navigator.of(context).pop(o); + }, + ); + children.add(tile); + } + return AlertDialog( + title: Text(title), + content: SingleChildScrollView( + child: ListBody( + children: children, + ), + ), + ); + }); + + if (option != null) { + onChange(option); + } + }, + ); + } +}