diff --git a/lib/main.dart b/lib/main.dart index f4cb9e0..4f41abd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -135,22 +135,24 @@ class WormholeAppState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { return DynamicColorBuilder(builder: (lightColorScheme, darkColorScheme) { + var lightScheme = lightColorScheme ?? ColorScheme.fromSeed(seedColor:Colors.indigo, brightness: Brightness.light); + var darkScheme = darkColorScheme ?? ColorScheme.fromSeed(seedColor:Colors.indigo, brightness: Brightness.dark); SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: themeMode == ThemeMode.dark - ? darkColorScheme?.background - : lightColorScheme?.background, + ? darkScheme.background + : lightScheme.background, systemNavigationBarColor: themeMode == ThemeMode.dark - ? darkColorScheme?.surface - : lightColorScheme?.surface)); + ? darkScheme.surface + : lightScheme.surface)); return MaterialApp( navigatorKey: NavigationService.navigatorKey, debugShowCheckedModeBanner: false, title: 'Wormhole', theme: ThemeData( - colorScheme: lightColorScheme, + colorScheme: lightScheme, ), darkTheme: ThemeData( - colorScheme: darkColorScheme, + colorScheme: darkScheme, ), themeMode: themeMode, home: const BasePage(), diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 6375848..de862cb 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -22,7 +22,8 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) { - return Column( + return SingleChildScrollView( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( @@ -167,8 +168,7 @@ class _SettingsPageState extends State { child: const Text('Save'), onPressed: () { this.setState(() { - Settings.setThemeMode(theme); - Restart.restartApp(); + Settings.setThemeMode(theme).then((_) => Restart.restartApp()); }); Navigator.of(context).pop(); }, @@ -249,6 +249,6 @@ class _SettingsPageState extends State { ); }), ], - ); + )); } } diff --git a/lib/utils/settings.dart b/lib/utils/settings.dart index e384ae1..ef56ebd 100644 --- a/lib/utils/settings.dart +++ b/lib/utils/settings.dart @@ -14,23 +14,23 @@ class Settings { static const _recentFiles = 'RECENT_FILES'; static const _themeMode = 'THEME_MODE'; - static setWordLength(int? value) async { + static Future setWordLength(int? value) async { await _setField(value, _wordLength); } - static setRendezvousUrl(String? value) async { + static Future setRendezvousUrl(String? value) async { await _setField(value, _rendezvousUrl); } - static setTransitUrl(String? value) async { + static Future setTransitUrl(String? value) async { await _setField(value, _transitUrl); } - static setRecentFiles(List? value) async { + static Future setRecentFiles(List? value) async { await _setField(value, _recentFiles); } - static addRecentFile(String value) async { + static Future addRecentFile(String value) async { var recentFiles = await getRecentFiles(); recentFiles.add(value); @@ -46,7 +46,7 @@ class Settings { await _setField(recentFiles, _recentFiles); } - static setThemeMode(ThemeMode value) async { + static Future setThemeMode(ThemeMode value) async { await _setField(value.toString(), _themeMode); }