Theme Switch fix

This commit is contained in:
2025-02-03 14:26:14 +02:00
parent bcc96f26de
commit 6bfd01c7ab

View File

@@ -18,7 +18,6 @@ class MzanziInnovationHub extends StatefulWidget {
} }
class _MzanziInnovationHubState extends State<MzanziInnovationHub> { class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
late ThemeMode _themeMode;
late MihTheme theme; late MihTheme theme;
Color getPrimany() { Color getPrimany() {
@@ -35,12 +34,11 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
void changeTheme(ThemeMode themeMode) { void changeTheme(ThemeMode themeMode) {
setState(() { setState(() {
_themeMode = themeMode; if (themeMode == ThemeMode.light) {
if (_themeMode == ThemeMode.light) {
setState(() { setState(() {
theme.mode = "Light"; theme.mode = "Light";
}); });
} else if (_themeMode == ThemeMode.dark) { } else if (themeMode == ThemeMode.dark) {
setState(() { setState(() {
theme.mode = "Dark"; theme.mode = "Dark";
}); });
@@ -60,10 +58,8 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
bool isDarkMode = systemTheme == Brightness.dark; bool isDarkMode = systemTheme == Brightness.dark;
if (isDarkMode) { if (isDarkMode) {
theme.mode = "Dark"; theme.mode = "Dark";
_themeMode = ThemeMode.dark;
} else { } else {
theme.mode = "Light"; theme.mode = "Light";
_themeMode = ThemeMode.light;
} }
theme.platform = Theme.of(context).platform; theme.platform = Theme.of(context).platform;
@@ -80,7 +76,7 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
precacheImage(theme.logoFrame(), context); precacheImage(theme.logoFrame(), context);
return MaterialApp( return MaterialApp(
title: getTitle(), title: getTitle(),
themeMode: _themeMode, themeMode: ThemeMode.system,
theme: theme.getThemeData(), theme: theme.getThemeData(),
darkTheme: theme.getThemeData(), darkTheme: theme.getThemeData(),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,