fix functional bugs
This commit is contained in:
@@ -93,7 +93,9 @@ class _MapScreenState extends State<MapScreen> {
|
||||
listenWhen: (previous, current) {
|
||||
return current.lastNotification !=
|
||||
previous.lastNotification ||
|
||||
current.flags != previous.flags;
|
||||
current.flags != previous.flags ||
|
||||
previous.selectedScooterForFocus?.id
|
||||
!= current.selectedScooterForFocus?.id;
|
||||
},
|
||||
|
||||
listener: (context, state) {
|
||||
@@ -164,14 +166,39 @@ class _MapScreenState extends State<MapScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.selectedScooterForFocus != null) {
|
||||
final targetScooter = state.selectedScooterForFocus!;
|
||||
|
||||
print("RESERVED SCOOTER: $targetScooter");
|
||||
|
||||
_moveCameraToPoint(
|
||||
targetScooter.longitude,
|
||||
targetScooter.latitude,
|
||||
zoom: 17,
|
||||
);
|
||||
|
||||
context.read<MapBloc>().add(ClearMapFocus());
|
||||
}
|
||||
},
|
||||
buildWhen: (previous, current) =>
|
||||
previous.scooters != current.scooters ||
|
||||
previous.zones != current.zones,
|
||||
buildWhen: (previous, current) {
|
||||
return previous.scooters != current.scooters ||
|
||||
previous.reservedScooters != current.reservedScooters ||
|
||||
previous.zones != current.zones ||
|
||||
previous.status != current.status;
|
||||
},
|
||||
|
||||
builder: (context, state) {
|
||||
final scooters = _buildScooterPlacemarks(
|
||||
state.scooters,
|
||||
state.address ?? "Unknown address",
|
||||
final freeScooters = _buildScooterPlacemarks(
|
||||
scooters: state.scooters,
|
||||
iconAsset: 'assets/icons/scooter_placemark_fill.png',
|
||||
isClickable: true,
|
||||
);
|
||||
|
||||
final reservedScooters = _buildScooterPlacemarks(
|
||||
scooters: state.reservedScooters ?? [],
|
||||
iconAsset: 'assets/icons/scooter_reserved_placemark_fill.png',
|
||||
isClickable: false,
|
||||
);
|
||||
|
||||
final zonePolygons = _buildZonePolygons(state.zones);
|
||||
@@ -193,9 +220,10 @@ class _MapScreenState extends State<MapScreen> {
|
||||
},
|
||||
mapObjects: [
|
||||
...zonePolygons,
|
||||
...reservedScooters,
|
||||
ClusterizedPlacemarkCollection(
|
||||
mapId: const MapObjectId('scooters_cluster'),
|
||||
placemarks: scooters,
|
||||
placemarks: freeScooters,
|
||||
radius: 30,
|
||||
minZoom: 15,
|
||||
consumeTapEvents: true,
|
||||
@@ -232,7 +260,6 @@ class _MapScreenState extends State<MapScreen> {
|
||||
},
|
||||
),
|
||||
|
||||
// Индикатор загрузки (отдельный строитель для статуса)
|
||||
BlocBuilder<MapBloc, ScooterState>(
|
||||
buildWhen: (previous, current) =>
|
||||
previous.status != current.status,
|
||||
@@ -378,6 +405,7 @@ class _MapScreenState extends State<MapScreen> {
|
||||
}
|
||||
|
||||
void _onMarkerTap(List<Scooter> scooters) async {
|
||||
context.read<MapBloc>().add(CheckUser());
|
||||
final flags = context.read<MapBloc>().state.flags;
|
||||
|
||||
if (!flags.hasCard) {
|
||||
@@ -553,26 +581,26 @@ class _MapScreenState extends State<MapScreen> {
|
||||
await ClusterIconPainter.initImage('assets/icons/scooter_placemark.png');
|
||||
}
|
||||
|
||||
List<PlacemarkMapObject> _buildScooterPlacemarks(
|
||||
List<Scooter> scooters,
|
||||
String address,
|
||||
) {
|
||||
List<PlacemarkMapObject> _buildScooterPlacemarks({
|
||||
required List<Scooter> scooters,
|
||||
required String iconAsset,
|
||||
required bool isClickable,
|
||||
}) {
|
||||
return scooters.map((scooter) {
|
||||
return PlacemarkMapObject(
|
||||
mapId: MapObjectId('${scooter.id}'),
|
||||
mapId: MapObjectId('${isClickable ? "" : "reserved_"}${scooter.id}'), // уникальный ID для карты
|
||||
point: Point(latitude: scooter.longitude, longitude: scooter.latitude),
|
||||
icon: PlacemarkIcon.single(
|
||||
PlacemarkIconStyle(
|
||||
image: BitmapDescriptor.fromAssetImage(
|
||||
'assets/icons/scooter_placemark_fill.png',
|
||||
),
|
||||
image: BitmapDescriptor.fromAssetImage(iconAsset),
|
||||
scale: 0.2,
|
||||
),
|
||||
),
|
||||
opacity: 1.0,
|
||||
onTap: (object, point) async => {
|
||||
_onMarkerTap([scooter]),
|
||||
},
|
||||
consumeTapEvents: isClickable,
|
||||
onTap: isClickable
|
||||
? (object, point) async => _onMarkerTap([scooter])
|
||||
: null,
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user