This commit is contained in:
Hamza-Ayed
2024-10-01 19:36:38 +03:00
parent 659f178737
commit 6f95dafd0b
13 changed files with 250 additions and 307 deletions

View File

@@ -263,7 +263,7 @@ class RegisterCaptainController extends GetxController {
);
// Get.snackbar('', '');
// await smsEgyptController.sendSmsEgypt(phoneNumber, randomNumber.toString());
await smsEgyptController.sendSmsEgypt(phoneNumber, randomNumber.toString());
lastOtpSentTime = DateTime.now(); // Update the last OTP sent time
isSent = true;

View File

@@ -1,30 +1,30 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
// import 'package:firebase_auth/firebase_auth.dart';
// import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
class FacebookSignIn {
Future<UserCredential?> signInWithFacebook() async {
final LoginResult result = await FacebookAuth.instance.login();
if (result.status == LoginStatus.success) {
// Create a credential from the access token
final OAuthCredential credential =
FacebookAuthProvider.credential(result.accessToken!.tokenString);
// Once signed in, return the UserCredential
return await FirebaseAuth.instance.signInWithCredential(credential);
}
return null;
}
// class FacebookSignIn {
// Future<UserCredential?> signInWithFacebook() async {
// final LoginResult result = await FacebookAuth.instance.login();
// if (result.status == LoginStatus.success) {
// // Create a credential from the access token
// final OAuthCredential credential =
// FacebookAuthProvider.credential(result.accessToken!.tokenString);
// // Once signed in, return the UserCredential
// return await FirebaseAuth.instance.signInWithCredential(credential);
// }
// return null;
// }
Future<void> signOut() async {
try {
await FacebookAuth.instance.logOut();
print('Facebook Sign Out Successful');
} catch (e) {
print('Error during Facebook Sign Out: $e');
}
}
// Future<void> signOut() async {
// try {
// await FacebookAuth.instance.logOut();
// print('Facebook Sign Out Successful');
// } catch (e) {
// print('Error during Facebook Sign Out: $e');
// }
// }
Future<bool> isSignedIn() async {
final accessToken = await FacebookAuth.instance.accessToken;
return accessToken != null;
}
}
// Future<bool> isSignedIn() async {
// final accessToken = await FacebookAuth.instance.accessToken;
// return accessToken != null;
// }
// }

View File

@@ -61,7 +61,7 @@ class NotificationController extends GetxController {
priority: Priority.high,
styleInformation: bigTextStyleInformation,
playSound: true,
sound: RawResourceAndroidNotificationSound(tone == '' ? 'ding' : tone),
sound: RawResourceAndroidNotificationSound(tone),
// audioAttributesUsage: AudioAttributesUsage.alarm,
visibility: NotificationVisibility.public,
autoCancel: false,

View File

@@ -328,7 +328,7 @@ class MapDriverController extends GetxController {
double _distance =
await calculateDistanceBetweenDriverAndPassengerLocation();
if (_distance < 50) {
if (_distance < 60) {
changeRideToBeginToPassenger();
isPassengerInfoWindow = false;
isRideStarted = true;
@@ -347,6 +347,19 @@ class MapDriverController extends GetxController {
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/rides/update.php",
payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
CRUD()
.post(link: "${AppLink.seferGizaServer}/rides/update.php", payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'RideIsBegin',
@@ -586,6 +599,23 @@ class MapDriverController extends GetxController {
'status': 'Finished',
'price': totalCost,
});
CRUD().post(
link: "${AppLink.seferGizaServer}/rides/update.php",
payload: {
'id': rideId,
'rideTimeFinish': DateTime.now().toString(),
'status': 'Finished',
'price': totalCost,
},
);
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/rides/update.php",
payload: {
'id': rideId,
'rideTimeFinish': DateTime.now().toString(),
'status': 'Finished',
'price': totalCost,
});
if (walletChecked == 'true') {
paymentToken = await generateTokenPassenger(
((-1) * double.parse(paymentAmount)).toString());
@@ -652,9 +682,11 @@ class MapDriverController extends GetxController {
}
void cancelCheckRideFromPassenger() async {
var res = await CRUD().get(link: AppLink.getOrderCancelStatus, payload: {
'order_id': rideId,
}); //.then((value) {
var res = await CRUD().get(
link: "${AppLink.endPoint}/ride/driver_order/getOrderCancelStatus.php",
payload: {
'order_id': rideId,
}); //.then((value) {
var response = jsonDecode(res);
canelString = response['data']['status'];
update();
@@ -687,6 +719,7 @@ class MapDriverController extends GetxController {
DateTime currentTime = DateTime.now();
void rideIsBeginPassengerTimer() async {
int durationOfRide = int.parse(durationOfRideValue);
double latePrice = Get.find<HomeCaptainController>().latePrice;
update();
int infinity = 40000;
if (carType == 'Comfort' ||
@@ -716,60 +749,26 @@ class MapDriverController extends GetxController {
endNameLocation.contains('مطار') ||
endNameLocation.contains('المطار')) {
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
(price) -
int.parse(duration) *
Get.find<HomeCaptainController>().latePrice
// : carType == 'Speed'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().speedPrice)
? price + ((i ~/ 60) - int.parse(duration)) * latePrice
: carType == 'Lady'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
(price) -
int.parse(duration) *
Get.find<HomeCaptainController>().latePrice
// : carType == 'Delivery'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().deliveryPrice)
? price + ((i ~/ 60) - int.parse(duration)) * latePrice
: carType == 'RayehGaiComfort'
? (i ~/ 60) *
Get.find<HomeCaptainController>().latePrice +
? (i ~/ 60) * latePrice +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) *
Get.find<HomeCaptainController>().latePrice +
: (i ~/ 60) * latePrice +
(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 +
(price) -
int.parse(duration) *
Get.find<HomeCaptainController>().latePrice
// : carType == 'Speed'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().speedPrice)
? price + ((i ~/ 60) - int.parse(duration)) * latePrice
: carType == 'Lady'
? (i ~/ 60) * Get.find<HomeCaptainController>().latePrice +
(price) -
int.parse(duration) *
Get.find<HomeCaptainController>().latePrice
// : carType == 'Delivery'
// ? (i ~/ 60) +
// (recentDistanceToDash *
// Get.find<HomeCaptainController>().deliveryPrice)
? price + ((i ~/ 60) - int.parse(duration)) * latePrice
: carType == 'RayehGaiComfort'
? (i ~/ 60) *
Get.find<HomeCaptainController>().latePrice +
? (i ~/ 60) * latePrice +
(recentDistanceToDash *
Get.find<HomeCaptainController>().comfortPrice)
: (i ~/ 60) *
Get.find<HomeCaptainController>().latePrice +
: (i ~/ 60) * latePrice +
(recentDistanceToDash *
Get.find<HomeCaptainController>().mashwariPrice);
} else if (currentTime.hour >= 1 && currentTime.hour < 5) {
@@ -779,51 +778,29 @@ class MapDriverController extends GetxController {
startNameLocation.contains('ملهى ليلي') ||
startNameLocation.contains('Night club')) {
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) *
2 +
? (i ~/ 60) * (latePrice + .5) * 2 +
(price) -
int.parse(duration) *
(Get.find<HomeCaptainController>().latePrice + .5) *
2
int.parse(duration) * (latePrice + .5) * 2
: carType == 'Lady'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) *
2 +
? (i ~/ 60) * (latePrice + .5) * 2 +
(price) -
int.parse(duration) *
(Get.find<HomeCaptainController>().latePrice + .5) *
2
int.parse(duration) * (latePrice + .5) * 2
: carType == 'RayehGaiComfort'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice +
.5) *
2 +
(price)
: (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice +
.5) *
2 +
(price);
? (i ~/ 60) * (latePrice + .5) * 2 + (price)
: (i ~/ 60) * (latePrice + .5) * 2 + (price);
}
price = carType == 'Comfort' // || carType == 'Free Ride'
? (i ~/ 60) * (Get.find<HomeCaptainController>().latePrice + .5) +
? (i ~/ 60) * (latePrice + .5) +
(price) -
int.parse(duration) *
(Get.find<HomeCaptainController>().latePrice + .5)
int.parse(duration) * (latePrice + .5)
: carType == 'Lady'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice + .5) +
? (i ~/ 60) * (latePrice + .5) +
(price) -
int.parse(duration) *
(Get.find<HomeCaptainController>().latePrice + .5)
int.parse(duration) * (latePrice + .5)
: carType == 'RayehGaiComfort'
? (i ~/ 60) *
(Get.find<HomeCaptainController>().latePrice +
.5) +
? (i ~/ 60) * (latePrice + .5) +
(price) -
int.parse(duration) *
(Get.find<HomeCaptainController>().latePrice + .5)
int.parse(duration) * (latePrice + .5)
: price;
} else if (currentTime.hour >= 14 && currentTime.hour <= 17) {
price = carType == 'Comfort' // || carType == 'Free Ride'

View File

@@ -7,7 +7,6 @@ import 'package:SEFER/views/home/Captin/orderCaptin/order_request_page.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
@@ -110,14 +109,7 @@ void main() async {
await GetStorage.init();
Stripe.publishableKey = AK.publishableKeyStripe;
// Request location permission
// PermissionStatus status = await Permission.location.request();
// if (status.isDenied) {
// WidgetsBinding.instance.addPostFrameCallback((_) {
// getPermissionLocation();
// });
// return;
// }
PermissionStatus status1 = await Permission.location.status;
if (status1.isGranted) {
await LocationController().startLocationUpdates();
@@ -130,7 +122,7 @@ void main() async {
await FirebaseMessagesController().requestFirebaseMessagingPermission();
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
// NotificationController1().initNotifications();
NotificationController().initNotifications();
NotificationController().initNotifications();
await Future.wait([

View File

@@ -177,129 +177,129 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
),
),
),
// AnimatedContainer(
// duration: const Duration(microseconds: 200),
// width: controller.widthMapTypeAndTraffic,
// decoration: BoxDecoration(
// color: AppColor.secondaryColor,
// border: Border.all(color: AppColor.blueColor),
// borderRadius: BorderRadius.circular(15)),
// child: Builder(builder: (context) {
// return IconButton(
// onPressed: () async {
// // Get.to(() => EgyptCardAI());
// // print(box.read(BoxName.myList));
AnimatedContainer(
duration: const Duration(microseconds: 200),
width: controller.widthMapTypeAndTraffic,
decoration: BoxDecoration(
color: AppColor.secondaryColor,
border: Border.all(color: AppColor.blueColor),
borderRadius: BorderRadius.circular(15)),
child: Builder(builder: (context) {
return IconButton(
onPressed: () async {
// Get.to(() => EgyptCardAI());
// print(box.read(BoxName.myList));
// List<String> d = [
// "30.003028,31.2419628",
// "30.0955661,31.2665336",
// "160.00",
// "25.92",
// "1488",
// "16.93",
// "114243034311436865474",
// "113172279072358305645",
// "hamza ayed",
// "rlMbi4Hc8L1STMPE99iPKqK4Gddwv8r9qZOCadsz9qTEJZ6KLEE9ruTJI6N8dKfK4CXez5pme5WIs14-1QGo29s07fQOniZgIlJV5XFL3yqzPRSUmn3",
// "+201023248456",
// "1 min",
// "1 m",
// "false",
// "QwUMoyUtZ0J3oR6yXKUavrB_gBl9npUZe-qZtax-Raq4QBbdKv0AmtLKm0BfBd6N_592HBv4CVa41ii4122W3hr-BCUKKzJhzZcK8m0YjbWbtpvgJRD8uD_nuMk9",
// "0",
// "238",
// "false",
// "114243034311436865474",
// "1488",
// "startEnd",
// "30.049307749732176,31.274291574954987",
// "",
// "",
// "",
// "",
// "17.73",
// "0",
// "hamzaayedflutter@gmail.com",
// "الفسطاط، حي مصر القديمة، مصر",
// " الزاوية الحمراء، محافظة القاهرة، مصر",
// "Speed",
// "8",
// "5.00"
// ];
// FirebaseMessagesController().sendNotificationToDriverMAP(
// 'Order'.tr,
// 'from: ',
// // jsonDecode(value)['message'].toString(),
// 'dUEVBJDPQfKiMuGgDjdyfX:APA91bE3DKYAYs3LIxGmzy55-ojLAZWv0ym4a9Zy9UxdkyRUOgQP8bf1WwU9LJAof0DjfaIxciVYPnue7EdwhujzQe67SImfOF9yI1YgGsKLDH6yo6FsFaAYpsbrSCqlaoRp14lLqymi',
// d,
// 'order.wav');
// // NotificationController()
// // .showNotification('VIP Order'.tr, '', 'order', '');
// // try {} catch (e) {
// // print('Error showing overlay: $e');
// // }
// // final Bubble _bubble = Bubble(showCloseButton: true);
// // try {
// // await _bubble.startBubbleHead(sendAppToBackground: false);
// // } on PlatformException {
// // print('Failed to call startBubbleHead');
// // }
List<String> d = [
"30.003028,31.2419628",
"30.0955661,31.2665336",
"160.00",
"25.92",
"1488",
"16.93",
"114243034311436865474",
"113172279072358305645",
"hamza ayed",
"rlMbi4Hc8L1STMPE99iPKqK4Gddwv8r9qZOCadsz9qTEJZ6KLEE9ruTJI6N8dKfK4CXez5pme5WIs14-1QGo29s07fQOniZgIlJV5XFL3yqzPRSUmn3",
"+201023248456",
"1 min",
"1 m",
"false",
"QwUMoyUtZ0J3oR6yXKUavrB_gBl9npUZe-qZtax-Raq4QBbdKv0AmtLKm0BfBd6N_592HBv4CVa41ii4122W3hr-BCUKKzJhzZcK8m0YjbWbtpvgJRD8uD_nuMk9",
"0",
"238",
"false",
"114243034311436865474",
"1488",
"startEnd",
"30.049307749732176,31.274291574954987",
"",
"",
"",
"",
"17.73",
"0",
"hamzaayedflutter@gmail.com",
"الفسطاط، حي مصر القديمة، مصر",
" الزاوية الحمراء، محافظة القاهرة، مصر",
"Speed",
"8",
"5.00"
];
FirebaseMessagesController().sendNotificationToDriverMAP(
'Order'.tr,
'from: ',
// jsonDecode(value)['message'].toString(),
'fKBBB4_1R0q18-byySHUeG:APA91bHk2RmjjMt6eKr7KQnqh4CK02yW3H5E8g_beVcQFgiCG50j9KCtSU1O8PtvS_gA5xuJLhaorDV9AeslcyLFJFf302tICKMiKgsDP5pWkF5WXNw0-4NsoD-BnJxf0-Do9Vs1Zbpq',
d,
'order.wav');
// NotificationController()
// .showNotification('VIP Order'.tr, '', 'order', '');
// try {} catch (e) {
// print('Error showing overlay: $e');
// }
// final Bubble _bubble = Bubble(showCloseButton: true);
// try {
// await _bubble.startBubbleHead(sendAppToBackground: false);
// } on PlatformException {
// print('Failed to call startBubbleHead');
// }
// // Bubble().startBubbleHead(sendAppToBackground: true);
// // }
// Bubble().startBubbleHead(sendAppToBackground: true);
// }
// // Future<void> stopBubbleHead() async {
// // try {
// // await _bubble.stopBubbleHead();
// // } on PlatformException {
// // print('Failed to call stopBubbleHead');
// // }
// // }
// //
// // // // send data to ovelay
// },
// icon: const Icon(
// FontAwesome5.grin_tears,
// size: 29,
// color: AppColor.blueColor,
// ),
// );
// }),
// ),
// AnimatedContainer(
// duration: const Duration(microseconds: 200),
// width: controller.widthMapTypeAndTraffic,
// decoration: BoxDecoration(
// color: AppColor.secondaryColor,
// border: Border.all(color: AppColor.blueColor),
// borderRadius: BorderRadius.circular(15)),
// child: Builder(builder: (context) {
// return IconButton(
// onPressed: () async {
// // FirebaseMessagesController().sendNotificationToAnyWithoutData(
// 'Order'.tr,
// 'from: ',
// // jsonDecode(value)['message'].toString(),
// 'dqK5wNrPTr20HQ8qa5KsgL:APA91bHwPW_XzCIxQtg_IkJmHg1JRd8NRMquvsgedBaHAIgErTs6Uzpw1IX0EIJqkTaZq5dxd1u2z7NVdLlvcmEzrpjjWt1pUsZaa5UU7Cpx6hUzJMUdXvhNlAYFGklM8bWUG4ZXSRf1',
// 'order.wav');
// NotificationController1().showNotification(
// 'sdf'.tr,
// 'We regret to inform you that another driver has accepted this order.'
// .tr,
// '',
// '');
// requestLocationPermission();
// Get.to(() => LoginCaptin());
// print(box.read(BoxName.tokenDriver));
// },
// icon: const Icon(
// FontAwesome5.closed_captioning,
// size: 29,
// color: AppColor.blueColor,
// ),
// );
// }),
// ),
// Future<void> stopBubbleHead() async {
// try {
// await _bubble.stopBubbleHead();
// } on PlatformException {
// print('Failed to call stopBubbleHead');
// }
// }
//
// // // send data to ovelay
},
icon: const Icon(
FontAwesome5.grin_tears,
size: 29,
color: AppColor.blueColor,
),
);
}),
),
AnimatedContainer(
duration: const Duration(microseconds: 200),
width: controller.widthMapTypeAndTraffic,
decoration: BoxDecoration(
color: AppColor.secondaryColor,
border: Border.all(color: AppColor.blueColor),
borderRadius: BorderRadius.circular(15)),
child: Builder(builder: (context) {
return IconButton(
onPressed: () async {
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
// 'Order'.tr,
// 'from: ',
// // jsonDecode(value)['message'].toString(),
// 'fKBBB4_1R0q18-byySHUeG:APA91bHk2RmjjMt6eKr7KQnqh4CK02yW3H5E8g_beVcQFgiCG50j9KCtSU1O8PtvS_gA5xuJLhaorDV9AeslcyLFJFf302tICKMiKgsDP5pWkF5WXNw0-4NsoD-BnJxf0-Do9Vs1Zbpq',
// 'order.wav');
// NotificationController1().showNotification(
// 'sdf'.tr,
// 'We regret to inform you that another driver has accepted this order.'
// .tr,
// '',
// '');
// requestLocationPermission();
Get.to(() => SmsSignupEgypt());
print(box.read(BoxName.tokenDriver));
},
icon: const Icon(
FontAwesome5.closed_captioning,
size: 29,
color: AppColor.blueColor,
),
);
}),
),
],
)),
);