2023-07-27 17:14:50 +02:00
|
|
|
part of '../metadata_settings.dart';
|
|
|
|
|
|
|
|
@npLog
|
2023-07-28 18:48:50 +02:00
|
|
|
class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
2023-07-27 17:14:50 +02:00
|
|
|
_Bloc({
|
|
|
|
required this.prefController,
|
|
|
|
}) : super(_State(
|
2024-02-25 05:09:57 +01:00
|
|
|
isEnable: prefController.isEnableExifValue,
|
|
|
|
isWifiOnly: prefController.shouldProcessExifWifiOnlyValue,
|
2023-07-27 17:14:50 +02:00
|
|
|
)) {
|
|
|
|
on<_Init>(_onInit);
|
|
|
|
on<_SetEnable>(_onSetEnable);
|
|
|
|
on<_SetWifiOnly>(_onSetWifiOnly);
|
|
|
|
}
|
|
|
|
|
2023-07-28 18:48:50 +02:00
|
|
|
@override
|
|
|
|
String get tag => _log.fullName;
|
|
|
|
|
2023-07-27 17:14:50 +02:00
|
|
|
Future<void> _onInit(_Init ev, Emitter<_State> emit) async {
|
|
|
|
_log.info(ev);
|
|
|
|
await Future.wait([
|
|
|
|
emit.forEach<bool>(
|
2024-02-25 05:09:57 +01:00
|
|
|
prefController.isEnableExifChange,
|
2023-07-27 17:14:50 +02:00
|
|
|
onData: (data) => state.copyWith(isEnable: data),
|
|
|
|
onError: (e, stackTrace) {
|
|
|
|
_log.severe("[_onInit] Uncaught exception", e, stackTrace);
|
|
|
|
return state.copyWith(error: ExceptionEvent(e, stackTrace));
|
|
|
|
},
|
|
|
|
),
|
|
|
|
emit.forEach<bool>(
|
2024-02-25 05:09:57 +01:00
|
|
|
prefController.shouldProcessExifWifiOnlyChange,
|
2023-07-27 17:14:50 +02:00
|
|
|
onData: (data) => state.copyWith(isWifiOnly: data),
|
|
|
|
onError: (e, stackTrace) {
|
|
|
|
_log.severe("[_onInit] Uncaught exception", e, stackTrace);
|
|
|
|
return state.copyWith(error: ExceptionEvent(e, stackTrace));
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onSetEnable(_SetEnable ev, Emitter<_State> emit) {
|
|
|
|
_log.info(ev);
|
|
|
|
prefController.setEnableExif(ev.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onSetWifiOnly(_SetWifiOnly ev, Emitter<_State> emit) async {
|
|
|
|
_log.info(ev);
|
|
|
|
await prefController.setProcessExifWifiOnly(ev.value);
|
|
|
|
ServiceConfig.setProcessExifWifiOnly(ev.value).ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
final PrefController prefController;
|
|
|
|
}
|