25-9-1-1
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
@@ -6,15 +8,15 @@ import 'package:Intaleq/controller/home/points_for_rider_controller.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/functions/location_controller.dart';
|
||||
import '../../../controller/home/device_tier.dart';
|
||||
import '../../../controller/home/map_passenger_controller.dart';
|
||||
import '../../widgets/mycircular.dart';
|
||||
import '../../widgets/mydialoug.dart';
|
||||
|
||||
class GoogleMapPassengerWidget extends StatelessWidget {
|
||||
GoogleMapPassengerWidget({
|
||||
super.key,
|
||||
});
|
||||
WayPointController wayPointController = Get.put(WayPointController());
|
||||
GoogleMapPassengerWidget({super.key});
|
||||
|
||||
final WayPointController wayPointController = Get.put(WayPointController());
|
||||
final LocationController locationController = Get.find<LocationController>();
|
||||
|
||||
@override
|
||||
@@ -30,19 +32,25 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
||||
child: GoogleMap(
|
||||
onMapCreated: controller.onMapCreated,
|
||||
|
||||
// ✅ حدود الكاميرا كما هي
|
||||
cameraTargetBounds: CameraTargetBounds(controller.boundsdata),
|
||||
minMaxZoomPreference: const MinMaxZoomPreference(6, 18),
|
||||
|
||||
// ✅ Zoom أهدأ للأجهزة الضعيفة
|
||||
minMaxZoomPreference: controller.lowPerf
|
||||
? const MinMaxZoomPreference(6, 17)
|
||||
: const MinMaxZoomPreference(6, 18),
|
||||
|
||||
onLongPress: (argument) {
|
||||
MyDialog().getDialog('Are you want to go to this site'.tr, '',
|
||||
() async {
|
||||
controller.clearPolyline();
|
||||
if (controller.dataCarsLocationByPassenger != null) {
|
||||
await controller.getDirectionMap(
|
||||
'${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
|
||||
'${argument.latitude.toString()},${argument.longitude.toString()}');
|
||||
|
||||
'${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
|
||||
'${argument.latitude},${argument.longitude}',
|
||||
);
|
||||
Get.back();
|
||||
controller.bottomSheet();
|
||||
await controller.bottomSheet();
|
||||
controller.showBottomSheet1();
|
||||
} else {
|
||||
Get.back();
|
||||
@@ -54,15 +62,12 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
||||
duration: const Duration(seconds: 11),
|
||||
instantInit: true,
|
||||
snackPosition: SnackPosition.TOP,
|
||||
titleText: Text(
|
||||
'Error'.tr,
|
||||
style: const TextStyle(color: AppColor.redColor),
|
||||
),
|
||||
titleText: Text('Error'.tr,
|
||||
style: const TextStyle(color: AppColor.redColor)),
|
||||
messageText: Text(
|
||||
'We Are Sorry That we dont have cars in your Location!'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
'We Are Sorry That we dont have cars in your Location!'
|
||||
.tr,
|
||||
style: AppStyle.title),
|
||||
icon: const Icon(Icons.error),
|
||||
shouldIconPulse: true,
|
||||
maxWidth: double.infinity,
|
||||
@@ -86,370 +91,98 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
// mainButton: TextButton(
|
||||
// onPressed: () {
|
||||
// controller.getCarsLocationByPassenger();
|
||||
// },
|
||||
// child: Text(
|
||||
// 'Try Again'.tr,
|
||||
// style: const TextStyle(
|
||||
// color: AppColor.secondaryColor),
|
||||
// ),
|
||||
// ),
|
||||
onTap: (GetSnackBar snackBar) {
|
||||
// Do something when the snackbar is tapped.
|
||||
},
|
||||
isDismissible: true,
|
||||
showProgressIndicator: false,
|
||||
dismissDirection: DismissDirection.up,
|
||||
progressIndicatorController: null,
|
||||
progressIndicatorBackgroundColor: Colors.transparent,
|
||||
progressIndicatorValueColor: null,
|
||||
snackStyle: SnackStyle.GROUNDED,
|
||||
forwardAnimationCurve: Curves.easeInToLinear,
|
||||
reverseAnimationCurve: Curves.easeInOut,
|
||||
animationDuration: const Duration(milliseconds: 4000),
|
||||
barBlur: 8,
|
||||
overlayBlur: 0,
|
||||
snackbarStatus: null,
|
||||
overlayColor: AppColor.primaryColor.withOpacity(0.5),
|
||||
userInputForm: null,
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
});
|
||||
// Get.defaultDialog(
|
||||
// title: 'Are you want to go to this site'.tr,
|
||||
// content: Column(
|
||||
// children: [
|
||||
// Text('${argument.latitude},${argument.longitude}'),
|
||||
// ],
|
||||
// ),
|
||||
// confirm: MyElevatedButton(
|
||||
// title: 'Ok'.tr,
|
||||
// onPressed: () async {
|
||||
// controller.clearPolyline();
|
||||
// if (controller.dataCarsLocationByPassenger != null) {
|
||||
// await controller.getMap(
|
||||
// '${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
|
||||
// '${argument.latitude.toString()},${argument.longitude.toString()}');
|
||||
|
||||
// Get.back();
|
||||
// controller.bottomSheet();
|
||||
// controller.showBottomSheet1();
|
||||
// } else {
|
||||
// Get.back();
|
||||
// Get.snackbar(
|
||||
// 'We Are Sorry That we dont have cars in your Location!'
|
||||
// .tr,
|
||||
// '',
|
||||
// colorText: AppColor.redColor,
|
||||
// duration: const Duration(seconds: 11),
|
||||
// instantInit: true,
|
||||
// snackPosition: SnackPosition.TOP,
|
||||
// titleText: Text(
|
||||
// 'Error'.tr,
|
||||
// style:
|
||||
// const TextStyle(color: AppColor.redColor),
|
||||
// ),
|
||||
// messageText: Text(
|
||||
// 'We Are Sorry That we dont have cars in your Location!'
|
||||
// .tr,
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
// icon: const Icon(Icons.error),
|
||||
// shouldIconPulse: true,
|
||||
// maxWidth: double.infinity,
|
||||
// margin: const EdgeInsets.all(16),
|
||||
// padding: const EdgeInsets.all(16),
|
||||
// borderRadius: 8,
|
||||
// borderColor: AppColor.redColor,
|
||||
// borderWidth: 2,
|
||||
// backgroundColor: AppColor.secondaryColor,
|
||||
// leftBarIndicatorColor: AppColor.redColor,
|
||||
// boxShadows: [
|
||||
// BoxShadow(
|
||||
// color: Colors.black.withOpacity(0.25),
|
||||
// blurRadius: 4,
|
||||
// spreadRadius: 2,
|
||||
// offset: const Offset(0, 4),
|
||||
// ),
|
||||
// ],
|
||||
// backgroundGradient: const LinearGradient(
|
||||
// colors: [
|
||||
// AppColor.redColor,
|
||||
// AppColor.accentColor
|
||||
// ],
|
||||
// begin: Alignment.topLeft,
|
||||
// end: Alignment.bottomRight,
|
||||
// ),
|
||||
// // mainButton: TextButton(
|
||||
// // onPressed: () {
|
||||
// // controller.getCarsLocationByPassenger();
|
||||
// // },
|
||||
// // child: Text(
|
||||
// // 'Try Again'.tr,
|
||||
// // style: const TextStyle(
|
||||
// // color: AppColor.secondaryColor),
|
||||
// // ),
|
||||
// // ),
|
||||
// onTap: (GetSnackBar snackBar) {
|
||||
// // Do something when the snackbar is tapped.
|
||||
// },
|
||||
// isDismissible: true,
|
||||
// showProgressIndicator: false,
|
||||
// dismissDirection: DismissDirection.up,
|
||||
// progressIndicatorController: null,
|
||||
// progressIndicatorBackgroundColor:
|
||||
// Colors.transparent,
|
||||
// progressIndicatorValueColor: null,
|
||||
// snackStyle: SnackStyle.GROUNDED,
|
||||
// forwardAnimationCurve: Curves.easeInToLinear,
|
||||
// reverseAnimationCurve: Curves.easeInOut,
|
||||
// animationDuration:
|
||||
// const Duration(milliseconds: 4000),
|
||||
// barBlur: 8,
|
||||
// overlayBlur: 0,
|
||||
// snackbarStatus: null,
|
||||
// overlayColor:
|
||||
// AppColor.primaryColor.withOpacity(0.5),
|
||||
// userInputForm: null,
|
||||
// );
|
||||
// }
|
||||
|
||||
// //
|
||||
// }),
|
||||
// );
|
||||
},
|
||||
|
||||
onTap: (argument) {
|
||||
controller.hidePlaces();
|
||||
|
||||
// controller.changeBottomSheetShown();
|
||||
// controller.bottomSheet();
|
||||
},
|
||||
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: controller.passengerLocation,
|
||||
zoom: 15,
|
||||
zoom: controller.lowPerf ? 14.5 : 15,
|
||||
),
|
||||
|
||||
// ✅ ماركرز (احرص أن الأيقونات محجّمة ومخزّنة Cache في الكنترولر)
|
||||
markers: controller.markers.toSet(),
|
||||
// {
|
||||
// if (controller.statusRide != 'Apply' ||
|
||||
// !controller.rideTimerBegin)
|
||||
// for (var carLocation in controller.carLocationsModels)
|
||||
|
||||
// // Marker(
|
||||
// // // anchor: const Offset(4, 4),
|
||||
// // position: LatLng(
|
||||
// // carLocation.latitude,
|
||||
// // carLocation.longitude,
|
||||
// // ),
|
||||
// // icon: controller.carIcon,
|
||||
// // markerId: MarkerId(carLocation.toString()),
|
||||
// // rotation: carLocation.heading,
|
||||
// // ),
|
||||
// // controller.carMarrkerAplied,
|
||||
// if (controller.statusRide == 'Apply')
|
||||
// // for (var carLocation
|
||||
// // in controller.driverCarsLocationToPassengerAfterApplied)
|
||||
// Marker(
|
||||
// // anchor: const Offset(4, 4),
|
||||
// position: LatLng(
|
||||
// double.parse(
|
||||
// controller
|
||||
// .datadriverCarsLocationToPassengerAfterApplied[
|
||||
// 'message'][0]['latitude'],
|
||||
// ),
|
||||
// double.parse(
|
||||
// controller
|
||||
// .datadriverCarsLocationToPassengerAfterApplied[
|
||||
// 'message'][0]['longitude'],
|
||||
// ),
|
||||
// ), //carLocation,
|
||||
// icon: controller.carIcon,
|
||||
// rotation: double.parse(controller
|
||||
// .datadriverCarsLocationToPassengerAfterApplied[
|
||||
// 'message'][0]['heading']),
|
||||
// markerId: MarkerId(controller
|
||||
// .datadriverCarsLocationToPassengerAfterApplied[
|
||||
// 'message'][0]['longitude']
|
||||
// .toString())),
|
||||
// for (int i = 1;
|
||||
// i < controller.coordinatesWithoutEmpty.length - 1;
|
||||
// i++)
|
||||
// Marker(
|
||||
// // anchor: const Offset(4, 4),
|
||||
// position: LatLng(
|
||||
// double.parse(controller.coordinatesWithoutEmpty[i]
|
||||
// .split(',')[0]),
|
||||
// double.parse(controller.coordinatesWithoutEmpty[i]
|
||||
// .split(',')[1])),
|
||||
// icon: controller.tripIcon,
|
||||
// markerId: MarkerId(
|
||||
// controller.coordinatesWithoutEmpty[i].toString())),
|
||||
// if (controller.isMarkersShown)
|
||||
// Marker(
|
||||
// markerId: MarkerId('MyLocation'.tr),
|
||||
// position: controller.newStartPointLocation,
|
||||
// draggable: true,
|
||||
// icon: controller.startIcon,
|
||||
// ),
|
||||
// if (controller.isMarkersShown)
|
||||
// Marker(
|
||||
// markerId: MarkerId('Destination'.tr),
|
||||
// position: controller.myDestination,
|
||||
// draggable: true,
|
||||
// icon: controller.endIcon,
|
||||
// ),
|
||||
// if (controller.haveSteps)
|
||||
// Marker(
|
||||
// markerId: MarkerId('StartSteps'.tr),
|
||||
// position: LatLng(
|
||||
// double.parse(
|
||||
// controller.placesCoordinate[0].split(',')[0]),
|
||||
// double.parse(
|
||||
// controller.placesCoordinate[0].split(',')[1])),
|
||||
// draggable: true,
|
||||
// icon: controller.startIcon,
|
||||
// ),
|
||||
// if (controller.haveSteps)
|
||||
// Marker(
|
||||
// markerId: MarkerId('EndSteps'.tr),
|
||||
// position: controller.latestPosition,
|
||||
// draggable: true,
|
||||
// icon: controller.endIcon,
|
||||
// ),
|
||||
// },
|
||||
// ✅ بوليغونز كما هي
|
||||
polygons: controller.polygons,
|
||||
polylines: controller.polyLines.toSet(),
|
||||
// {
|
||||
// Polyline(
|
||||
// polylineId: const PolylineId('route'),
|
||||
// points: controller.polylineCoordinates,
|
||||
// color: AppColor.primaryColor,
|
||||
// width: 4,
|
||||
// // patterns: [
|
||||
// // PatternItem.dot,
|
||||
// // PatternItem.gap(10),
|
||||
// // ],
|
||||
// endCap: Cap.roundCap,
|
||||
// startCap: Cap.roundCap,
|
||||
// geodesic: true,
|
||||
// ),
|
||||
|
||||
// Polyline(
|
||||
// zIndex: 1,
|
||||
// consumeTapEvents: true,
|
||||
// geodesic: true,
|
||||
// endCap: Cap.buttCap,
|
||||
// startCap: Cap.buttCap,
|
||||
// visible: true,
|
||||
// polylineId: const PolylineId('route0'),
|
||||
// points: controller.polylineCoordinatesPointsAll[0],
|
||||
// color: AppColor.blueColor,
|
||||
// width: 5,
|
||||
// ),
|
||||
// Polyline(
|
||||
// zIndex: 2,
|
||||
// consumeTapEvents: true,
|
||||
// geodesic: true,
|
||||
// endCap: Cap.buttCap,
|
||||
// startCap: Cap.buttCap,
|
||||
// visible: true,
|
||||
// polylineId: const PolylineId('route1'),
|
||||
// points: controller.polylineCoordinatesPointsAll[1],
|
||||
// color: AppColor.yellowColor,
|
||||
// width: 5,
|
||||
// ),
|
||||
// Polyline(
|
||||
// zIndex: 2,
|
||||
// consumeTapEvents: true,
|
||||
// geodesic: true,
|
||||
// endCap: Cap.buttCap,
|
||||
// startCap: Cap.buttCap,
|
||||
// visible: true,
|
||||
// polylineId: const PolylineId('route2'),
|
||||
// points: controller.polylineCoordinatesPointsAll[2],
|
||||
// color: AppColor.greenColor,
|
||||
// width: 5,
|
||||
// ),
|
||||
// Polyline(
|
||||
// zIndex: 2,
|
||||
// consumeTapEvents: true,
|
||||
// geodesic: true,
|
||||
// endCap: Cap.buttCap,
|
||||
// startCap: Cap.buttCap,
|
||||
// visible: true,
|
||||
// polylineId: const PolylineId('route3'),
|
||||
// points: controller.polylineCoordinatesPointsAll[2],
|
||||
// color: AppColor.deepPurpleAccent,
|
||||
// width: 5,
|
||||
// ),
|
||||
// // Polyline(
|
||||
// // zIndex: 2,
|
||||
// // consumeTapEvents: true,
|
||||
// // geodesic: true,
|
||||
// // endCap: Cap.buttCap,
|
||||
// // startCap: Cap.buttCap,
|
||||
// // visible: true,
|
||||
// // polylineId: PolylineId('g'),
|
||||
// // points: [
|
||||
// // LatLng(controller.southwest.latitude,
|
||||
// // controller.southwest.longitude),
|
||||
// // LatLng(controller.northeast.latitude,
|
||||
// // controller.northeast.longitude)
|
||||
// // ],
|
||||
// // color: AppColor.primaryColor,
|
||||
// // width: 5,
|
||||
// // ),
|
||||
// },
|
||||
// ✅ Polyline مُبسّطة للأجهزة الضعيفة (الكنترولر يجهّز مجموعة مبسطة عند lowPerf)
|
||||
polylines: controller.lowPerf
|
||||
? controller.polyLinesLight
|
||||
.toSet() // <- استخدم مجموعة خفيفة
|
||||
: controller.polyLines.toSet(),
|
||||
|
||||
// ✅ دوائر خفيفة على الأجهزة الضعيفة
|
||||
// circles: {
|
||||
// Circle(
|
||||
// circleId: const CircleId('kk'),
|
||||
// center: controller.mylocation,
|
||||
// radius: 60,
|
||||
// fillColor: AppColor.primaryColor,)
|
||||
// circleId: const CircleId('circle_id'),
|
||||
// center: controller.passengerLocation,
|
||||
// radius: controller.lowPerf ? 80 : 100,
|
||||
// fillColor:
|
||||
// Colors.blue.withOpacity(controller.lowPerf ? 0.2 : 0.3),
|
||||
// strokeColor: Colors.blue,
|
||||
// strokeWidth: controller.lowPerf ? 1 : 2,
|
||||
// ),
|
||||
// },
|
||||
|
||||
circles: <Circle>{
|
||||
Circle(
|
||||
circleId: const CircleId('circle_id'),
|
||||
center: controller.passengerLocation,
|
||||
radius: 100,
|
||||
fillColor: Colors.blue.withOpacity(0.3),
|
||||
strokeColor: Colors.blue,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
},
|
||||
// ✅ الوضع الخفيف: liteMode + تعطيل الطبقات المكلفة + خريطة Normal
|
||||
mapType: controller.lowPerf
|
||||
? MapType.normal
|
||||
: (controller.mapType
|
||||
? MapType.satellite
|
||||
: MapType.terrain),
|
||||
|
||||
mapType:
|
||||
controller.mapType ? MapType.satellite : MapType.terrain,
|
||||
myLocationButtonEnabled: true,
|
||||
// liteModeEnabled: true, tiltGesturesEnabled: false,
|
||||
myLocationButtonEnabled: false,
|
||||
|
||||
// indoorViewEnabled: true,
|
||||
trafficEnabled: controller.mapTrafficON,
|
||||
buildingsEnabled: true,
|
||||
mapToolbarEnabled: true,
|
||||
// ⚠️ liteMode (Android فقط): فعّله على الأجهزة الضعيفة
|
||||
// liteModeEnabled: controller.lowPerf,
|
||||
liteModeEnabled: Platform.isAndroid ? isLowEnd() : false,
|
||||
trafficEnabled: controller.mapTrafficON && !isLowEnd(),
|
||||
buildingsEnabled: !isLowEnd(),
|
||||
// ✅ تقليل الكلفة الرسومية
|
||||
|
||||
mapToolbarEnabled: false,
|
||||
rotateGesturesEnabled: isLowEnd() ? false : true,
|
||||
tiltGesturesEnabled: false, // تعطيل الميلان لتقليل الحمل
|
||||
|
||||
// ✅ Throttle لحركة الكاميرا على الأجهزة الضعيفة
|
||||
onCameraMove: (position) {
|
||||
int waypointsLength =
|
||||
Get.find<WayPointController>().wayPoints.length;
|
||||
int index = controller.wayPointIndex;
|
||||
if (waypointsLength > 0) {
|
||||
controller.placesCoordinate[index] =
|
||||
'${position.target.latitude.toString()},${position.target.longitude}';
|
||||
if (controller.lowPerf) {
|
||||
controller.onCameraMoveThrottled(position);
|
||||
} else {
|
||||
// منطقك الحالي
|
||||
int waypointsLength =
|
||||
Get.find<WayPointController>().wayPoints.length;
|
||||
int index = controller.wayPointIndex;
|
||||
if (waypointsLength > 0) {
|
||||
controller.placesCoordinate[index] =
|
||||
'${position.target.latitude},${position.target.longitude}';
|
||||
}
|
||||
if (controller.startLocationFromMap == true) {
|
||||
controller.newStartPointLocation = position.target;
|
||||
} else if (controller.passengerStartLocationFromMap ==
|
||||
true) {
|
||||
controller.newStartPointLocation = position.target;
|
||||
}
|
||||
controller.newMyLocation = position.target;
|
||||
}
|
||||
if (controller.startLocationFromMap == true) {
|
||||
controller.newStartPointLocation = position.target;
|
||||
} else if (controller.passengerStartLocationFromMap == true) {
|
||||
controller.newStartPointLocation = position.target;
|
||||
}
|
||||
controller.newMyLocation = position.target;
|
||||
},
|
||||
|
||||
myLocationEnabled: true,
|
||||
// liteModeEnabled: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user