Theme Changer (Primitive?)

This commit is contained in:
2023-12-30 15:22:59 +02:00
parent fedc5df0c7
commit 75e21261dc
4 changed files with 54 additions and 79 deletions

View File

@@ -6,9 +6,18 @@ import 'package:witl/input_data.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
static _MyAppState of(BuildContext context) => context.findAncestorStateOfType<_MyAppState>()!;
}
class _MyAppState extends State<MyApp> {
ThemeMode _theme = ThemeMode.system;
@override
Widget build(BuildContext context) {
return MaterialApp(
@@ -26,11 +35,11 @@ class MyApp extends StatelessWidget {
primaryColor: Colors.black,
brightness: Brightness.dark,
dividerColor: Colors.black12,
scaffoldBackgroundColor: Color(0xFF131313),
scaffoldBackgroundColor: const Color(0xFF131313),
),
themeMode: ThemeMode.system,
themeMode: _theme,
// Navigashun with Routes
// Base "Home" Route
@@ -52,4 +61,17 @@ class MyApp extends StatelessWidget {
},
);
}
void changeTheme(String newTheme) {
setState(() {
switch(newTheme) {
case "Light":
_theme = ThemeMode.light;
case "Dark":
_theme = ThemeMode.dark;
case "System Default":
_theme = ThemeMode.system;
}
});
}
}