refactor(theme&ui): improve theme switching and navigation styling
This commit is contained in:
33
lib/product/services/theme_services.dart
Normal file
33
lib/product/services/theme_services.dart
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user