This commit is contained in:
Hamza-Ayed
2024-06-22 13:30:02 +03:00
parent 976e5dfa4d
commit 2bd242b28c
6 changed files with 21 additions and 175 deletions

View File

@@ -37,11 +37,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>34</string>
<string>35</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.5.34</string>
<string>1.5.35</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<string>NO</string>
<key>GMSApiKey</key>

View File

@@ -30,7 +30,6 @@ class LoginController extends GetxController {
void changeAgreeTerm() {
isAgreeTerms = !isAgreeTerms;
print(isAgreeTerms);
update();
}
@@ -52,7 +51,6 @@ class LoginController extends GetxController {
'email': email,
'id': passengerID,
});
print(res);
if (res == 'Failure') {
//Failure
Get.offAll(SmsSignupEgypt());
@@ -61,7 +59,6 @@ class LoginController extends GetxController {
Get.snackbar("User does not exist.".tr, '', backgroundColor: Colors.red);
} else {
var jsonDecoeded = jsonDecode(res);
// print(jsonDecoeded['data'][0]['is_verified']);
if (jsonDecoeded.isNotEmpty) {
if (jsonDecoeded['status'] == 'success' &&
jsonDecoeded['data'][0]['verified'] == 1) {
@@ -70,16 +67,12 @@ class LoginController extends GetxController {
box.write(BoxName.email, jsonDecoeded['data'][0]['email']);
box.write(BoxName.phone, jsonDecoeded['data'][0]['phone']);
print(box.read(BoxName.tokenFCM));
var token = await CRUD().get(link: AppLink.getTokens, payload: {
'passengerID': box.read(BoxName.passengerID).toString()
});
print(token);
print(box.read(BoxName.tokenFCM));
if (token != 'failure') {
if (jsonDecode(token)['data'][0]['token'] !=
box.read(BoxName.tokenFCM)) {
print('token changed');
Get.put(FirebaseMessagesController())
.sendNotificationToAnyWithoutData(
'token change',
@@ -90,7 +83,7 @@ class LoginController extends GetxController {
await CRUD().post(link: AppLink.addTokens, payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()
}).then((value) => print('cccc'));
});
}
}
@@ -103,7 +96,6 @@ class LoginController extends GetxController {
update();
}
} else {
print('res is null');
isloading = false;
update();
}
@@ -114,12 +106,10 @@ class LoginController extends GetxController {
// if (formKeyAdmin.currentState!.validate()) {
// await DeviceInfoPlus.getDeviceInfo();
// if (Platform.isAndroid) {
// // print(DeviceInfoPlus.deviceDataList['serialNumber']);
// // var res = await CRUD().get(link: AppLink.getAdminUser, payload: {
// // // 'device_number': DeviceInfoPlus.deviceData['serialNumber'].toString(),
// // });
// // var d = jsonDecode(res);
// // // print(d);
// // // if (DeviceInfoPlus.deviceData['serialNumber'] ==
// // d['message']['device_number']) {
// Get.back();
@@ -127,12 +117,10 @@ class LoginController extends GetxController {
// // }
// }
// if (Platform.isIOS) {
// // print(DeviceInfoPlus.deviceData['identifierForVendor']);
// // var res = await CRUD().get(link: AppLink.getAdminUser, payload: {
// // 'device_number': DeviceInfoPlus.deviceData['identifierForVendor'].toString(),
// // });
// // var d = jsonDecode(res);
// // print(d);
// // if (DeviceInfoPlus.deviceData['serialNumber'] ==
// // d['message']['device_number']) {
// Get.back();
@@ -155,12 +143,9 @@ class LoginController extends GetxController {
if (res == 'Failure') {
Get.snackbar('Failure', '', backgroundColor: Colors.red);
} else {
// print(res);
var jsonDecoeded = jsonDecode(res);
// print(jsonDecoeded);
if (jsonDecoeded.isNotEmpty) {
if (jsonDecoeded['status'] == 'success') {
print(jsonDecoeded['data'][0]['verified']);
if (jsonDecoeded['data'][0]['verified'] == 1) {
box.write(BoxName.passengerID, jsonDecoeded['data'][0]['id']);
box.write(BoxName.email, jsonDecoeded['data'][0]['email']);
@@ -174,12 +159,11 @@ class LoginController extends GetxController {
Get.offAll(() => const MapPagePassenger());
isloading = false;
update();
print(box.read(BoxName.passengerID).toString());
print(box.read(BoxName.tokenFCM));
await CRUD().post(link: AppLink.addTokens, payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()
}).then((value) => print('cccc'));
});
} else {
isloading = false;
update();
@@ -192,7 +176,7 @@ class LoginController extends GetxController {
await CRUD().post(link: AppLink.sendVerifyEmail, payload: {
'email': emailController.text,
'token': randomNumber.toString(),
}).then((value) => print(value));
});
Get.to(() => const VerifyEmailPage());
},
);
@@ -204,7 +188,6 @@ class LoginController extends GetxController {
update();
}
} else {
print('res is null');
isloading = false;
update();
}
@@ -244,7 +227,6 @@ class LoginController extends GetxController {
return;
}
}
print('permisson is ${permissionGranted.toString()}');
if (permissionGranted.toString() == 'PermissionStatus.granted') {
box.write(BoxName.locationPermission, 'true');
}
@@ -254,7 +236,6 @@ class LoginController extends GetxController {
@override
void onInit() async {
// permissionLocation = await Permission.locationWhenInUse.isGranted;
// print('permisson is ${permissionGranted}');
super.onInit();
}

View File

@@ -121,7 +121,6 @@ class RegisterController extends GetxController {
Get.offAll(const MapPagePassenger());
}
} else {
print(res);
Get.snackbar('Error'.tr, '', backgroundColor: Colors.redAccent);
}
}
@@ -150,14 +149,12 @@ class RegisterController extends GetxController {
'site': siteController.text,
'birthdate': birthDate,
});
print(jsonDecode(res));
if (jsonDecode(res)['status'] == 'success') {
print('sdfffffffffff');
int randomNumber = Random().nextInt(100000) + 1;
await CRUD().post(link: AppLink.sendVerifyEmail, payload: {
'email': emailController.text,
'token': randomNumber.toString(),
}).then((value) => print(value));
});
Get.to(() => const VerifyEmailPage());
}
}

View File

@@ -37,8 +37,7 @@ class FirebaseMessagesController extends GetxController {
// Get the current notification settings
NotificationSettings? notificationSettings =
await FirebaseMessaging.instance.getNotificationSettings();
print(
'Notification authorization status: ${notificationSettings.authorizationStatus}');
'Notification authorization status: ${notificationSettings.authorizationStatus}';
// Call the update function if needed
update();
@@ -62,7 +61,6 @@ class FirebaseMessagesController extends GetxController {
provisional: false,
sound: true,
);
print('User granted permission: ${settings.authorizationStatus}');
messaging.setForegroundNotificationPresentationOptions(
alert: true, badge: true, sound: true);
}
@@ -79,16 +77,13 @@ class FirebaseMessagesController extends GetxController {
},
body: {},
);
// print(res.body);
var jsonResponse = jsonDecode(res.body);
// print(jsonResponse);
if (jsonResponse['status'] == 'success') {
dataTokens = jsonResponse['data'];
for (var i = 0; i < dataTokens.length; i++) {
tokens.add(jsonResponse['data'][i]['token']);
}
box.write(BoxName.tokens, tokens);
print(box.read(BoxName.tokens));
} else {
Get.defaultDialog(title: "Warning", middleText: "Server Error");
}
@@ -111,14 +106,12 @@ class FirebaseMessagesController extends GetxController {
FirebaseMessaging.onBackgroundMessage((RemoteMessage message) async {
// Handle background message
if (message.data.isNotEmpty && message.notification != null) {
print(message.notification?.title);
fireBaseTitles(message);
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
if (message.data.isNotEmpty && message.notification != null) {
print(message.notification?.title);
fireBaseTitles(message);
}
});
@@ -230,9 +223,7 @@ class FirebaseMessagesController extends GetxController {
token: driverList[0].toString(),
remoteID: driverList[2].toString(),
));
} catch (e) {
print('Error navigating to PassengerCallPage: $e');
}
} catch (e) {}
} else if (message.notification!.title! == 'Call Income from Driver') {
try {
var myListString = message.data['passengerList'];
@@ -250,9 +241,7 @@ class FirebaseMessagesController extends GetxController {
token: driverList[0].toString(),
remoteID: driverList[2].toString(),
));
} catch (e) {
print('Error navigating to PassengerCallPage: $e');
}
} catch (e) {}
} else if (message.notification!.title! == 'Call End') {
try {
var myListString = message.data['passengerList'];
@@ -266,9 +255,7 @@ class FirebaseMessagesController extends GetxController {
}
// Assuming GetMaterialApp is initialized and context is valid for navigation
// Get.off(const CallPage());
} catch (e) {
print('Error navigating to PassengerCallPage: $e');
}
} catch (e) {}
} else if (message.notification!.title! == 'Driver Cancel Your Trip') {
// Get.snackbar(
// 'You will be pay the cost to driver or we will get it from you on next trip'
@@ -412,7 +399,6 @@ class FirebaseMessagesController extends GetxController {
// Save the list of tokens back to the box.
// box.write(BoxName.tokens, tokens);
tokens = box.read(BoxName.tokens);
// print(tokens);
for (var i = 0; i < tokens.length; i++) {
http
.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -435,9 +421,7 @@ class FirebaseMessagesController extends GetxController {
'to': tokens[i],
}))
.whenComplete(() {})
.catchError((e) {
print('sendNotification() error: $e');
});
.catchError((e) {});
}
}
@@ -464,7 +448,6 @@ class FirebaseMessagesController extends GetxController {
// }))
// .whenComplete(() {})
// .catchError((e) {
// print('sendNotification() error: $e');
// });
// }
// }
@@ -494,15 +477,12 @@ class FirebaseMessagesController extends GetxController {
if (response.statusCode == 200) {
// Notification sent successfully
print('Notification sent successfully');
} else {
// Handle error response
print(
'Failed to send notification. Status code: ${response.statusCode}');
'Failed to send notification. Status code: ${response.statusCode}';
}
} catch (e) {
// Handle other exceptions
print('sendNotification() error: $e');
}
}
@@ -533,15 +513,12 @@ class FirebaseMessagesController extends GetxController {
if (response.statusCode == 200) {
// Notification sent successfully
print('Notification sent successfully');
} else {
// Handle error response
print(
'Failed to send notification. Status code: ${response.statusCode}');
'Failed to send notification. Status code: ${response.statusCode}';
}
} catch (e) {
// Handle other exceptions
print('sendNotification() error: $e');
}
}
@@ -571,15 +548,12 @@ class FirebaseMessagesController extends GetxController {
if (response.statusCode == 200) {
// Notification sent successfully
print('Notification sent successfully');
} else {
// Handle error response
print(
'Failed to send notification. Status code: ${response.statusCode}');
'Failed to send notification. Status code: ${response.statusCode}';
}
} catch (e) {
// Handle other exceptions
print('sendNotification() error: $e');
}
}
@@ -610,15 +584,12 @@ class FirebaseMessagesController extends GetxController {
if (response.statusCode == 200) {
// Notification sent successfully
print('Notification sent successfully');
} else {
// Handle error response
print(
'Failed to send notification. Status code: ${response.statusCode}');
'Failed to send notification. Status code: ${response.statusCode}';
}
} catch (e) {
// Handle other exceptions
print('sendNotification() error: $e');
}
}
}

View File

@@ -254,7 +254,6 @@ class MapPassengerController extends GetxController {
List<String> coordinatesWithoutEmpty = [];
void getMapPointsForAllMethods() async {
print(placesCoordinate.toString());
clearPolyline();
isMarkersShown = false;
isWayPointStopsSheetUtilGetMap = false;
@@ -271,7 +270,6 @@ class MapPassengerController extends GetxController {
latestPosition = LatLng(
double.parse(coordinatesWithoutEmpty.last.split(',')[0]),
double.parse(coordinatesWithoutEmpty.last.split(',')[1]));
// print(coordinatesWithoutEmpty);
for (var i = 0; i < coordinatesWithoutEmpty.length; i++) {
if ((i + 1) < coordinatesWithoutEmpty.length) {
await getMapPoints(
@@ -693,9 +691,7 @@ class MapPassengerController extends GetxController {
try {
var res = await CRUD()
.get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId});
if (res == 'failure') {
// print(res);
}
if (res == 'failure') {}
var decode = jsonDecode(res);
if (decode['data']['status'] == 'Begin') {
@@ -711,10 +707,8 @@ class MapPassengerController extends GetxController {
// isCancelRidePageShown = true;
rideIsBeginPassengerTimer();
runWhenRideIsBegin();
// //print('rideTimerBegin: $rideTimerBegin');
}
} catch (e) {
//print('Error: $e');
// Handle the error or perform any necessary actions
}
}
@@ -725,11 +719,8 @@ class MapPassengerController extends GetxController {
var res = await CRUD().get(
link: AppLink.getRideStatusFromStartApp,
payload: {'passenger_id': box.read(BoxName.passengerID)});
if (res == 'failure') {
//print(res);
}
if (res == 'failure') {}
rideStatusFromStartApp = jsonDecode(res);
print(rideStatusFromStartApp['data']['status']);
if (rideStatusFromStartApp['data']['status'] == 'Begin') {
statusRide = 'Begin';
driverId = rideStatusFromStartApp['data']['driver_id'];
@@ -751,7 +742,6 @@ class MapPassengerController extends GetxController {
Map<String, dynamic> tripData =
box.read(BoxName.tripData) as Map<String, dynamic>;
print(tripData);
final points = decodePolyline(
tripData["routes"][0]["overview_polyline"]["points"]);
@@ -783,7 +773,6 @@ class MapPassengerController extends GetxController {
update();
}
} catch (e) {
//print('Error: $e');
// Handle the error or perform any necessary actions
}
}
@@ -893,8 +882,6 @@ class MapPassengerController extends GetxController {
late String make = '';
late String licensePlate = '';
confirmRideForFirstDriver() async {
print('confirmRideForFirstDriver');
print('statusRide $statusRide');
await getCarsLocationByPassengerAndReloadMarker();
await getNearestDriverByPassengerLocationAPIGOOGLE();
@@ -928,7 +915,6 @@ class MapPassengerController extends GetxController {
isDriversTokensSend = false;
update();
// //print('rideConfirm= $rideConfirm');
await CRUD().post(link: AppLink.addRides, payload: {
"start_location": //'${data[0]['start_address']}',
@@ -949,7 +935,6 @@ class MapPassengerController extends GetxController {
"price_for_passenger": totalME.toString(),
"distance": distance.toString()
}).then((value) {
// //print(jsonDecode(value)['message']);
// List<String> body = [
rideId = jsonDecode(value)['message'];
List<String> body = [
@@ -995,7 +980,6 @@ class MapPassengerController extends GetxController {
kazan.toStringAsFixed(0),
passengerRate.toStringAsFixed(2),
]; //
print(body);
FirebaseMessagesController().sendNotificationToDriverMAP(
'Order',
jsonDecode(value)['message'].toString(),
@@ -1003,8 +987,6 @@ class MapPassengerController extends GetxController {
body,
// polylineCoordinates.toString()
);
print(dataCarsLocationByPassenger);
// //print(dataCarsLocationByPassenger['message'][0]['token'].toString());
});
delayAndFetchRideStatus(rideId);
if (shouldFetch == false) {
@@ -1079,8 +1061,6 @@ class MapPassengerController extends GetxController {
kazan.toStringAsFixed(0),
passengerRate.toStringAsFixed(2),
];
print('driversToken');
print(driversToken);
for (var i = 1; i < driversToken.length; i++) {
FirebaseMessagesController().sendNotificationToDriverMapPolyline(
'OrderSpeed',
@@ -1098,15 +1078,10 @@ class MapPassengerController extends GetxController {
void delayAndFetchRideStatus(String rideId) {
Timer(const Duration(milliseconds: 200), () async {
if (shouldFetch) {
// //print('shouldFetch is =$shouldFetch');
if (remainingTimeToPassengerFromDriverAfterApplied > 0) {
var res = await getRideStatus(rideId);
// print(res);
// var decod = jsonDecode(res);
print(
' 000000000000000000delayAndFetchRideStatus0000000000000000000000000000000');
print(res);
if (res.toString() == 'Apply') {
// getUpdatedRideForDriverApply(rideId);
shouldFetch = false; // Stop further fetches
@@ -1136,12 +1111,8 @@ class MapPassengerController extends GetxController {
void delayAndFetchRideStatusForAllDriverAvailable(String rideId) {
Timer(const Duration(milliseconds: 200), () async {
if (shouldFetch) {
// //print('shouldFetch is =$shouldFetch');
var res = await getRideStatus(rideId);
print(res);
// var decod = jsonDecode(res);
print('--------delayAndFetchRideStatusForAllDriverAvailable----');
// print(decod['data']);
if (res.toString() == 'Apply') {
getUpdatedRideForDriverApply(rideId);
@@ -1166,11 +1137,8 @@ class MapPassengerController extends GetxController {
if (remainingTime == 0) {
rideConfirm = false;
// //print(timeToPassengerFromDriverAfterApplied);
timeToPassengerFromDriverAfterApplied += durationToPassenger;
// //print(duration1);
// //print('timeToPassengerFromDriverAfterApplied====' +
// timeToPassengerFromDriverAfterApplied.toString());
startTimerFromDriverToPassengerAfterApplied();
update();
@@ -1181,8 +1149,6 @@ class MapPassengerController extends GetxController {
}
void timerEnded() async {
//print('Timer ended');
runEvery30SecondsUntilConditionMet();
isCancelRidePageShown = false;
update();
@@ -1202,16 +1168,6 @@ class MapPassengerController extends GetxController {
await CRUD().get(link: AppLink.getRideOrderID, payload: {'id': rideId});
if (res != 'failure') {
var response = jsonDecode(res);
print('driverId: ${response['data']['driver_id']}');
print('driverPhone: ${response['data']['phone']}');
print('driverCarMake: ${response['data']['make']}');
print('model: ${response['data']['model']}');
print('make: ${response['data']['make']}');
print('licensePlate: ${response['data']['car_plate']}');
print('firstName: ${response['data']['first_name']}');
print('driverToken: ${response['data']['token']}');
print('carYear: ${response['data']['year']}');
print('driverRate: ${response['data']['ratingDriver']}');
driverId = response['data']['driver_id'];
driverPhone = response['data']['phone'];
driverCarMake = response['data']['make'];
@@ -1267,7 +1223,6 @@ class MapPassengerController extends GetxController {
// Get.snackbar('no car', 'message');
noCarString = false;
dataCarsLocationByPassenger = jsonDecode(res);
//print(dataCarsLocationByPassenger);
// if (dataCarsLocationByPassenger.length > carsOrder) {
driverId = dataCarsLocationByPassenger['message'][carsOrder]
['driver_id']
@@ -1276,8 +1231,6 @@ class MapPassengerController extends GetxController {
.toString();
// }
// //print('driverId==============$driverId');
carsLocationByPassenger.clear(); // Clear existing markers
// late LatLng lastDriverLocation; // Initialize a variable for last location
@@ -1286,7 +1239,6 @@ class MapPassengerController extends GetxController {
i < dataCarsLocationByPassenger['message'].length;
i++) {
var json = dataCarsLocationByPassenger['message'][i];
print(json);
CarLocationModel model = CarLocationModel.fromJson(json);
if (carLocationsModels.length < i + 1) {
carLocationsModels.add(model);
@@ -1371,7 +1323,6 @@ class MapPassengerController extends GetxController {
void handleResponse(Map<String, dynamic> res1) {
if (res1['message'] == "No passenger found for the given phone number") {
print(res1);
Get.defaultDialog(
title: "No user found for the given phone number".tr,
titleStyle: AppStyle.title,
@@ -1472,7 +1423,6 @@ class MapPassengerController extends GetxController {
// If the trip duration is less than or equal to 50 minutes, then break the loop.
for (var i = 0; i < loopCount; i++) {
// Wait for 50 seconds.
print('loop is $i from $loopCount');
await Future.delayed(const Duration(seconds: 4));
if (rideTimerBegin == true) {
await getDriverCarsLocationToPassengerAfterApplied();
@@ -1502,7 +1452,6 @@ class MapPassengerController extends GetxController {
['latitude']),
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
['longitude']));
print('driver position $driverPosition');
final driverAcceptedMarker = Marker(
markerId: const MarkerId('driverToPassengers'),
position: driverPosition,
@@ -1552,13 +1501,10 @@ class MapPassengerController extends GetxController {
}
Future cancelRide() async {
//print("rideConfirm=$rideConfirm");
if (rideConfirm == false && statusRide == 'Apply') {
clearPlacesDestination();
clearPolyline();
// clearPolylineAll();
print('rideConfirm before is $rideConfirm');
data = [];
changeCancelRidePageShow();
if (rideId != 'yet') {
@@ -1593,7 +1539,6 @@ class MapPassengerController extends GetxController {
} else {
clearPlacesDestination();
clearPolyline();
print('rideConfirm is $rideConfirm');
data = [];
await CRUD().post(link: AppLink.updateDriverOrder, payload: {
"order_id": rideId.toString(), // Convert to String
@@ -1682,7 +1627,6 @@ class MapPassengerController extends GetxController {
void changeWayPointStopsSheet() {
// int waypointsLength = Get.find<WayPointController>().wayPoints.length;
//print('isWayPointStopsSheet $wayPointIndex');
if (wayPointIndex > -1) {
isWayPointStopsSheet = true;
isWayPointStopsSheetUtilGetMap = true;
@@ -1772,7 +1716,6 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {});
placesDestination = response['results'];
//print(placesDestination);
update();
}
@@ -1784,7 +1727,6 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {});
placesStart = response['results'];
//print(placesStart);
update();
}
@@ -1796,7 +1738,6 @@ class MapPassengerController extends GetxController {
wayPoint0 = response['results'];
placeListResponseAll[index] = response['results'];
//print(wayPoint0);
update();
}
@@ -1944,10 +1885,6 @@ class MapPassengerController extends GetxController {
newStartPointLocation = passengerLocation;
speed = _locationData.speed!;
// //print location details
// //print('Accuracy: ${_locationData.accuracy}');
// //print('Latitude: ${_locationData.latitude}');
// //print('Longitude: ${_locationData.longitude}');
// //print('Time: ${_locationData.time}');
isLoading = false;
update();
}
@@ -1984,7 +1921,6 @@ class MapPassengerController extends GetxController {
// void startMarkerReloading() {
// int count = 0;
// markerReloadingTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
// //print('timer==============================');
// reloadMarkers();
//
// count++;
@@ -2000,7 +1936,6 @@ class MapPassengerController extends GetxController {
Timer.periodic(const Duration(seconds: 2), (timer) {
reloadCount++;
//print('Reloading markers ($reloadCount)');
if (!rideConfirm) {
reloadMarkers();
} else {
@@ -2009,7 +1944,6 @@ class MapPassengerController extends GetxController {
if (reloadCount >= 35) {
timer.cancel(); // Stop the timer after 5 reloads
//print('Marker reloading completed.');
}
});
}
@@ -2063,7 +1997,6 @@ class MapPassengerController extends GetxController {
latitude: double.parse(carLocation['latitude']),
longitude: double.parse(carLocation['longitude']),
);
print('nearestCar ${nearestDistance.toStringAsFixed(0)}');
// Update the UI with the nearest driver
update();
@@ -2132,7 +2065,6 @@ class MapPassengerController extends GetxController {
// Handle the distance and duration as needed
else {
//print(
// 'Failed to retrieve distance and duration: ${response['status']}');
// Handle the failure case
}
@@ -2140,11 +2072,6 @@ class MapPassengerController extends GetxController {
}
}
}
//print(nearestCar!.distance);
//print(nearestCar!.duration);
//print(nearestCar!.latitude);
//print(nearestCar!.longitude);
//print(nearestCar!.id);
}
calculateDistanceBetweenPassengerAndDriverBeforeCancelRide() async {
@@ -2202,7 +2129,6 @@ class MapPassengerController extends GetxController {
update();
remainingTime = 25; //to make cancel every call
await getCarsLocationByPassengerAndReloadMarker();
// //print(carsLocationByPassenger);
var coordDestination = destination.split(',');
double latPassengerDestination = double.parse(coordDestination[0]);
double lngPassengerDestination = double.parse(coordDestination[1]);
@@ -2218,7 +2144,6 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
// //print(data);
box.remove(BoxName.tripData);
box.write(BoxName.tripData, response);
startNameAddress = data[0]['start_address'];
@@ -2314,12 +2239,9 @@ class MapPassengerController extends GetxController {
// '&key=${AK.mapAPIKEY}';
// var response = await CRUD().getGoogleApi(link: url, payload: {});
// data = response['routes'][0]['legs'];
// // //print(data);
// // isLoading = false;
// int durationToRide0 = data[0]['duration']['value'];
// durationToRide = durationToRide + durationToRide0;
// print(durationToRide0);
// print('durationToRide = $durationToRide');
// distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000;
// update();
// final points =
@@ -2357,16 +2279,12 @@ class MapPassengerController extends GetxController {
update();
var url =
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destinationSteps&origin=$originSteps&key=${AK.mapAPIKEY}');
// //print(url);
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
// //print(data);
// isLoading = false;
int durationToRide0 = data[0]['duration']['value'];
durationToRide = durationToRide + durationToRide0;
print(durationToRide0);
print('durationToRide = $durationToRide');
distance = distanceOfDestination + (data[0]['distance']['value']) / 1000;
update();
@@ -2422,10 +2340,6 @@ class MapPassengerController extends GetxController {
LatLngBounds bounds =
LatLngBounds(northeast: northeast, southwest: southwest);
print('boundsbounds');
print(bounds);
print('boundsbounds');
// Fit the camera to the bounds
var cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 180);
mapController!.animateCamera(cameraUpdate);
@@ -2471,7 +2385,6 @@ class MapPassengerController extends GetxController {
var decode = jsonDecode(value);
if (decode["status"] == "success") {
//print(totalPassenger);
var firstElement = decode["message"][0];
if (double.parse(box.read(BoxName.passengerWalletTotal)) < 0) {
totalPassenger = totalCostPassenger -
@@ -2487,7 +2400,6 @@ class MapPassengerController extends GetxController {
(totalDriver * int.parse(firstElement['amount']) / 100);
promoTaken = true;
update();
//print(totalPassenger);
Get.back();
}
});
@@ -2510,8 +2422,6 @@ class MapPassengerController extends GetxController {
Future bottomSheet() async {
if (data.isNotEmpty) {
durationToAdd = Duration(seconds: durationToRide);
print('durationToRide----- $durationToRide');
print('durationToAdd----- $durationToAdd');
hours = durationToAdd.inHours;
minutes = (durationToAdd.inMinutes % 60).round();
DateTime currentTime = DateTime.now();
@@ -2519,11 +2429,7 @@ class MapPassengerController extends GetxController {
averageDuration = (durationToRide / 60) / distance;
// costDuration = (durationToRide / 60) * averageDuration * 0.016;
costDuration = (durationToRide / 60).floorToDouble();
print('costDuration----- $costDuration');
print('costDistance----- $costDistance');
print('Distance----- $distance');
print(
'passengerWalletTotal----- ${box.read(BoxName.passengerWalletTotal)}');
'passengerWalletTotal----- ${box.read(BoxName.passengerWalletTotal)}';
double costComfort, costSpeed, costDelivery, costLady, costRayehGai = 0;
update();
if (currentTime.hour >= 22 && currentTime.hour < 5) {
@@ -2561,7 +2467,6 @@ class MapPassengerController extends GetxController {
costDuration * 2;
update();
}
//print('cost $cost');
var totalDriver1 = costDistance + costDuration;
totalCostPassenger = totalDriver1 + (totalDriver1 * kazan / 100);
@@ -2593,7 +2498,6 @@ class MapPassengerController extends GetxController {
tax = totalCostPassenger * kazan / 100;
totalME = totalCostPassenger - tax;
costForDriver = fuelPrice * (20 / 210) * distance;
print('cost for driver = $costForDriver');
if (totalPassengerSpeed < 20) {
// for eygpt 20 le open ride
totalCostPassenger = 20;
@@ -2620,9 +2524,7 @@ class MapPassengerController extends GetxController {
// buttomSheetMapPage();
changeBottomSheetShown();
} else {
print('==========================');
}
} else {}
}
addToken() async {
@@ -2720,7 +2622,6 @@ class MapPassengerController extends GetxController {
payload: {'country': box.read(BoxName.countryCode).toString()},
);
if (res != 'failure') {
print(jsonDecode(res));
var json = jsonDecode(res);
kazan = double.parse(json['message'][0]['kazan']);
naturePrice = double.parse(json['message'][0]['naturePrice']);
@@ -2739,7 +2640,6 @@ class MapPassengerController extends GetxController {
link: AppLink.getPassengerRate,
payload: {'passenger_id': box.read(BoxName.passengerID)});
if (res != 'failure') {
print(jsonDecode(res)['message']['rating']);
if (jsonDecode(res)['message']['rating'] == null) {
passengerRate = 5;
} else {

View File

@@ -32,7 +32,6 @@ DbSql sql = DbSql.instance;
@pragma('vm:entry-point')
Future<void> backgroundMessageHandler(RemoteMessage message) async {
await Firebase.initializeApp();
print('===========back===${message.notification?.title}');
FirebaseMessagesController().fireBaseTitles(message);
}
@@ -48,10 +47,8 @@ void main() async {
await GetStorage.init();
// Get.put(DriverCallController());
await AC().gAK();
print(
'local is ${WidgetsBinding.instance.platformDispatcher.locale.countryCode}');
'local is ${WidgetsBinding.instance.platformDispatcher.locale.countryCode}';
// print(Get.deviceLocale!.countryCode);
Stripe.publishableKey = AK.publishableKey;
// if (box.read(BoxName.driverID) != null) {}
if (Platform.isAndroid || Platform.isIOS) {