This commit is contained in:
Hamza-Ayed
2024-06-30 12:35:55 +03:00
parent 6fb79baab4
commit d423cc0831
27 changed files with 517 additions and 452 deletions

View File

@@ -4,6 +4,7 @@ import 'dart:math';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/controller/functions/location_background_controller.dart';
import 'package:SEFER/views/auth/captin/cards/sms_signup.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:get/get.dart';
@@ -48,68 +49,6 @@ class LoginDriverController extends GetxController {
update();
}
void login() async {
isloading = true;
update();
var res = await CRUD().get(link: AppLink.loginCaptin, payload: {
'email': emailController.text,
'phone': phoneController.text,
'password': passwordController.text
});
if (res == 'failure') {
//Failure
isloading = false;
update();
Get.snackbar('Failure', '', backgroundColor: Colors.red);
} else {
var jsonDecoeded = jsonDecode(res);
if (jsonDecoeded.isNotEmpty) {
if (jsonDecoeded['status'] == 'success') {
if (jsonDecoeded['data'][0]['verified'] == 1) {
box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']);
box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']);
box.write(
BoxName.nameDriver, jsonDecoeded['data'][0]['first_name']);
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
SecureStorage()
.saveData(BoxName.passwordDriver, passwordController.text);
Get.offAll(() => HomeCaptain());
isloading = false;
update();
await CRUD().post(link: AppLink.addTokensDriver, payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id': box.read(BoxName.driverID).toString()
});
} else {
isloading = false;
update();
Get.defaultDialog(
title: 'You must Verify email !.'.tr,
middleText: '',
backgroundColor: Colors.yellow[300],
onConfirm: () async {
int randomNumber = Random().nextInt(100000) + 1;
await CRUD().post(link: AppLink.sendVerifyEmail, payload: {
'email': emailController.text,
'token': randomNumber.toString(),
});
Get.to(() => VerifyEmailCaptainPage());
},
);
}
} else if (jsonDecoeded['status'] == 'Failure') {
Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'],
backgroundColor: Colors.redAccent);
isloading = false;
update();
}
} else {
isloading = false;
update();
}
}
}
loginUsingCredentials(String driverID, email) async {
isloading = true;
update();
@@ -129,6 +68,7 @@ class LoginDriverController extends GetxController {
if (jsonDecoeded['status'] == 'success' &&
jsonDecoeded['data'][0]['is_verified'] == 1) {
box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']);
box.write(BoxName.gender, jsonDecoeded['data'][0]['gender']);
box.write(BoxName.phoneVerified,
jsonDecoeded['data'][0]['is_verified'].toString());
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
@@ -150,14 +90,23 @@ class LoginDriverController extends GetxController {
box.read(BoxName.tokenDriver)) {
Get.put(FirebaseMessagesController())
.sendNotificationToAnyWithoutData(
'token change',
'change device',
jsonDecode(token)['data'][0]['token'].toString(),
);
await CRUD().post(link: AppLink.addTokensDriver, payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id': box.read(BoxName.driverID).toString()
});
'token change'.tr,
'change device'.tr,
jsonDecode(token)['data'][0]['token'].toString(),
'promo.wav');
Get.defaultDialog(
title: 'you will use this device?'.tr,
middleText: '',
confirm: MyElevatedButton(
title: 'Ok'.tr,
onPressed: () async {
await CRUD()
.post(link: AppLink.addTokensDriver, payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id': box.read(BoxName.driverID).toString()
});
Get.back();
}));
}
}
@@ -184,13 +133,4 @@ class LoginDriverController extends GetxController {
'captain_id': box.read(BoxName.driverID).toString()
});
}
@override
void onInit() async {
super.onInit();
// if (box.read(BoxName.driverID).toString() != null) {
// loginByBoxData();
// }
}
}

View File

@@ -111,12 +111,14 @@ class RegisterCaptainController extends GetxController {
box.write(BoxName.phoneDriver, '+2${phoneController.text}');
box.write(BoxName.phoneVerified, 1);
var res1 = await CRUD().post(
link: AppLink.updateAccountBank,
payload: {'phone': '+2${phoneController.text}'});
if (jsonDecode(res1)['status'] == 'success') {
Get.to(EgyptCardAI());
}
// var res1 = await CRUD().post(
// link: AppLink.updateAccountBank,
// payload: {'phone': '+2${phoneController.text}'});
// if (res1 != 'failure') {
Get.to(EgyptCardAI());
// } else {
// Get.snackbar('title', 'message');
// }
}
}
}

View File

@@ -90,9 +90,9 @@ class FirebaseMessagesController extends GetxController {
}
void fireBaseTitles(RemoteMessage message) {
if (message.notification!.title! == 'Order') {
if (message.notification!.title! == 'Order'.tr) {
if (Platform.isAndroid) {
NotificationController().showNotification('Order', '', 'order');
NotificationController().showNotification('Order'.tr, '', 'order');
}
var myListString = message.data['DriverList'];
// var points = message.data['PolylineJson'];
@@ -109,27 +109,27 @@ class FirebaseMessagesController extends GetxController {
// 'PolylineJson': myPoints,
'body': message.notification!.body
});
} else if (message.notification!.title == 'Cancel Trip') {
} else if (message.notification!.title == 'Cancel Trip'.tr) {
NotificationController().showNotification(
'Cancel Trip'.tr, 'Passenger Cancel Trip'.tr, 'cancel');
cancelTripDialog();
} else if (message.notification!.title! == 'token change') {
} else if (message.notification!.title! == 'token change'.tr) {
NotificationController()
.showNotification('token change', 'token change', 'cancel');
.showNotification('token change'.tr, 'token change', 'cancel');
GoogleSignInHelper.signOut();
} else if (message.notification!.title! == 'message From passenger') {
} else if (message.notification!.title! == 'message From passenger'.tr) {
NotificationController()
.showNotification('message From passenger'.tr, ''.tr, 'tone2');
passengerDialog(message.notification!.body!);
update();
} else if (message.notification!.title! == 'Hi ,I will go now') {
} else if (message.notification!.title! == 'Hi ,I will go now'.tr) {
// Get.snackbar('Hi ,I will go now', '',
// backgroundColor: AppColor.greenColor);
NotificationController().showNotification(
'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'tone2');
update();
} else if (message.notification!.title! == 'Call Income') {
} else if (message.notification!.title! == 'Call Income'.tr) {
try {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
@@ -147,7 +147,8 @@ class FirebaseMessagesController extends GetxController {
// remoteID: driverList[2].toString(),
// ));
} catch (e) {}
} else if (message.notification!.title! == 'Call Income from Passenger') {
} else if (message.notification!.title! ==
'Call Income from Passenger'.tr) {
try {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
@@ -165,7 +166,7 @@ class FirebaseMessagesController extends GetxController {
// remoteID: driverList[2].toString(),
));
} catch (e) {}
} else if (message.notification!.title! == 'Call End') {
} else if (message.notification!.title! == 'Call End'.tr) {
try {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
@@ -179,7 +180,7 @@ class FirebaseMessagesController extends GetxController {
// Assuming GetMaterialApp is initialized and context is valid for navigation
Get.off(const CallPage());
} catch (e) {}
} else if (message.notification!.title! == 'Order Applied') {
} else if (message.notification!.title! == 'Order Applied'.tr) {
Get.snackbar(
"The order has been accepted by another driver."
.tr, // Corrected grammar
@@ -202,7 +203,7 @@ class FirebaseMessagesController extends GetxController {
// 'PolylineJson': myPoints,
'body': message.notification!.body
});
} else if (message.notification!.title! == 'Order Applied') {
} else if (message.notification!.title! == 'Order Applied'.tr) {
NotificationController().showNotification(
'The order Accepted by another Driver'.tr,
'We regret to inform you that another driver has accepted this order.'
@@ -361,7 +362,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'start.wav'
'sound': 'ding.wav'
},
'priority': 'high',
'data': <String, dynamic>{
@@ -404,7 +405,7 @@ class FirebaseMessagesController extends GetxController {
// }
//android/app/src/main/res/raw/iphone_ringtone.wav
void sendNotificationToPassengerToken(
String title, body, token, List<String> map) async {
String title, body, token, List<String> map, String tone) async {
try {
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -416,7 +417,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'tone2.wav'
'sound': tone
},
'data': {
'passengerList': map,
@@ -472,7 +473,7 @@ class FirebaseMessagesController extends GetxController {
}
void sendNotificationToAnyWithoutData(
String title, String body, String token) async {
String title, String body, String token, String tone) async {
try {
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -484,7 +485,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'promo.wav'
'sound': tone
},
'data': <String, dynamic>{
'click_action': 'FLUTTER_NOTIFICATION_CLICK',
@@ -507,8 +508,8 @@ class FirebaseMessagesController extends GetxController {
}
}
void sendNotificationToDriverMAP(
String title, String body, String token, List<String> data) async {
void sendNotificationToDriverMAP(String title, String body, String token,
List<String> data, String tone) async {
try {
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -521,7 +522,7 @@ class FirebaseMessagesController extends GetxController {
'title': title,
'body': body,
// 'sound': 'tone2.wav',
'sound': 'order.wav'
'sound': tone
},
'data': {
'DriverList': data,

View File

@@ -98,6 +98,7 @@ class CRUD {
await arabicTextExtractByVisionAndAI(imagePath: imagePath);
var json = jsonDecode(extractedString);
var textValues = extractTextFromLines(json);
print(textValues);
// await Get.put(AI()).geminiAiExtraction(prompt, textValues);
await Get.put(AI()).anthropicAI(textValues, prompt, imagePath);
}
@@ -129,8 +130,9 @@ class CRUD {
};
String imagePathFull =
'${AppLink.server}card_image/$imagePath-${box.read(BoxName.driverID)}.jpg';
'${AppLink.server}/card_image/$imagePath-${box.read(BoxName.driverID)}.jpg';
// print(box.read(BoxName.driverID));
// print(imagePathFull);
var request = http.Request('POST', Uri.parse(
// 'https://ocrhamza.cognitiveservices.azure.com/vision/v2.1/ocr?language=ar'));
// 'https://eastus.api.cognitive.microsoft.com/vision/v3.2/ocr'
@@ -141,6 +143,7 @@ class CRUD {
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
// print(await response.stream.bytesToString());
return await response.stream.bytesToString();
} else {}
}
@@ -218,7 +221,9 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
},
);
print(response.request);
print(response.body);
print(response.statusCode);
var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
if (jsonData['status'] == 'success') {

View File

@@ -393,10 +393,13 @@ class AI extends GetxController {
update();
await ImageController().choosImage(linkPHP, imagePath);
Future.delayed(const Duration(seconds: 2));
// print(imagePath);
var extractedString =
await CRUD().arabicTextExtractByVisionAndAI(imagePath: imagePath);
print(extractedString);
var json = jsonDecode(extractedString);
var textValues = CRUD().extractTextFromLines(json);
print(textValues);
// await Get.put(AI()).geminiAiExtraction(prompt, textValues, imagePath);
await Get.put(AI()).anthropicAI(textValues, prompt, imagePath);
isLoading = false;

View File

@@ -7,6 +7,14 @@ void showInBrowser(String url) async {
} else {}
}
Future<void> makePhoneCall(String phoneNumber) async {
final Uri launchUri = Uri(
scheme: 'tel',
path: phoneNumber,
);
await launchUrl(launchUri);
}
void launchCommunication(
String method, String contactInfo, String message) async {
String url;

View File

@@ -54,6 +54,7 @@ class ImageController extends GetxController {
update();
// Save the cropped image
File savedCroppedImage = File(croppedFile!.path);
print('link =$link');
try {
await uploadImage(
savedCroppedImage,

View File

@@ -222,7 +222,8 @@ class MapDriverController extends GetxController {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'DriverIsGoingToPassenger',
box.read(BoxName.name).toString(),
tokenPassenger);
tokenPassenger,
'start.wav');
if (box.read(BoxName.googlaMapApp) == true) {
await openGoogleMapFromDriverToPassenger();
}
@@ -288,7 +289,10 @@ class MapDriverController extends GetxController {
});
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
'RideIsBegin',
box.read(BoxName.name).toString(),
tokenPassenger,
'start.wav');
rideIsBeginPassengerTimer();
// var d = jsonDecode(res);
@@ -352,6 +356,7 @@ class MapDriverController extends GetxController {
}
calculateDistanceBetweenDriverAndPassengerLocation() {
Get.put(LocationController());
double distance2 = Geolocator.distanceBetween(
latLngPassengerLocation.latitude,
latLngPassengerLocation.longitude,
@@ -533,19 +538,19 @@ class MapDriverController extends GetxController {
});
Future.delayed(const Duration(milliseconds: 300));
FirebaseMessagesController().sendNotificationToPassengerToken(
'Driver Finish Trip',
'${'you will pay to Driver'.tr} $paymentAmount \$',
tokenPassenger,
[
box.read(BoxName.driverID),
rideId,
box.read(BoxName.tokenDriver),
// carType == 'Comfort' || carType == 'Mashwari'
// ? price.toStringAsFixed(2)
// : totalPassenger
paymentAmount.toString()
],
);
'Driver Finish Trip',
'${'you will pay to Driver'.tr} $paymentAmount \$',
tokenPassenger,
[
box.read(BoxName.driverID),
rideId,
box.read(BoxName.tokenDriver),
// carType == 'Comfort' || carType == 'Mashwari'
// ? price.toStringAsFixed(2)
// : totalPassenger
paymentAmount.toString()
],
'ding.wav');
Get.to(() => RatePassenger(), arguments: {
'passengerId': passengerId,
'rideId': rideId,

View File

@@ -95,21 +95,29 @@ class OrderRequestController extends GetxController {
List<Map<String, dynamic>> results = await sql.getCustomQuery(customQuery);
}
void startTimer(String driverID, orderID) async {
for (int i = 0; i <= duration; i++) {
bool _timerActive = false;
Future<void> startTimer(String driverID, String orderID) async {
_timerActive = true;
for (int i = 0; i <= duration && _timerActive; i++) {
await Future.delayed(const Duration(seconds: 1));
progress = i / duration;
remainingTime = duration - i;
update();
}
if (remainingTime == 0) {
if (remainingTime == 0 && _timerActive) {
if (applied == false) {
endTimer();
refuseOrder(orderID);
}
}
}
void endTimer() {
_timerActive = false;
}
void startTimerSpeed(String driverID, orderID) async {
for (int i = 0; i <= durationSpeed; i++) {
await Future.delayed(const Duration(seconds: 1));
@@ -144,15 +152,16 @@ class OrderRequestController extends GetxController {
});
// applied = true;
sql.insertData({
'order_id': orderID,
'created_at': DateTime.now().toString(),
'driver_id': box.read(BoxName.driverID).toString(),
}, TableName.driverOrdersRefuse);
getRefusedOrderByCaptain();
if (box.read(BoxName.gender).toString() != 'Female') {
sql.insertData({
'order_id': orderID,
'created_at': DateTime.now().toString(),
'driver_id': box.read(BoxName.driverID).toString(),
}, TableName.driverOrdersRefuse);
getRefusedOrderByCaptain();
}
update();
Get.back();
// Get.back();
// Get.offAll(HomeCaptain());
}

View File

@@ -223,12 +223,12 @@ class CaptainWalletController extends GetxController {
});
if (res1 != 'failure') {
FirebaseMessagesController().sendNotificationToDriverMAP(
'Transfer',
'${'You have transfer to your wallet from'.tr}'
'${box.read(BoxName.nameDriver)}',
amountToNewDriverMap[0]['token'].toString(),
[],
);
'Transfer',
'${'You have transfer to your wallet from'.tr}'
'${box.read(BoxName.nameDriver)}',
amountToNewDriverMap[0]['token'].toString(),
[],
'order1.wav');
await addSeferWallet('payout fee', '5');
Get.defaultDialog(

View File

@@ -4,7 +4,16 @@ class MyTranslation extends Translations {
@override
Map<String, Map<String, String>> get keys => {
"ar": {
'Add Question': '',
"Heading your way now. Please be ready.":
"في طريقي إليك الآن. يرجى الاستعداد.",
"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.":
"تم حجز هذه الرحلة من قبل سائق آخر.",
'Price: ': 'السعر ',
'Add Question': "أضف سؤالاً",
"Please enter a valid card 16-digit number.":
"الرجاء إدخال رقم بطاقة صحيح مكون من 16 رقمًا.",
"Insert card number": "أدخل رقم البطاقة",
@@ -199,7 +208,7 @@ class MyTranslation extends Translations {
"Invalid OTP": "رمز التحقق غير صالح",
"Enter your email address": "أدخل عنوان بريدك الإلكتروني",
"Please enter Your Email.": "يُرجى إدخال...",
"Enter your phone number": "أدخلي رقم هاتفك",
"Enter your phone number": "أدخل رقم هاتفك",
"Please enter your phone number.": "الرجاء إدخال رقم هاتفك.",
"Please enter Your Password.": "إدخال كلمة المرور الخاصة بك",
"Submit": "إرسال",
@@ -284,7 +293,7 @@ class MyTranslation extends Translations {
"Send Verfication Code": "إرسال رمز التحقق",
"End Ride": "‏إنهاء الرحلة",
"Minute": "الدقيقة",
"Go to passenger Location now": "انتقل إلى موقع الراكب الآن",
"Go to passenger Location": "انتقل إلى موقع الراكب ",
"Duration of the Ride is": "مدة المشوار هي",
"Distance of the Ride is": "مسافة المشوار هي",
"Name of the Passenger is": "اسم الراكب هو",
@@ -375,7 +384,7 @@ class MyTranslation extends Translations {
"Driver Applied the Ride for You": "سائق قدم الرحلة من أجلك",
"Show latest promo": "أظهر أحدث عرض ترويجي",
"Cancel Trip": "إلغاء الرحلة",
"Passenger Cancel Trip": "راكب يلغي الرحلة",
"Passenger Cancel Trip": "الرحلة ألغيت من قبل المسافر",
"Please stay on the picked point.": "يرجى البقاء على النقطة المحددة.",
"Trip is Begin": "الرحلة بدأت",
"Hi ,I will go now": "مرحبًا، سأذهب الآن",

View File

@@ -54,7 +54,7 @@ class PassengerNotificationController extends GetxController {
'body': body,
});
FirebaseMessagesController()
.sendNotificationToPassengerToken(title, body, 'token', []);
.sendNotificationToPassengerToken(title, body, 'token', [], 'ding.wav');
}
@override

View File

@@ -83,13 +83,14 @@ class RateController extends GetxController {
'token': paymentToken4,
'driverID': box.read(BoxName.driverID).toString(),
});
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'Wallet Added'.tr,
'Wallet Added${(pointsSubtraction).toStringAsFixed(0)}'.tr,
Get.find<MapDriverController>().tokenPassenger,
'tone2.wav');
walletChecked = 'true';
}
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'Wallet Added',
'Wallet Added'.tr,
Get.find<MapDriverController>().tokenPassenger);
walletChecked = 'true';
update();
}
});