feat(flutter): MinstrelApp watches themeMode + offers darkTheme
MaterialApp now provides both light and dark themes plus a themeMode bound to themeModeProvider. ThemeMode.system rebuilds the tree automatically when the OS toggles brightness — no manual listener needed. While themeModeProvider is loading (storage read in flight), falls back to AppThemeMode.system, which inherits the OS setting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
|
|
||||||
import 'shared/routing.dart';
|
import 'shared/routing.dart';
|
||||||
import 'theme/theme_data.dart';
|
import 'theme/theme_data.dart';
|
||||||
|
import 'theme/theme_mode_provider.dart';
|
||||||
|
|
||||||
class MinstrelApp extends ConsumerWidget {
|
class MinstrelApp extends ConsumerWidget {
|
||||||
const MinstrelApp({super.key});
|
const MinstrelApp({super.key});
|
||||||
@@ -10,9 +11,12 @@ class MinstrelApp extends ConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final router = ref.watch(routerProvider);
|
final router = ref.watch(routerProvider);
|
||||||
|
final mode = ref.watch(themeModeProvider).value ?? AppThemeMode.system;
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
title: 'Minstrel',
|
title: 'Minstrel',
|
||||||
theme: buildThemeData(),
|
theme: buildLightTheme(),
|
||||||
|
darkTheme: buildDarkTheme(),
|
||||||
|
themeMode: mode.materialMode,
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user