Files
tripz/lib/views/home/map_widget.dart/google_map_passenger_widget.dart
Hamza-Ayed 13a7c3db81 25-1/31/1
2025-01-31 14:57:17 +03:00

454 lines
21 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:Tripz/controller/home/points_for_rider_controller.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.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());
@override
Widget build(BuildContext context) {
return GetBuilder<MapPassengerController>(
builder: (controller) => controller.isLoading
? const MyCircularProgressIndicator()
: Positioned(
bottom: Get.height * .2,
top: 0,
left: 0,
right: 0,
child: GoogleMap(
onMapCreated: controller.onMapCreated,
cameraTargetBounds: CameraTargetBounds(controller.boundsdata),
minMaxZoomPreference: 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()}');
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,
);
}
//
});
// 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,
),
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,
// // ),
// },
// circles: {
// Circle(
// circleId: const CircleId('kk'),
// center: controller.mylocation,
// radius: 60,
// fillColor: AppColor.primaryColor,)
// },
circles: <Circle>{
Circle(
circleId: const CircleId('circle_id'),
center: controller.passengerLocation,
radius: 100,
fillColor: Colors.blue.withOpacity(0.3),
strokeColor: Colors.blue,
strokeWidth: 2,
),
},
mapType:
controller.mapType ? MapType.satellite : MapType.terrain,
myLocationButtonEnabled: true,
// liteModeEnabled: true, tiltGesturesEnabled: false,
// indoorViewEnabled: true,
trafficEnabled: controller.mapTrafficON,
buildingsEnabled: true,
mapToolbarEnabled: true,
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.startLocationFromMap == true) {
controller.newStartPointLocation = position.target;
} else if (controller.passengerStartLocationFromMap == true) {
controller.newStartPointLocation = position.target;
}
controller.newMyLocation = position.target;
},
myLocationEnabled: true,
// liteModeEnabled: true,
),
),
);
}
}