2023-08-19 18:47:56 +02:00
|
|
|
part of '../my_app.dart';
|
|
|
|
|
|
|
|
@npLog
|
|
|
|
class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
|
|
|
_Bloc({
|
|
|
|
required this.prefController,
|
|
|
|
}) : super(_State(
|
2024-02-25 05:09:57 +01:00
|
|
|
language: prefController.languageValue,
|
|
|
|
isDarkTheme: prefController.isDarkThemeValue,
|
|
|
|
isFollowSystemTheme: prefController.isFollowSystemThemeValue,
|
|
|
|
isUseBlackInDarkTheme: prefController.isUseBlackInDarkThemeValue,
|
|
|
|
seedColor: prefController.seedColorValue?.value,
|
2023-08-19 18:47:56 +02:00
|
|
|
)) {
|
|
|
|
on<_Init>(_onInit);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get tag => _log.fullName;
|
|
|
|
|
|
|
|
Future<void> _onInit(_Init ev, Emitter<_State> emit) async {
|
|
|
|
_log.info(ev);
|
|
|
|
await Future.wait([
|
|
|
|
emit.forEachIgnoreError<language_util.AppLanguage>(
|
2024-02-25 05:09:57 +01:00
|
|
|
prefController.languageChange,
|
2023-08-19 18:47:56 +02:00
|
|
|
onData: (data) => state.copyWith(language: data),
|
|
|
|
),
|
|
|
|
emit.forEachIgnoreError<bool>(
|
2024-02-25 05:09:57 +01:00
|
|
|
prefController.isDarkThemeChange,
|
2023-08-19 18:47:56 +02:00
|
|
|
onData: (data) => state.copyWith(isDarkTheme: data),
|
|
|
|
),
|
|
|
|
emit.forEachIgnoreError<bool>(
|
2024-02-25 05:09:57 +01:00
|
|
|
prefController.isFollowSystemThemeChange,
|
2023-08-19 18:47:56 +02:00
|
|
|
onData: (data) => state.copyWith(isFollowSystemTheme: data),
|
|
|
|
),
|
|
|
|
emit.forEachIgnoreError<bool>(
|
2024-02-25 05:09:57 +01:00
|
|
|
prefController.isUseBlackInDarkThemeChange,
|
2023-08-19 18:47:56 +02:00
|
|
|
onData: (data) => state.copyWith(isUseBlackInDarkTheme: data),
|
|
|
|
),
|
|
|
|
emit.forEachIgnoreError<Color?>(
|
2024-02-25 05:09:57 +01:00
|
|
|
prefController.seedColorChange,
|
2023-08-19 18:47:56 +02:00
|
|
|
onData: (data) => state.copyWith(seedColor: data?.value),
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
final PrefController prefController;
|
|
|
|
}
|