Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../providers/appearance_provider.dart';
|
||||
import 'app_theme.dart';
|
||||
|
||||
|
||||
class AppThemeScope extends ConsumerWidget {
|
||||
final Widget child;
|
||||
|
||||
const AppThemeScope({super.key, required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final mode = ref.watch(
|
||||
appearanceProvider.select((a) => a.value?.themeMode ?? ThemeMode.system),
|
||||
);
|
||||
final brightness = switch (mode) {
|
||||
ThemeMode.light => Brightness.light,
|
||||
ThemeMode.dark => Brightness.dark,
|
||||
ThemeMode.system => MediaQuery.platformBrightnessOf(context),
|
||||
};
|
||||
return Theme(
|
||||
data: brightness == Brightness.dark ? AppTheme.dark() : AppTheme.light(),
|
||||
child: Material(type: MaterialType.transparency, child: child),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user