2024-10-30 15:14:08 +01:00
|
|
|
part of 'place_picker.dart';
|
|
|
|
|
|
|
|
@npLog
|
|
|
|
class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
2024-11-29 19:19:53 +01:00
|
|
|
_Bloc({
|
|
|
|
required this.prefController,
|
|
|
|
required this.initialPosition,
|
|
|
|
required this.initialZoom,
|
|
|
|
}) : super(_State.init()) {
|
2024-10-30 15:14:08 +01:00
|
|
|
on<_SetPosition>(_onSetPosition);
|
2024-11-29 19:19:53 +01:00
|
|
|
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));
|
|
|
|
}
|
2024-11-29 19:19:53 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|