Update: 2026-06-11 13:47:39

This commit is contained in:
Hamza-Ayed
2026-06-11 13:47:40 +03:00
parent 977adfe99d
commit c5170a88d2
516 changed files with 3654 additions and 3321 deletions

View File

@@ -23,6 +23,7 @@ import '../../../constant/country_polygons.dart';
import '../../../constant/links.dart';
import '../../../constant/table_names.dart';
import '../../../env/env.dart';
import '../../../views/home/Captin/orderCaptin/marker_generator.dart';
import '../../../main.dart';
import '../../../print.dart';
import '../../../views/Rate/rate_passenger.dart';
@@ -51,6 +52,7 @@ class MapDriverController extends GetxController
InlqBitmap passengerIcon = InlqBitmap.defaultMarker;
InlqBitmap startIcon = InlqBitmap.defaultMarker;
InlqBitmap endIcon = InlqBitmap.defaultMarker;
InlqBitmap? walkIcon;
final List<LatLng> polylineCoordinates = [];
final List<LatLng> polylineCoordinatesDestination = [];
List<Polyline> polyLines = [];
@@ -264,6 +266,8 @@ class MapDriverController extends GetxController
);
}
_updatePassengerWalkLine();
Log.print(
"🔄 [onMapCreated] Redrawn ${polyLines.length} polylines after map rebuild.");
update();
@@ -297,6 +301,8 @@ class MapDriverController extends GetxController
});
}
int _walkLineUpdateCounter = 0;
Future<void> startListeningStepNavigation() async {
// Cancel any previous listener
_navigationTimer?.cancel();
@@ -343,6 +349,12 @@ class MapDriverController extends GetxController
if (upcomingPathPoints.isNotEmpty) {
_updateTraveledPolylineSmart(myLocation);
}
// تحديث خط المشي المنقط كل 3 ثوانٍ أثناء التنقل (كل 6 دورات × 500ms)
_walkLineUpdateCounter++;
if (_walkLineUpdateCounter % 6 == 0) {
_updatePassengerWalkLine();
}
if (isCameraLocked) {
final double bearing = speedKmh > 5 ? heading : 0.0;
_animateCameraToNavigationMode(newLoc, bearing);
@@ -1841,7 +1853,7 @@ class MapDriverController extends GetxController
box.write(BoxName.countryCode, 'Jordan');
update(); // [Fix N-5]
// box.write(BoxName.serverChosen,
// AppLink.IntaleqSyriaServer); // مثال: اختر سيرفر سوريا للبيانات
// AppLink.SiroSyriaServer); // مثال: اختر سيرفر سوريا للبيانات
return 'Jordan';
}
@@ -1951,6 +1963,8 @@ class MapDriverController extends GetxController
),
);
_updatePassengerWalkLine();
// د) معالجة الخطوات (Instructions) للسيرفر الموحد
final List<dynamic> instructions = response['instructions'] ?? [];
if (instructions.isNotEmpty) {
@@ -2309,15 +2323,30 @@ class MapDriverController extends GetxController
southwest: southwest,
);
// Fit the camera to the bounds
var cameraUpdate = CameraUpdate.newLatLngBounds(
boundsData,
left: 140,
top: 140,
right: 140,
bottom: 140,
);
safeAnimateCamera(cameraUpdate);
final latDiff =
(boundsData.northeast.latitude - boundsData.southwest.latitude).abs();
final lngDiff =
(boundsData.northeast.longitude - boundsData.southwest.longitude).abs();
if (latDiff < 0.0001 || lngDiff < 0.0001) {
final center = LatLng(
(boundsData.northeast.latitude + boundsData.southwest.latitude) / 2,
(boundsData.northeast.longitude + boundsData.southwest.longitude) / 2,
);
safeAnimateCamera(CameraUpdate.newCameraPosition(
CameraPosition(target: center, zoom: 17),
));
} else {
// Fit the camera to the bounds
var cameraUpdate = CameraUpdate.newLatLngBounds(
boundsData,
left: 140,
top: 140,
right: 140,
bottom: 140,
);
safeAnimateCamera(cameraUpdate);
}
}
void changePassengerInfoWindow() {
@@ -2539,6 +2568,10 @@ class MapDriverController extends GetxController
addCustomPassengerIcon();
addCustomStartIcon();
addCustomEndIcon();
MarkerGenerator.createWalkMarker().then((icon) {
walkIcon = icon;
update();
});
if (!Get.isRegistered<TextToSpeechController>()) {
Get.put(TextToSpeechController(), permanent: true);
@@ -2575,7 +2608,8 @@ class MapDriverController extends GetxController
}
/// [Fix C-4] تحديث myLocation في المستمع الأساسي
void handleLocationUpdateFromCentral(LatLng newLoc, double posSpeed, double posHeading) {
void handleLocationUpdateFromCentral(
LatLng newLoc, double posSpeed, double posHeading) {
myLocation = newLoc; // ← [Fix C-4] تحديث الموقع الفوري
_oldLoc = smoothedLocation ?? newLoc;
_targetLoc = newLoc;
@@ -2763,6 +2797,7 @@ class MapDriverController extends GetxController
),
);
_updatePassengerWalkLine();
update();
}
}
@@ -2773,6 +2808,70 @@ class MapDriverController extends GetxController
// [Fix 1] إعادة تشغيل المستمع الأساسي للحركة السلسة بعد إيقاف الملاحة.
_startLocationListening();
}
// دالة لبناء الخط المنقط
List<Polyline> _buildDashedLine(LatLng start, LatLng end,
{required Color color, required String prefixId}) {
List<Polyline> segments = [];
double dist = Geolocator.distanceBetween(
start.latitude, start.longitude, end.latitude, end.longitude);
if (dist < 2) return []; // قريبة جداً، لا نرسم خطاً
const double dashLengthMeters = 8.0;
const double gapLengthMeters = 6.0;
double totalLength = 0.0;
int segmentCount = 0;
while (totalLength < dist) {
double startFraction = totalLength / dist;
double startLat =
start.latitude + (end.latitude - start.latitude) * startFraction;
double startLng =
start.longitude + (end.longitude - start.longitude) * startFraction;
totalLength += dashLengthMeters;
if (totalLength > dist) totalLength = dist;
double endFraction = totalLength / dist;
double endLat =
start.latitude + (end.latitude - start.latitude) * endFraction;
double endLng =
start.longitude + (end.longitude - start.longitude) * endFraction;
segments.add(
Polyline(
polylineId: PolylineId('${prefixId}_dash_$segmentCount'),
points: [LatLng(startLat, startLng), LatLng(endLat, endLng)],
color: color,
width: 4.0,
),
);
segmentCount++;
totalLength += gapLengthMeters;
}
return segments;
}
// تحديث ورسم الخط المنقط من نهاية الطريق إلى موقع الراكب الفعلي
void _updatePassengerWalkLine() {
// مسح خطوط المشي السابقة
polyLines.removeWhere(
(p) => p.polylineId.value.startsWith('passenger_walk_line'));
if (!isRideStarted &&
upcomingPathPoints.isNotEmpty &&
latLngPassengerLocation.latitude != 0) {
final LatLng lastRoadPt = upcomingPathPoints.last;
final walkDashes = _buildDashedLine(
lastRoadPt,
latLngPassengerLocation,
color: Colors.blueGrey, // لون أزرق رمادي مميز
prefixId: 'passenger_walk_line',
);
polyLines.addAll(walkDashes);
}
}
}
double safeParseDouble(dynamic value, {double defaultValue = 0.0}) {