elCaribe app - customization and branding
This commit is contained in:
21
news-app/lib/cubits/themeCubit.dart
Normal file
21
news-app/lib/cubits/themeCubit.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:news/data/repositories/Settings/settingsLocalDataRepository.dart';
|
||||
|
||||
import 'package:news/ui/styles/appTheme.dart';
|
||||
|
||||
import 'package:news/utils/uiUtils.dart';
|
||||
|
||||
class ThemeState {
|
||||
final AppTheme appTheme;
|
||||
ThemeState(this.appTheme);
|
||||
}
|
||||
|
||||
class ThemeCubit extends Cubit<ThemeState> {
|
||||
SettingsLocalDataRepository settingsRepository;
|
||||
ThemeCubit(this.settingsRepository) : super(ThemeState(UiUtils.getAppThemeFromLabel(settingsRepository.getCurrentTheme())));
|
||||
|
||||
void changeTheme(AppTheme appTheme) {
|
||||
settingsRepository.setCurrentTheme(UiUtils.getThemeLabelFromAppTheme(appTheme));
|
||||
emit(ThemeState(appTheme));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user