Skip to content

Commit

Permalink
Fix missing dynamic theme handling (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
EwuUwe authored Mar 13, 2024
1 parent cc5d2a5 commit ab3678a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
14 changes: 8 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,24 @@ class WormholeAppState extends State<WormholeApp> 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(),
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class _SettingsPageState extends State<SettingsPage> {

@override
Widget build(BuildContext context) {
return Column(
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
Expand Down Expand Up @@ -167,8 +168,7 @@ class _SettingsPageState extends State<SettingsPage> {
child: const Text('Save'),
onPressed: () {
this.setState(() {
Settings.setThemeMode(theme);
Restart.restartApp();
Settings.setThemeMode(theme).then((_) => Restart.restartApp());
});
Navigator.of(context).pop();
},
Expand Down Expand Up @@ -249,6 +249,6 @@ class _SettingsPageState extends State<SettingsPage> {
);
}),
],
);
));
}
}
12 changes: 6 additions & 6 deletions lib/utils/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ class Settings {
static const _recentFiles = 'RECENT_FILES';
static const _themeMode = 'THEME_MODE';

static setWordLength(int? value) async {
static Future<void> setWordLength(int? value) async {
await _setField(value, _wordLength);
}

static setRendezvousUrl(String? value) async {
static Future<void> setRendezvousUrl(String? value) async {
await _setField(value, _rendezvousUrl);
}

static setTransitUrl(String? value) async {
static Future<void> setTransitUrl(String? value) async {
await _setField(value, _transitUrl);
}

static setRecentFiles(List<String>? value) async {
static Future<void> setRecentFiles(List<String>? value) async {
await _setField(value, _recentFiles);
}

static addRecentFile(String value) async {
static Future<void> addRecentFile(String value) async {
var recentFiles = await getRecentFiles();
recentFiles.add(value);

Expand All @@ -46,7 +46,7 @@ class Settings {
await _setField(recentFiles, _recentFiles);
}

static setThemeMode(ThemeMode value) async {
static Future<void> setThemeMode(ThemeMode value) async {
await _setField(value.toString(), _themeMode);
}

Expand Down

0 comments on commit ab3678a

Please sign in to comment.