2-10/3/1
This commit is contained in:
@@ -94,138 +94,139 @@ class RegisterCaptainController extends GetxController {
|
||||
return validPrefixes.hasMatch(phoneNumber);
|
||||
}
|
||||
|
||||
// sendOtpMessage() async {
|
||||
// SmsEgyptController smsEgyptController = Get.put(SmsEgyptController());
|
||||
// isLoading = true;
|
||||
// update();
|
||||
// int randomNumber = Random().nextInt(100000) + 1;
|
||||
// isLoading = true;
|
||||
// update();
|
||||
// if (formKey3.currentState!.validate()) {
|
||||
// if (box.read(BoxName.countryCode) == 'Egypt') {
|
||||
// if (isValidEgyptianPhoneNumber(phoneController.text)) {
|
||||
// var responseCheker = await CRUD()
|
||||
// .post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
|
||||
// 'phone_number': '+2${phoneController.text}',
|
||||
// });
|
||||
// if (responseCheker != 'failure') {
|
||||
// var d = jsonDecode(responseCheker);
|
||||
// if (d['message'][0]['is_verified'].toString() == '1') {
|
||||
// Get.snackbar('Phone number is verified before'.tr, '',
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
// box.write(BoxName.phoneVerified, '1');
|
||||
// box.write(BoxName.phone, '+2${phoneController.text}');
|
||||
// await Get.put(LoginDriverController()).loginUsingCredentials(
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.emailDriver).toString(),
|
||||
// );
|
||||
// } else {
|
||||
// await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
// 'phone_number': '+2${phoneController.text}',
|
||||
// 'token_code': randomNumber.toString(),
|
||||
// "driverId": box.read(BoxName.driverID),
|
||||
// "email": box.read(BoxName.emailDriver),
|
||||
// });
|
||||
sendOtpMessage() async {
|
||||
SmsEgyptController smsEgyptController = Get.put(SmsEgyptController());
|
||||
isLoading = true;
|
||||
update();
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
isLoading = true;
|
||||
update();
|
||||
if (formKey3.currentState!.validate()) {
|
||||
if (box.read(BoxName.countryCode) == 'Egypt') {
|
||||
if (isValidEgyptianPhoneNumber(phoneController.text)) {
|
||||
var responseCheker = await CRUD()
|
||||
.post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
});
|
||||
if (responseCheker != 'failure') {
|
||||
var d = jsonDecode(responseCheker);
|
||||
if (d['message'][0]['is_verified'].toString() == '1') {
|
||||
Get.snackbar('Phone number is verified before'.tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
box.write(BoxName.phone, '+2${phoneController.text}');
|
||||
await Get.put(LoginDriverController()).loginUsingCredentials(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
);
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
|
||||
// await smsEgyptController.sendSmsEgypt(
|
||||
// phoneController.text.toString(), randomNumber.toString());
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
// isSent = true;
|
||||
isSent = true;
|
||||
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// }
|
||||
// } else {
|
||||
// await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
// 'phone_number': '+2${phoneController.text}',
|
||||
// 'token_code': randomNumber.toString(),
|
||||
// "driverId": box.read(BoxName.driverID),
|
||||
// "email": box.read(BoxName.emailDriver),
|
||||
// });
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
|
||||
// await smsEgyptController.sendSmsEgypt(
|
||||
// phoneController.text.toString(), randomNumber.toString());
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
// isSent = true;
|
||||
isSent = true;
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
Get.snackbar('Phone Number wrong'.tr, '',
|
||||
backgroundColor: AppColor.redColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// }
|
||||
// } else {
|
||||
// Get.snackbar('Phone Number wrong'.tr, '',
|
||||
// backgroundColor: AppColor.redColor);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// }
|
||||
DateTime? lastOtpSentTime; // Store the last OTP sent time
|
||||
int otpResendInterval = 300; // 5 minutes in seconds
|
||||
|
||||
// Main function to handle OTP sending
|
||||
sendOtpMessage() async {
|
||||
if (_isOtpResendAllowed()) {
|
||||
isLoading = true;
|
||||
update();
|
||||
// sendOtpMessage() async {
|
||||
// if (_isOtpResendAllowed()) {
|
||||
// isLoading = true;
|
||||
// update();
|
||||
|
||||
if (formKey3.currentState!.validate()) {
|
||||
String countryCode = box.read(BoxName.countryCode);
|
||||
String phoneNumber = phoneController.text;
|
||||
// if (formKey3.currentState!.validate()) {
|
||||
// String countryCode = box.read(BoxName.countryCode);
|
||||
// String phoneNumber = phoneController.text;
|
||||
|
||||
if (countryCode == 'Egypt' && isValidEgyptianPhoneNumber(phoneNumber)) {
|
||||
await _checkAndSendOtp(phoneNumber);
|
||||
} else {
|
||||
_showErrorMessage('Phone Number is not Egypt phone '.tr);
|
||||
}
|
||||
}
|
||||
isLoading = false;
|
||||
update();
|
||||
} else {
|
||||
_showCooldownMessage();
|
||||
}
|
||||
}
|
||||
// if (countryCode == 'Egypt' && isValidEgyptianPhoneNumber(phoneNumber)) {
|
||||
// await _checkAndSendOtp(phoneNumber);
|
||||
// } else {
|
||||
// _showErrorMessage('Phone Number is not Egypt phone '.tr);
|
||||
// }
|
||||
// }
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// } else {
|
||||
// _showCooldownMessage();
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check if the resend OTP request is allowed (5 minutes cooldown)
|
||||
bool _isOtpResendAllowed() {
|
||||
if (lastOtpSentTime == null) return true;
|
||||
// bool _isOtpResendAllowed() {
|
||||
// if (lastOtpSentTime == null) return true;
|
||||
|
||||
final int elapsedTime =
|
||||
DateTime.now().difference(lastOtpSentTime!).inSeconds;
|
||||
return elapsedTime >= otpResendInterval;
|
||||
}
|
||||
// final int elapsedTime =
|
||||
// DateTime.now().difference(lastOtpSentTime!).inSeconds;
|
||||
// return elapsedTime >= otpResendInterval;
|
||||
// }
|
||||
|
||||
// Show message when user tries to resend OTP too soon
|
||||
void _showCooldownMessage() {
|
||||
int remainingTime = otpResendInterval -
|
||||
DateTime.now().difference(lastOtpSentTime!).inSeconds;
|
||||
Get.snackbar(
|
||||
'Please wait ${remainingTime ~/ 60}:${(remainingTime % 60).toString().padLeft(2, '0')} minutes before requesting again',
|
||||
'',
|
||||
backgroundColor: AppColor.redColor,
|
||||
);
|
||||
}
|
||||
// // Show message when user tries to resend OTP too soon
|
||||
// void _showCooldownMessage() {
|
||||
// int remainingTime = otpResendInterval -
|
||||
// DateTime.now().difference(lastOtpSentTime!).inSeconds;
|
||||
// Get.snackbar(
|
||||
// 'Please wait ${remainingTime ~/ 60}:${(remainingTime % 60).toString().padLeft(2, '0')} minutes before requesting again',
|
||||
// '',
|
||||
// backgroundColor: AppColor.redColor,
|
||||
// );
|
||||
// }
|
||||
|
||||
// Check if the phone number has been verified, and send OTP if not verified
|
||||
_checkAndSendOtp(String phoneNumber) async {
|
||||
var responseChecker = await CRUD().post(
|
||||
link: AppLink.checkPhoneNumberISVerfiedDriver,
|
||||
payload: {
|
||||
'phone_number': '+2$phoneNumber',
|
||||
},
|
||||
);
|
||||
// // Check if the phone number has been verified, and send OTP if not verified
|
||||
// _checkAndSendOtp(String phoneNumber) async {
|
||||
// var responseChecker = await CRUD().post(
|
||||
// link: AppLink.checkPhoneNumberISVerfiedDriver,
|
||||
// payload: {
|
||||
// 'phone_number': '+2$phoneNumber',
|
||||
// },
|
||||
// );
|
||||
|
||||
if (responseChecker != 'failure') {
|
||||
var responseData = jsonDecode(responseChecker);
|
||||
if (_isPhoneVerified(responseData)) {
|
||||
_handleAlreadyVerified();
|
||||
} else {
|
||||
await _sendOtpAndSms(phoneNumber);
|
||||
}
|
||||
} else {
|
||||
await _sendOtpAndSms(phoneNumber);
|
||||
}
|
||||
}
|
||||
// if (responseChecker != 'failure') {
|
||||
// var responseData = jsonDecode(responseChecker);
|
||||
// if (_isPhoneVerified(responseData)) {
|
||||
// _handleAlreadyVerified();
|
||||
// } else {
|
||||
// await _sendOtpAndSms(phoneNumber);
|
||||
// }
|
||||
// } else {
|
||||
// await _sendOtpAndSms(phoneNumber);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check if the phone number is already verified
|
||||
bool _isPhoneVerified(dynamic responseData) {
|
||||
|
||||
@@ -115,7 +115,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Future<void> fireBaseTitles(RemoteMessage message) async {
|
||||
if (message.notification!.title! == 'Order'.tr) {
|
||||
if (Platform.isAndroid) {
|
||||
NotificationController1().showNotification('Order'.tr, '', 'order', '');
|
||||
NotificationController().showNotification('Order'.tr, '', 'order', '');
|
||||
}
|
||||
// await FirebaseMessagesController().showOverlayNotification(message);
|
||||
var myListString = message.data['DriverList'];
|
||||
@@ -156,6 +156,8 @@ class FirebaseMessagesController extends GetxController {
|
||||
});
|
||||
|
||||
// Get.to(const VipOrderPage());
|
||||
} else if (message.notification!.title! == 'message From passenger'.tr) {
|
||||
passengerDialog(message.notification!.body!);
|
||||
} else if (message.notification!.title == 'Cancel') {
|
||||
cancelTripDialog1();
|
||||
} else if (message.notification!.title! == 'token change') {
|
||||
@@ -163,15 +165,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
// .showNotification('token change'.tr, 'token change', 'cancel');
|
||||
// GoogleSignInHelper.signOut();
|
||||
GoogleSignInHelper.signOut();
|
||||
} else if (message.notification!.title! == 'message From passenger') {
|
||||
// print('sdfd');
|
||||
// if (Platform.isAndroid) {
|
||||
// NotificationController1()
|
||||
// .showNotification('message From passenger'.tr, ''.tr, 'tone2', '');
|
||||
// }
|
||||
passengerDialog(message.notification!.body!);
|
||||
|
||||
update();
|
||||
} else if (message.notification!.title! == 'face detect') {
|
||||
if (Platform.isAndroid) {
|
||||
NotificationController1()
|
||||
|
||||
@@ -15,7 +15,7 @@ import '../home/captin/home_captain_controller.dart';
|
||||
class NotificationController extends GetxController {
|
||||
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
// Initializes the local notifications plugin
|
||||
|
||||
Future<void> initNotifications() async {
|
||||
const AndroidInitializationSettings android =
|
||||
AndroidInitializationSettings('@mipmap/launcher_icon');
|
||||
@@ -26,14 +26,13 @@ class NotificationController extends GetxController {
|
||||
await _flutterLocalNotificationsPlugin.initialize(
|
||||
initializationSettings,
|
||||
onDidReceiveNotificationResponse: onDidReceiveNotificationResponse,
|
||||
onDidReceiveBackgroundNotificationResponse:
|
||||
onDidReceiveBackgroundNotificationResponse,
|
||||
onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
|
||||
);
|
||||
|
||||
// Create a notification channel
|
||||
const AndroidNotificationChannel channel = AndroidNotificationChannel(
|
||||
'your channel id',
|
||||
'your channel name',
|
||||
'high_importance_channel', // Use the same ID as in strings.xml
|
||||
'High Importance Notifications',
|
||||
description: 'This channel is used for important notifications.',
|
||||
importance: Importance.high,
|
||||
);
|
||||
@@ -56,7 +55,8 @@ class NotificationController extends GetxController {
|
||||
);
|
||||
|
||||
AndroidNotificationDetails android = AndroidNotificationDetails(
|
||||
'high_importance_channel', 'High Importance Notifications',
|
||||
'high_importance_channel', // Use the same ID as before
|
||||
'High Importance Notifications',
|
||||
importance: Importance.high,
|
||||
priority: Priority.high,
|
||||
styleInformation: bigTextStyleInformation,
|
||||
@@ -94,17 +94,17 @@ class NotificationController extends GetxController {
|
||||
|
||||
// Callback when the notification is tapped
|
||||
void onDidReceiveNotificationResponse(NotificationResponse response) {
|
||||
_handleNotificationResponse(response);
|
||||
handleNotificationResponse(response);
|
||||
}
|
||||
|
||||
// Callback when the notification is tapped while the app is in the background
|
||||
void onDidReceiveBackgroundNotificationResponse(
|
||||
NotificationResponse response) {
|
||||
_handleNotificationResponse(response);
|
||||
handleNotificationResponse(response);
|
||||
}
|
||||
|
||||
// Handle notification response for both foreground and background
|
||||
void _handleNotificationResponse(NotificationResponse response) {
|
||||
void handleNotificationResponse(NotificationResponse response) {
|
||||
print('Notification tapped!');
|
||||
Log.print('response.payload: ${response.payload}');
|
||||
if (response.payload != null) {
|
||||
|
||||
@@ -24,6 +24,7 @@ class HomeCaptainController extends GetxController {
|
||||
Duration activeDuration = Duration.zero;
|
||||
Timer? activeTimer;
|
||||
Map data = {};
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
bool isLoading = true;
|
||||
late double kazan = 0;
|
||||
double latePrice = 0;
|
||||
@@ -69,6 +70,19 @@ class HomeCaptainController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 35), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.asset(
|
||||
config,
|
||||
'assets/images/car.png',
|
||||
// mipmaps: false,
|
||||
).then((value) {
|
||||
carIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
String stringActiveDuration = '';
|
||||
void onButtonSelected() {
|
||||
// totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
@@ -170,15 +184,23 @@ class HomeCaptainController extends GetxController {
|
||||
// CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
// );
|
||||
// }
|
||||
GoogleMapController? mapHomeCaptainController; // Initialize to null
|
||||
GoogleMapController? mapHomeCaptainController; // Nullable controller
|
||||
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
mapHomeCaptainController = controller;
|
||||
controller.getVisibleRegion();
|
||||
// Animate camera to user location (optional)
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
|
||||
// Optional: Check if the controller is still null (just for safety)
|
||||
if (mapHomeCaptainController != null) {
|
||||
// Get the visible region
|
||||
controller.getVisibleRegion();
|
||||
|
||||
// Animate camera to user location (optional)
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
} else {
|
||||
print("Controller is null, cannot proceed.");
|
||||
}
|
||||
}
|
||||
|
||||
void savePeriod(Duration period) {
|
||||
@@ -223,6 +245,7 @@ class HomeCaptainController extends GetxController {
|
||||
await getlocation();
|
||||
onButtonSelected();
|
||||
getDriverRate();
|
||||
addCustomCarIcon();
|
||||
getKazanPercent();
|
||||
getPaymentToday();
|
||||
getCountRideToday();
|
||||
|
||||
@@ -105,8 +105,8 @@ class MapDriverController extends GetxController {
|
||||
late LatLng latLngPassengerDestination = LatLng(0, 0);
|
||||
|
||||
void onMapCreated(GoogleMapController controller) async {
|
||||
myLocation = Get.find<LocationController>().location as LatLng;
|
||||
myLocation = myLocation;
|
||||
myLocation = Get.find<LocationController>().myLocation;
|
||||
// myLocation = myLocation;
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
@@ -454,9 +454,10 @@ class MapDriverController extends GetxController {
|
||||
}
|
||||
|
||||
addWaitingTimeCostFromPassengerToDriverWallet() async {
|
||||
double distance2 = calculateDistanceBetweenDriverAndPassengerLocation();
|
||||
double distance2 =
|
||||
await calculateDistanceBetweenDriverAndPassengerLocation();
|
||||
|
||||
if (distance2 > 40) {
|
||||
if (distance2 > 60) {
|
||||
Get.defaultDialog(
|
||||
title: 'Your are far from passenger location'.tr,
|
||||
middleText:
|
||||
@@ -893,12 +894,11 @@ class MapDriverController extends GetxController {
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio
|
||||
// scale: 1.0,
|
||||
);
|
||||
size: const Size(30, 35), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.asset(
|
||||
config,
|
||||
'assets/images/car.png',
|
||||
// mipmaps: false,
|
||||
).then((value) {
|
||||
carIcon = value;
|
||||
update();
|
||||
@@ -999,11 +999,10 @@ class MapDriverController extends GetxController {
|
||||
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
|
||||
|
||||
// Create the LatLngBounds object
|
||||
LatLngBounds boundsData =
|
||||
LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
boundsData = LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 140);
|
||||
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData!, 140);
|
||||
mapController!.animateCamera(cameraUpdate);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -161,12 +161,25 @@ class MyTranslation extends Translations {
|
||||
"You dont have money in your Wallet": "ليس لديك أموال في محفظتك",
|
||||
"You dont have money in your Wallet or you should less transfer 5 LE to activate":
|
||||
"ليس لديك أموال في محفظتك أو يجب عليك تحويل 5 جنيهات على الأقل لتفعيل الحساب",
|
||||
'I Arrive': "لقد وصلت",
|
||||
'Rejected Orders Count': "عدد الطلبات المرفوضة",
|
||||
'This is the total number of rejected orders per day after accepting the orders':
|
||||
'هذا هو العدد الإجمالي للطلبات المرفوضة يوميًا بعد قبول الطلبات',
|
||||
'You are not near the passenger location':
|
||||
"أنت لست بالقرب من موقع الراكب",
|
||||
'If you need assistance, contact us':
|
||||
"إذا كنت بحاجة إلى المساعدة، تواصل معنا",
|
||||
'You Can Cancel the Trip and get Cost From ':
|
||||
"يمكنك إلغاء الرحلة والحصول على التكلفة من",
|
||||
'Please go to the pickup location exactly':
|
||||
"يرجى الذهاب إلى موقع الالتقاط بالضبط",
|
||||
"Approaching your area. Should be there in 3 minutes.":
|
||||
"اقترب من منطقتك. يجب أن أكون هناك خلال 3 دقائق.",
|
||||
"There's heavy traffic here. Can you suggest an alternate pickup point?":
|
||||
"هناك حركة مرور كثيفة هنا. هل يمكنك اقتراح نقطة استلام بديلة؟",
|
||||
"This ride is already taken by another driver.":
|
||||
"تم حجز هذه الرحلة من قبل سائق آخر.",
|
||||
'Type Any thing': "اكتب أي شيء",
|
||||
'Price: ': 'السعر ',
|
||||
'Add Question': "أضف سؤالاً",
|
||||
"Please enter a valid card 16-digit number.":
|
||||
|
||||
Reference in New Issue
Block a user