This commit is contained in:
Hamza-Ayed
2024-09-11 10:10:18 +03:00
parent 8a9d270672
commit 98ee34490c
13 changed files with 373 additions and 202 deletions

View File

@@ -18,6 +18,7 @@ import '../../views/auth/captin/criminal_documents_page.dart';
import '../../views/home/Captin/home_captain/home_captin.dart';
import '../../views/home/Captin/orderCaptin/order_speed_request.dart';
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
import '../../views/home/Captin/orderCaptin/vip_order_page.dart';
import '../auth/google_sign.dart';
import '../functions/face_detect.dart';
import 'access_token.dart';
@@ -80,28 +81,28 @@ class FirebaseMessagesController extends GetxController {
}
});
FirebaseMessaging.onBackgroundMessage((RemoteMessage message) async {
if (message.notification!.title! == 'Order'.tr) {
if (Platform.isAndroid) {
NotificationController()
.showNotification('Order'.tr, '', 'order', 'order_page_payload');
}
// await FirebaseMessagesController().showOverlayNotification(message);
var myListString = message.data['DriverList'];
// var points = message.data['PolylineJson'];
// if (message.notification!.title! == 'Order'.tr) {
// if (Platform.isAndroid) {
// NotificationController()
// .showNotification('Order'.tr, '', 'order', 'order_page_payload');
// }
// // await FirebaseMessagesController().showOverlayNotification(message);
// var myListString = message.data['DriverList'];
// // var points = message.data['PolylineJson'];
var myList = jsonDecode(myListString) as List<dynamic>;
// var myPoints = jsonDecode(points) as List<dynamic>;
driverToken = myList[14].toString();
// This is for location using and uploading status
Get.put(HomeCaptainController()).changeRideId();
update();
Get.to(() => OrderRequestPage(), arguments: {
'myListString': myListString,
'DriverList': myList,
// 'PolylineJson': myPoints,
'body': message.notification!.body
});
}
// var myList = jsonDecode(myListString) as List<dynamic>;
// // var myPoints = jsonDecode(points) as List<dynamic>;
// driverToken = myList[14].toString();
// // This is for location using and uploading status
// Get.put(HomeCaptainController()).changeRideId();
// update();
// Get.to(() => OrderRequestPage(), arguments: {
// 'myListString': myListString,
// 'DriverList': myList,
// // 'PolylineJson': myPoints,
// 'body': message.notification!.body
// });
// }
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
@@ -138,6 +139,23 @@ class FirebaseMessagesController extends GetxController {
// 'Cancel Trip'.tr, 'Passenger Cancel Trip'.tr, 'cancel', '');
// }
cancelTripDialog();
} else if (message.notification!.title == 'VIP Order') {
var myListString = message.data['DriverList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
if (Platform.isAndroid) {
NotificationController()
.showNotification('VIP Order'.tr, '', 'order', '');
}
MyDialog().getDialog('VIP Order'.tr, 'midTitle', () {
sendNotificationToPassengerToken(
'VIP Order Accepted'.tr,
'The driver accepted your trip'.tr,
driverList[0],
[driverList[1]],
'order');
});
// Get.to(const VipOrderPage());
} else if (message.notification!.title == 'Cancel') {
cancelTripDialog1();
} else if (message.notification!.title! == 'token change') {

View File

@@ -87,28 +87,29 @@ class LocationController extends GetxController {
switch (area) {
case 'Cairo':
endpoint = AppLink.addCarsLocationCairoEndpoint;
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
endpoint = AppLink.addCarsLocationCairoEndpoint;
Log.print('Endpoint: $endpoint');
break;
case 'Giza':
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
endpoint = AppLink.addCarsLocationGizaEndpoint;
Log.print('Endpoint: $endpoint');
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
break;
case 'Alexandria':
endpoint = AppLink.addCarsLocationAlexandriaEndpoint;
Log.print('Endpoint: $endpoint');
box.write(
BoxName.serverChosen, AppLink.seferAlexandriaServer);
endpoint = AppLink.addCarsLocationAlexandriaEndpoint;
Log.print('Endpoint: $endpoint');
break;
case 'Outside':
// Handle cases outside of Cairo, Giza, and Alexandria
print('Location outside Cairo, Giza, or Alexandria');
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
endpoint = AppLink
.addCarsLocationCairoEndpoint; // Fallback to Cairo endpoint
Log.print('Fallback Endpoint: $endpoint');
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
break;
default:
// Handle any other unexpected cases

View File

@@ -566,12 +566,14 @@ class MapDriverController extends GetxController {
// Get.find<HomeCaptainController>().changeToAppliedRide('Finished');
// Get.find<HomeCaptainController>().update();
totalCost = price < 30
? carType != 'Comfort' && carType != 'Mashwari' && carType != 'Lady'
? carType != 'Comfort' && carType != 'Mishwar Vip' && carType != 'Lady'
? '20'
: '30'
: price < double.parse(totalPricePassenger)
? totalPricePassenger
: carType != 'Comfort' && carType != 'Mashwari' && carType != 'Lady'
: carType != 'Comfort' &&
carType != 'Mishwar Vip' &&
carType != 'Lady'
? totalPricePassenger
: price.toStringAsFixed(2);
paymentAmount = totalCost;
@@ -633,7 +635,7 @@ class MapDriverController extends GetxController {
box.read(BoxName.driverID),
rideId,
box.read(BoxName.tokenDriver),
// carType == 'Comfort' || carType == 'Mashwari'
// carType == 'Comfort' || carType == 'Mishwar Vip'
// ? price.toStringAsFixed(2)
// : totalPassenger
paymentAmount.toString()
@@ -681,44 +683,178 @@ class MapDriverController extends GetxController {
int rideTimerFromBegin = 0;
double price = 0;
DateTime currentTime = DateTime.now();
void rideIsBeginPassengerTimer() async {
int durationOfRide = int.parse(durationOfRideValue);
update();
int infinity = 40000;
if (carType == 'Comfort' ||
carType == 'Mashwari' ||
carType == 'Rayeh Gai') {
carType == 'Mishwar Vip' ||
carType == 'RayehGaiComfort') {
durationOfRide = infinity;
update();
}
if (carType != 'Comfort' ||
carType != 'Mishwar Vip' ||
carType != 'Lady' ||
carType != 'RayehGaiComfort') {
price = double.parse(totalCost);
update();
}
for (int i = 0; i <= durationOfRide; i++) {
await Future.delayed(const Duration(seconds: 1));
recentDistanceToDash = Get.find<LocationController>().totalDistance;
rideTimerFromBegin = i;
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Speed'
? (i ~/ 60) +
if (startNameLocation.toLowerCase().contains('airport') ||
endNameLocation.toLowerCase().contains('airport') ||
startNameLocation.contains('مطار') ||
startNameLocation.contains('المطار') ||
endNameLocation.contains('مطار') ||
endNameLocation.contains('المطار')) {
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
// : carType == 'Speed'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().speedPrice)
: carType == 'Lady'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
// : carType == 'Delivery'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().deliveryPrice)
: carType == 'RayehGaiComfort'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().mashwariPrice);
} else if (currentTime.hour >= 21 && currentTime.hour < 0) {
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
// : carType == 'Speed'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().speedPrice)
: carType == 'Lady'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
// : carType == 'Delivery'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().deliveryPrice)
: carType == 'RayehGaiComfort'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
20 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().mashwariPrice);
} else if (currentTime.hour >= 1 && currentTime.hour < 5) {
if (startNameLocation.contains('club') ||
startNameLocation.contains('nightclub') ||
startNameLocation.contains('ديسكو') ||
startNameLocation.contains('ملهى ليلي') ||
startNameLocation.contains('Night club')) {
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) *
2 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().speedPrice)
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Lady'
? (i ~/ 60) +
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) *
2 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Delivery'
? (i ~/ 60) +
: carType == 'RayehGaiComfort'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice +
.5) *
2 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().deliveryPrice)
: carType == 'Rayeh Gai'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().speedPrice)
: (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>()
.mashwariPrice); // $1 for each minute + $4 for each km
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice +
.5) *
2 +
(recentDistanceToDash *
Get.find<HomeCaptainController>().mashwariPrice);
}
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) * (Get.find<HomeCaptainController>().latePrice + .5) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Lady'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'RayehGaiComfort'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().mashwariPrice);
} else if (currentTime.hour >= 14 && currentTime.hour <= 17) {
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) * (Get.find<HomeCaptainController>().heavyPrice) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Lady'
? (i ~/ 60) * (Get.find<HomeCaptainController>().heavyPrice) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'RayehGaiComfort'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().heavyPrice) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) *
(Get.find<HomeCaptainController>().heavyPrice) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().mashwariPrice);
} else {
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Lady'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'RayehGaiComfort'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().mashwariPrice);
}
// $1 for each minute + $4 for each km
price = (price * double.parse(kazan)) + price; // Add 10% tax
speed = Get.find<LocationController>().speed * 3.6;
progressTimerRideBegin = i / durationOfRide;

View File

@@ -113,14 +113,16 @@ class MyTranslation extends Translations {
"National Bank of Greece": "البنك الوطني اليوناني",
"Central Bank Of Egypt": "البنك المركزي المصري",
"ATTIJARIWAFA BANK Egypt": "البنك التجاري وفا مصر",
"Morning Promo": "عرض الصباح",
"Morning Promo": "بونص الصباح",
"VIP Order": "طلب VIP", "VIP Order Accepted": "تم قبول طلب VIP.",
"The driver accepted your trip": "السائق قبل رحلتك.",
"this is count of your all trips in the morning promo today from 7:00am-10:00am":
"هذا عدد جميع رحلاتك في عرض الصباح اليوم من الساعة 7:00 صباحًا حتى 10:00 صباحًا",
"هذا عدد جميع رحلاتك في بونص الصباح اليوم من الساعة 7:00 صباحًا حتى 10:00 صباحًا",
"Morning Promo Rides": "رحلات عرض الصباح",
"Afternoon Promo": "عرض بعد الظهر",
"Afternoon Promo": "بونص الظهر",
"this is count of your all trips in the Afternoon promo today from 3:00pm-6:00 pm":
"هذا عدد جميع رحلاتك في عرض بعد الظهر اليوم من الساعة 3:00 مساءً حتى 6:00 مساءً",
"Afternoon Promo Rides": "رحلات عرض بعد الظهر",
"هذا عدد جميع رحلاتك في بونص بعد الظهر اليوم من الساعة 3:00 مساءً حتى 6:00 مساءً",
"Afternoon Promo Rides": "رحلات بونص بعد الظهر",
"Heading your way now. Please be ready.":
"في طريقي إليك الآن. يرجى الاستعداد.",
"Approaching your area. Should be there in 3 minutes.":