7/5/1
This commit is contained in:
@@ -45,7 +45,9 @@ class MapPassengerController extends GetxController {
|
||||
TextEditingController wayPoint4Controller = TextEditingController();
|
||||
TextEditingController sosPhonePassengerProfile = TextEditingController();
|
||||
TextEditingController whatsAppLocationText = TextEditingController();
|
||||
TextEditingController messageToDriver = TextEditingController();
|
||||
final sosFormKey = GlobalKey<FormState>();
|
||||
final messagesFormKey = GlobalKey<FormState>();
|
||||
final increaseFeeFormKey = GlobalKey<FormState>();
|
||||
List data = [];
|
||||
List<LatLng> bounds = [];
|
||||
@@ -96,6 +98,8 @@ class MapPassengerController extends GetxController {
|
||||
BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor motoIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor ladyIcon = BitmapDescriptor.defaultMarker;
|
||||
double height = 150;
|
||||
DateTime currentTime = DateTime.now();
|
||||
final location = Location();
|
||||
@@ -1235,6 +1239,7 @@ class MapPassengerController extends GetxController {
|
||||
void timerEnded() async {
|
||||
runEvery30SecondsUntilConditionMet();
|
||||
isCancelRidePageShown = false;
|
||||
print('isCancelRidePageShown: ${isCancelRidePageShown}');
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1266,7 +1271,7 @@ class MapPassengerController extends GetxController {
|
||||
driversToken.remove(driverToken);
|
||||
for (var i = 1; i < driversToken.length; i++) {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'Order Applied',
|
||||
'Order Applied'.tr,
|
||||
'$driverName Apply order\nTake attention in other order'.tr,
|
||||
driversToken[i],
|
||||
'start.wav',
|
||||
@@ -1345,9 +1350,9 @@ class MapPassengerController extends GetxController {
|
||||
i < dataCarsLocationByPassenger['message'].length;
|
||||
i++) {
|
||||
var json = dataCarsLocationByPassenger['message'][i];
|
||||
CarLocationModel model = CarLocationModel.fromJson(json);
|
||||
// CarLocationModel model = CarLocationModel.fromJson(json);
|
||||
if (carLocationsModels.length < i + 1) {
|
||||
carLocationsModels.add(model);
|
||||
// carLocationsModels.add(model);
|
||||
markers.add(
|
||||
Marker(
|
||||
markerId: MarkerId(json['latitude']),
|
||||
@@ -1356,13 +1361,17 @@ class MapPassengerController extends GetxController {
|
||||
double.parse(json['longitude']),
|
||||
),
|
||||
rotation: double.parse(json['heading']),
|
||||
icon: carIcon,
|
||||
icon: json['model'].toString().contains('دراجة')
|
||||
? motoIcon
|
||||
: json['gender'] == 'Male'
|
||||
? carIcon
|
||||
: ladyIcon,
|
||||
),
|
||||
);
|
||||
driversToken.add(json['token']);
|
||||
// driversToken = json['token'];
|
||||
} else {
|
||||
carLocationsModels[i] = model;
|
||||
// carLocationsModels[i] = model;
|
||||
markers[i] = Marker(
|
||||
markerId: MarkerId(json['latitude']),
|
||||
position: LatLng(
|
||||
@@ -1370,7 +1379,11 @@ class MapPassengerController extends GetxController {
|
||||
double.parse(json['longitude']),
|
||||
),
|
||||
rotation: double.parse(json['heading']),
|
||||
icon: carIcon,
|
||||
icon: json['model'].contains('دراجة')
|
||||
? motoIcon
|
||||
: json['gender'] == 'Male'
|
||||
? carIcon
|
||||
: ladyIcon,
|
||||
);
|
||||
// driversToken = json['token'];
|
||||
driversToken.add(json['token']);
|
||||
@@ -1517,7 +1530,7 @@ class MapPassengerController extends GetxController {
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(seconds: 4));
|
||||
if (rideTimerBegin == true) {
|
||||
if (rideTimerBegin == true || statusRide == 'Apply') {
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
@@ -1566,8 +1579,16 @@ class MapPassengerController extends GetxController {
|
||||
rotation: double.parse(
|
||||
datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['heading']),
|
||||
icon: carIcon,
|
||||
icon: datadriverCarsLocationToPassengerAfterApplied['message'][0]['model']
|
||||
.contains('دراجة')
|
||||
? motoIcon
|
||||
: datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['gender'] ==
|
||||
'Male'
|
||||
? carIcon
|
||||
: ladyIcon, // Default to carIcon if gender is not Male or Female
|
||||
);
|
||||
|
||||
markers.add(driverAcceptedMarker);
|
||||
// update();
|
||||
mapController?.animateCamera(CameraUpdate.newLatLng(driverPosition));
|
||||
@@ -1620,8 +1641,9 @@ class MapPassengerController extends GetxController {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
print('Cancel');
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Cancel Trip'.tr,
|
||||
'Cancel Trip',
|
||||
'Trip Cancelled'.tr,
|
||||
driverToken,
|
||||
[],
|
||||
@@ -1922,6 +1944,28 @@ class MapPassengerController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomMotoIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/moto1.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
motoIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomLadyIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/lady1.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
ladyIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomStepIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||
@@ -2253,7 +2297,7 @@ class MapPassengerController extends GetxController {
|
||||
isLoading = false;
|
||||
update();
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
('${AppLink.googleMapsLink}directions/json?&language=ar&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
@@ -2342,14 +2386,17 @@ class MapPassengerController extends GetxController {
|
||||
// Initialize the short address
|
||||
String shortAddress = '';
|
||||
|
||||
// Add the first part (usually the most specific location)
|
||||
if (parts.isNotEmpty) {
|
||||
// Add the first part (usually the most specific location)
|
||||
shortAddress += parts[0];
|
||||
}
|
||||
|
||||
// Add the district or area name (usually the third part in this format)
|
||||
if (parts.length > 2) {
|
||||
// Add the district or area name (usually the third part in Arabic format)
|
||||
shortAddress += '، ${parts[2]}';
|
||||
} else if (parts.length > 1) {
|
||||
// Add the second part for English or shorter addresses
|
||||
shortAddress += '، ${parts[1]}';
|
||||
}
|
||||
|
||||
// Add the country (usually the last part)
|
||||
@@ -2363,6 +2410,21 @@ class MapPassengerController extends GetxController {
|
||||
.where((part) => !RegExp(r'^[0-9 ]+$').hasMatch(part.trim()))
|
||||
.join('،');
|
||||
|
||||
// Check if the address is in English
|
||||
bool isEnglish =
|
||||
RegExp(r'^[a-zA-Z0-9 ]+$').hasMatch(shortAddress.replaceAll('،', ''));
|
||||
|
||||
if (isEnglish) {
|
||||
// Further processing for English addresses
|
||||
List<String> englishParts = shortAddress.split('،');
|
||||
if (englishParts.length > 2) {
|
||||
shortAddress =
|
||||
'${englishParts[0]}، ${englishParts[1]}، ${englishParts.last}';
|
||||
} else if (englishParts.length > 1) {
|
||||
shortAddress = '${englishParts[0]}، ${englishParts.last}';
|
||||
}
|
||||
}
|
||||
|
||||
return shortAddress;
|
||||
}
|
||||
|
||||
@@ -2809,6 +2871,8 @@ class MapPassengerController extends GetxController {
|
||||
readyWayPoints();
|
||||
addCustomPicker();
|
||||
addCustomCarIcon();
|
||||
addCustomLadyIcon();
|
||||
addCustomMotoIcon();
|
||||
addCustomStepIcon();
|
||||
addCustomStartIcon();
|
||||
addCustomEndIcon();
|
||||
|
||||
@@ -17,6 +17,8 @@ class TripMonitorController extends GetxController {
|
||||
late Timer timer;
|
||||
late LatLng parentLocation;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor motoIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor ladyIcon = BitmapDescriptor.defaultMarker;
|
||||
double rotation = 0;
|
||||
double speed = 0;
|
||||
|
||||
@@ -65,6 +67,27 @@ class TripMonitorController extends GetxController {
|
||||
carIcon = value;
|
||||
update();
|
||||
});
|
||||
void addCustomMotoIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/moto1.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
motoIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomLadyIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/lady1.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
ladyIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user