refactor(theme&ui): improve theme switching and navigation styling

This commit is contained in:
anhtunz
2024-12-26 14:52:33 +07:00
parent a69429b05f
commit 70e3ed8978
6 changed files with 255 additions and 366 deletions

View File

@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import '../cache/local_manager.dart';
import '../constant/enums/app_theme_enums.dart';
import '../constant/enums/local_keys_enums.dart';
import '../theme/app_theme_dark.dart';
import '../theme/app_theme_light.dart';
class ThemeServices{
ThemeData _currentTheme(String theme) {
if (theme == AppThemes.LIGHT.name) {
return AppThemeLight.instance.theme;
} else if (theme == AppThemes.DARK.name) {
return AppThemeDark.instance.theme;
} else {
return AppThemeLight.instance.theme;
}
}
Future<ThemeData> getTheme() async {
await LocaleManager.prefrencesInit();
String theme = LocaleManager.instance.getStringValue(PreferencesKeys.THEME);
return _currentTheme(theme);
}
Future<ThemeData> changeTheme(String theme) async {
await LocaleManager.prefrencesInit();
LocaleManager.instance
.setStringValue(PreferencesKeys.THEME, theme);
return _currentTheme(theme);
}
}