nc-photos/app/lib/widget/place_picker/bloc.dart

40 lines
1 KiB
Dart
Raw Normal View History

2024-10-30 15:14:08 +01:00
part of 'place_picker.dart';
@npLog
class _Bloc extends Bloc<_Event, _State> with BlocLogger {
_Bloc({
required this.prefController,
required this.initialPosition,
required this.initialZoom,
}) : super(_State.init()) {
2024-10-30 15:14:08 +01:00
on<_SetPosition>(_onSetPosition);
on<_Done>(_onDone);
2024-10-30 15:14:08 +01:00
}
@override
String get tag => _log.fullName;
@override
bool Function(dynamic, dynamic)? get shouldLog => (currentState, nextState) {
return currentState.position == nextState.position;
};
void _onSetPosition(_SetPosition ev, _Emitter emit) {
// _log.info(ev);
emit(state.copyWith(position: ev.value));
}
void _onDone(_Done ev, _Emitter emit) {
_log.info(ev);
if (prefController.mapBrowserPrevPositionValue == null &&
state.position != null) {
prefController.setMapBrowserPrevPosition(state.position!.center);
}
emit(state.copyWith(isDone: true));
}
final PrefController prefController;
final MapCoord? initialPosition;
final double? initialZoom;
2024-10-30 15:14:08 +01:00
}