This commit is contained in:
Hamza-Ayed
2023-12-31 14:54:28 +03:00
parent ee41f87b69
commit 8475bdc831
7 changed files with 158 additions and 165 deletions

View File

@@ -13,11 +13,6 @@ import '../../constant/style.dart';
import '../../main.dart';
import '../../views/home/profile/promos_passenger_page.dart';
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
import '../../views/widgets/elevated_btn.dart';
import '../functions/crud.dart';
import '../functions/launch.dart';
import '../home/captin/map_driver_controller.dart';
import '../home/map_passenger_controller.dart';
class FirebaseMessagesController extends GetxController {
final fcmToken = FirebaseMessaging.instance;
@@ -203,19 +198,19 @@ class FirebaseMessagesController extends GetxController {
}
// If the app is in the background or terminated, show a system tray message
RemoteNotification? notification = message.notification;
AndroidNotification? android = message.notification?.android;
AndroidNotification? android = notification?.android;
// if (notification != null && android != null) {
if (notification != null && android != null) {
print('onMessageOpenedApp: ${notification.title} ${notification.body}');
// print('onMessageOpenedApp: ${notification.title} ${notification.body}');
if (message.data.isNotEmpty) {
if (message.notification!.title!.contains('Order')) {
var myListString = message.data['DriverList'];
print(myListString);
print('9999999999999myListString999999999999999');
// print(myListString);
// print('9999999999999myListString999999999999999');
var myList = jsonDecode(myListString) as List<dynamic>;
driverToken = myList[14].toString();
update();
print('driverToken==============$driverToken');
// print('driverToken==============$driverToken');
Get.to(() => OrderRequestPage(), arguments: {
'myListString': myListString,
'DriverList': myList,
@@ -223,8 +218,8 @@ class FirebaseMessagesController extends GetxController {
});
} else if (message.notification!.title!.contains('Apply Ride')) {
var passengerList = message.data['passengerList'];
print(passengerList);
print('9999999999999my Apply Ride 999999999999999');
// print(passengerList);
// print('9999999999999my Apply Ride 999999999999999');
var myList = jsonDecode(passengerList) as List<dynamic>;
driverID = myList[2].toString();
@@ -313,18 +308,18 @@ class FirebaseMessagesController extends GetxController {
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print(
'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
// print(
// 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
RemoteNotification? notification = message.notification;
if (message.data.isNotEmpty) {
if (message.notification!.title!.contains('Order')) {
if (notification!.title!.contains('Order')) {
var myListString = message.data['DriverList'];
print(myListString);
print('9999999999999myListString999999999999999');
// print(myListString);
// print('9999999999999myListString999999999999999');
var myList = jsonDecode(myListString) as List<dynamic>;
driverToken = myList[14].toString();
update();
print('driverToken==============$driverToken');
// print('driverToken==============$driverToken');
Get.to(() => OrderRequestPage(), arguments: {
'myListString': myListString,
'DriverList': myList,
@@ -332,8 +327,8 @@ class FirebaseMessagesController extends GetxController {
});
} else if (message.notification!.title!.contains('Apply Ride')) {
var passengerList = message.data['passengerList'];
print(passengerList);
print('9999999999999my Apply Ride 999999999999999');
// print(passengerList);
// print('9999999999999my Apply Ride 999999999999999');
var myList = jsonDecode(passengerList) as List<dynamic>;
driverID = myList[2].toString();

View File

@@ -103,6 +103,18 @@ class MapPassengerController extends GetxController {
late String driverToken;
int carsOrder = 0;
String? mapAPIKEY;
late double totalME = 0;
late double tax = 0;
late double totalPassenger = 0;
late double totalDriver = 0;
late double averageDuration = 0;
late double costDuration = 0;
late double cost = 0;
late double distance = 0;
late double duration = 0;
late Duration durationToAdd;
late DateTime newTime = DateTime.now();
void onChangedPassengerCount(int newValue) {
selectedPassengerCount = newValue;
@@ -116,6 +128,7 @@ class MapPassengerController extends GetxController {
void getCurrentLocationFormString() async {
currentLocationToFormPlaces = true;
currentLocationString = 'Waiting for your location'.tr;
await getLocation();
currentLocationString = myLocation.toString();
newStartPointLocation = myLocation;
@@ -401,7 +414,7 @@ class MapPassengerController extends GetxController {
update();
} else {
Get.defaultDialog(
title: 'No Car or Captain Found in your area.'.tr,
title: 'No Car or Driver Found in your area.'.tr,
titleStyle: AppStyle.title,
middleText: 'Please Try anther time '.tr,
middleTextStyle: AppStyle.title.copyWith(color: AppColor.yellowColor),
@@ -436,7 +449,7 @@ class MapPassengerController extends GetxController {
changeConfirmRide();
} else {
Get.defaultDialog(
title: 'There no Captain Aplly your order sorry for that '.tr,
title: 'There no Driver Aplly your order sorry for that '.tr,
middleText: 'try next time .',
confirm: MyElevatedButton(
title: 'Back',
@@ -503,30 +516,19 @@ class MapPassengerController extends GetxController {
var res =
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
'southwestLat': southwest.latitude.toString(),
'southwestLon': southwest.longitude.toString(),
'northeastLat': northeast.latitude.toString(),
'northeastLon': northeast.longitude.toString(),
'southwestLat': bounds.southwest.latitude.toString(),
'southwestLon': bounds.southwest.longitude.toString(),
'northeastLat': bounds.northeast.latitude.toString(),
'northeastLon': bounds.northeast.longitude.toString(),
});
if (res == 'failure') {
noCarString = true;
dataCarsLocationByPassenger = res;
update();
// Get.snackbar('No Car in your site.Sorry!'.tr, '',
// backgroundColor: AppColor.redColor);
// Get.defaultDialog(
// title: 'No Car in your site.Sorry!'.tr,
// middleText: '',
// confirm: MyElevatedButton(
// title: 'Back',
// onPressed: () {
// Get.back();
// markerReloadingTimer.cancel();
// }));
} else {
noCarString = false;
dataCarsLocationByPassenger = jsonDecode(res);
// print(dataCarsLocationByPassenger);
print(dataCarsLocationByPassenger);
// if (dataCarsLocationByPassenger.length > carsOrder) {
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
.toString();
@@ -569,7 +571,7 @@ class MapPassengerController extends GetxController {
Future runEvery30SecondsUntilConditionMet() async {
// Calculate the duration of the trip in minutes.
double tripDurationInMinutes = duration1 / 30;
double tripDurationInMinutes = duration1 / 20;
int loopCount = tripDurationInMinutes.ceil();
// If the trip duration is less than or equal to 50 minutes, then break the loop.
for (var i = 0; i < loopCount; i++) {
@@ -769,7 +771,7 @@ class MapPassengerController extends GetxController {
ImageConfiguration config = ImageConfiguration(
size: Size(Get.width * .6, Get.height * .6),
);
BitmapDescriptor.fromAssetImage(config, 'assets/images/picker.png')
BitmapDescriptor.fromAssetImage(config, 'assets/images/brand.png')
.then((value) {
tripIcon = value;
update();
@@ -1133,18 +1135,6 @@ class MapPassengerController extends GetxController {
return distance;
}
late double totalME = 0;
late double tax = 0;
late double totalPassenger = 0;
late double totalDriver = 0;
late double averageDuration = 0;
late double costDuration = 0;
late double cost = 0;
late double distance = 0;
late double duration = 0;
late Duration durationToAdd;
late DateTime newTime = DateTime.now();
Future bottomSheet() async {
if (data.isNotEmpty) {
String distanceText = await data[0]['distance']['text'];