fix: stabilize passenger mapping interactions and finalize localization

This commit is contained in:
Hamza-Ayed
2026-04-18 19:16:01 +03:00
parent a54a7a4189
commit 61343111a2
28 changed files with 14917 additions and 14716 deletions

View File

@@ -1,10 +1,11 @@
import 'dart:math' as math;
import 'dart:typed_data';
import 'package:Intaleq/env/env.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:maplibre_gl/maplibre_gl.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.dart';
@@ -413,7 +414,9 @@ class _RideDetailSheet extends StatefulWidget {
}
class _RideDetailSheetState extends State<_RideDetailSheet> {
MapLibreMapController? _mc;
IntaleqMapController? _mc;
Set<Marker> _markers = {};
Set<Polyline> _polylines = {};
LatLngBounds? get _bounds {
final latDiff = (widget.start.latitude - widget.end.latitude).abs();
@@ -431,7 +434,7 @@ class _RideDetailSheetState extends State<_RideDetailSheet> {
);
}
void _onMapCreated(MapLibreMapController c) => _mc = c;
void _onMapCreated(IntaleqMapController c) => _mc = c;
Future<void> _onStyleLoaded() async {
WidgetsBinding.instance.addPostFrameCallback((_) async {
@@ -442,48 +445,45 @@ class _RideDetailSheetState extends State<_RideDetailSheet> {
}
Future<void> _draw() async {
final mc = _mc;
if (mc == null || !mounted) return;
if (!mounted) return;
try {
final aData = await rootBundle.load('assets/images/A.png');
await mc.addImage('det_start', aData.buffer.asUint8List());
final bData = await rootBundle.load('assets/images/b.png');
await mc.addImage('det_end', bData.buffer.asUint8List());
} catch (_) {}
setState(() {
_polylines = {
Polyline(
polylineId: const PolylineId('route'),
points: [widget.start, widget.end],
color: AppColor.primaryColor,
width: 4,
),
};
await mc.addLine(LineOptions(
geometry: [widget.start, widget.end],
lineColor:
'#${AppColor.primaryColor.value.toRadixString(16).substring(2)}',
lineWidth: 4.0,
lineOpacity: 1.0,
));
await mc.addSymbol(SymbolOptions(
geometry: widget.start,
iconImage: 'det_start',
iconSize: 0.8,
iconAnchor: 'bottom',
));
await mc.addSymbol(SymbolOptions(
geometry: widget.end,
iconImage: 'det_end',
iconSize: 0.8,
iconAnchor: 'bottom',
));
_markers = {
Marker(
markerId: const MarkerId('start'),
position: widget.start,
icon: InlqBitmap.fromAsset('assets/images/A.png'),
anchor: const Offset(0.5, 1.0),
),
Marker(
markerId: const MarkerId('end'),
position: widget.end,
icon: InlqBitmap.fromAsset('assets/images/b.png'),
anchor: const Offset(0.5, 1.0),
),
};
});
final b = _bounds;
if (b != null) {
await mc.animateCamera(CameraUpdate.newLatLngBounds(b,
await _mc?.animateCamera(CameraUpdate.newLatLngBounds(b,
left: 60, top: 60, right: 60, bottom: 60));
} else {
await mc.animateCamera(CameraUpdate.newLatLngZoom(widget.start, 14));
await _mc?.animateCamera(CameraUpdate.newLatLngZoom(widget.start, 14));
}
}
@override
void dispose() {
_mc?.dispose();
super.dispose();
}
@@ -524,14 +524,20 @@ class _RideDetailSheetState extends State<_RideDetailSheet> {
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
child: MapLibreMap(
styleString: 'assets/style.json',
child: IntaleqMap(
apiKey: Env.mapSaasKey,
styleUrl: Get.isDarkMode
? 'assets/style_dark.json'
: 'assets/style.json',
initialCameraPosition:
CameraPosition(target: center, zoom: 12),
onMapCreated: _onMapCreated,
onStyleLoadedCallback: _onStyleLoaded,
onMapCreated: (c) {
_mc = c;
_onStyleLoaded();
},
myLocationEnabled: false,
trackCameraPosition: false,
markers: _markers,
polylines: _polylines,
),
),
),