-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theme change functionality #22
base: master
Are you sure you want to change the base?
Theme change functionality #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import 'app_colors.dart'; | ||
|
||
class AppThemes { | ||
// light theme configurations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our code should be self explanatory. don't need to add unnecessary comment.
); | ||
} | ||
|
||
// dark theme configurations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our code should be self explanatory. don't need to add unnecessary comment.
// Get themeMode info from local storage and return current ThemeMode | ||
Future<ThemeMode> get themeMode async => | ||
await _loadThemeFromSharedPref() ? ThemeMode.dark : ThemeMode.light; | ||
|
||
// Load themeMode from local storage | ||
Future<bool> _loadThemeFromSharedPref() async { | ||
return await _preferenceManager.getBool(themeModeKey); | ||
} | ||
|
||
// Load isDarkMode status from local storage | ||
Future<bool> getCurrentThemeMode() async { | ||
return await _preferenceManager.getBool(themeModeKey); | ||
} | ||
|
||
// change isDarkMode status in local storage | ||
changeThemeMode(bool isDarkMode) { | ||
_preferenceManager.setBool(themeModeKey, isDarkMode); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our code should be self explanatory. don't need to add unnecessary comment.
getCurrentThemeMode() async { | ||
currentThemeMode.value = await themeService.themeMode; | ||
} | ||
|
||
setCurrentThemeMode(ThemeMode themeMode) { | ||
currentThemeMode.value = themeMode; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add return type as void
.
Here the background color of the cards are static colors from AppColors file, to make it dynamic we need to use colors from the theme regardless of we use GetX theme or our custom theme class. Should I refactor them to use colors from theme? |
Why? (ticket link or issue description)
#16
What was done and how?
Theme changing was implemented with GetX
Anything special? (optional)