|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | + |
| 3 | +class AppThemeController extends ValueNotifier<ThemeMode> { |
| 4 | + AppThemeController() : super(ThemeMode.system); |
| 5 | + |
| 6 | + void toggle() { |
| 7 | + value = value == ThemeMode.dark ? ThemeMode.light : ThemeMode.dark; |
| 8 | + } |
| 9 | + |
| 10 | + void setDarkMode(bool enabled) { |
| 11 | + value = enabled ? ThemeMode.dark : ThemeMode.light; |
| 12 | + } |
| 13 | + |
| 14 | + bool get isDark => value == ThemeMode.dark; |
| 15 | +} |
| 16 | + |
| 17 | +class AppTheme { |
| 18 | + AppTheme._(); |
| 19 | + |
| 20 | + static final light = ThemeData( |
| 21 | + brightness: Brightness.light, |
| 22 | + colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue), |
| 23 | + scaffoldBackgroundColor: Colors.grey.shade50, |
| 24 | + appBarTheme: const AppBarTheme(elevation: 0, scrolledUnderElevation: 0.5), |
| 25 | + cardTheme: CardThemeData( |
| 26 | + color: Colors.white, |
| 27 | + elevation: 4.0, |
| 28 | + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), |
| 29 | + ), |
| 30 | + navigationBarTheme: const NavigationBarThemeData(elevation: 1), |
| 31 | + ); |
| 32 | + |
| 33 | + static final dark = ThemeData( |
| 34 | + brightness: Brightness.dark, |
| 35 | + colorScheme: ColorScheme.fromSeed( |
| 36 | + seedColor: Colors.blue, |
| 37 | + brightness: Brightness.dark, |
| 38 | + ), |
| 39 | + scaffoldBackgroundColor: const Color(0xFF121212), |
| 40 | + appBarTheme: const AppBarTheme(elevation: 0, scrolledUnderElevation: 0.5), |
| 41 | + cardTheme: CardThemeData( |
| 42 | + color: const Color(0xFF1E1E1E), |
| 43 | + elevation: 4.0, |
| 44 | + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), |
| 45 | + ), |
| 46 | + navigationBarTheme: const NavigationBarThemeData(elevation: 1), |
| 47 | + ); |
| 48 | +} |
0 commit comments