25-3/18/1

This commit is contained in:
Hamza-Ayed
2025-03-18 13:54:27 +03:00
parent 6e77dec65f
commit 153d2f64c0
1307 changed files with 9505 additions and 528 deletions

0
lib/controller/auth/captin/history_captain.dart Normal file → Executable file
View File

185
lib/controller/auth/captin/invit_controller.dart Normal file → Executable file
View File

@@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:local_auth/local_auth.dart';
import 'package:sefer_driver/constant/box_name.dart';
import 'package:sefer_driver/constant/links.dart';
import 'package:sefer_driver/controller/firebase/local_notification.dart';
@@ -153,55 +154,79 @@ Download the Tripz app now and enjoy your ride!
: 'You deserve the gift'.tr,
'${EncryptionHelper.instance.decryptData(driverInvitationData[index]['invitorName'])} ${(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
() async {
bool isAvailable = await LocalAuthentication().isDeviceSupported();
if (int.parse((driverInvitationData[index]['countOfInvitDriver'])) <
100) {
Get.back();
} else {
//claim your gift
if ((driverInvitationData[index]['isGiftToken']).toString() == '0') {
Get.back();
await CRUD().post(link: AppLink.updateInviteDriver, payload: {
'id': EncryptionHelper.instance
.encryptData(driverInvitationData[index]['id'])
});
await Get.find<CaptainWalletController>().addDriverPayment(
'paymentMethod',
EncryptionHelper.instance.encryptData('500'),
'',
);
// add for invitor too
await Get.find<CaptainWalletController>().addDriverWalletToInvitor(
'paymentMethod',
EncryptionHelper.instance
.encryptData(driverInvitationData[index]['driverInviterId']),
EncryptionHelper.instance.encryptData('500'),
);
await Get.find<CaptainWalletController>().addSeferWallet(
'giftInvitation',
EncryptionHelper.instance.encryptData('-1000'));
NotificationCaptainController().addNotificationCaptain(
driverInvitationData[index]['driverInviterId'].toString(),
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'LE'}',
false);
NotificationController().showNotification(
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'LE'}',
'tone1',
'');
} else
//claim your gift
if (isAvailable) {
// Authenticate the user
bool didAuthenticate = await LocalAuthentication().authenticate(
localizedReason: 'Use Touch ID or Face ID to confirm payment',
options: AuthenticationOptions(
biometricOnly: true,
sensitiveTransaction: true,
));
if (didAuthenticate) {
if ((driverInvitationData[index]['isGiftToken']).toString() ==
'0') {
Get.back();
await CRUD().post(link: AppLink.updateInviteDriver, payload: {
'id': EncryptionHelper.instance
.encryptData(driverInvitationData[index]['id'])
});
await Get.find<CaptainWalletController>().addDriverPayment(
'paymentMethod',
('500'),
'',
);
// add for invitor too
await Get.find<CaptainWalletController>()
.addDriverWalletToInvitor(
'paymentMethod',
EncryptionHelper.instance.encryptData(
driverInvitationData[index]['driverInviterId']),
('500'),
);
await Get.find<CaptainWalletController>()
.addSeferWallet('giftInvitation', ('-1000'));
NotificationCaptainController().addNotificationCaptain(
driverInvitationData[index]['driverInviterId'].toString(),
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'LE'}',
false);
NotificationController().showNotification(
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'LE'}',
'tone1',
'');
} else {
Get.back();
MyDialog().getDialog("You have got a gift".tr,
"Share the app with another new driver".tr, () {
Get.back();
});
}
} else {
Get.back();
MyDialog().getDialog("You have got a gift".tr,
"Share the app with another new driver".tr, () {
// Authentication failed, handle accordingly
MyDialog().getDialog('Authentication failed'.tr, ''.tr, () {
Get.back();
});
}
} else {
MyDialog().getDialog('Biometric Authentication'.tr,
'You should use Touch ID or Face ID to confirm payment'.tr, () {
Get.back();
});
}
},
);
}
void onSelectPassengerInvitation(int index) async {
bool isAvailable = await LocalAuthentication().isDeviceSupported();
MyDialog().getDialog(
int.parse(driverInvitationDataToPassengers[index]['countOfInvitDriver']
.toString()) <
@@ -215,43 +240,61 @@ Download the Tripz app now and enjoy your ride!
.toString()) <
3) {
Get.back();
} else {
// Claim the gift if 100 trips are completed
if (driverInvitationDataToPassengers[index]['isGiftToken']
.toString() ==
'0') {
Get.back();
// Add wallet to the inviter
await Get.find<CaptainWalletController>()
.addDriverWallet('paymentMethod', '50', '50');
// add for invitor too
await Get.find<CaptainWalletController>().addDriverWalletToInvitor(
'paymentMethod',
driverInvitationData[index]['driverInviterId'],
'50');
// Update invitation as claimed
await CRUD().post(
link: AppLink.updatePassengerGift,
payload: {'id': driverInvitationDataToPassengers[index]['id']},
);
// Notify the inviter
NotificationCaptainController().addNotificationCaptain(
driverInvitationDataToPassengers[index]['passengerInviterId']
.toString(),
"You have got a gift for invitation".tr,
'${"You have 50".tr} ${'LE'}',
false,
);
} else if (isAvailable) {
// Authenticate the user
bool didAuthenticate = await LocalAuthentication().authenticate(
localizedReason: 'Use Touch ID or Face ID to confirm payment',
options: AuthenticationOptions(
biometricOnly: true,
sensitiveTransaction: true,
));
if (didAuthenticate) {
// Claim the gift if 100 trips are completed
if (driverInvitationDataToPassengers[index]['isGiftToken']
.toString() ==
'0') {
Get.back();
// Add wallet to the inviter
await Get.find<CaptainWalletController>()
.addDriverWallet('paymentMethod', '50', '50');
// add for invitor too
await Get.find<CaptainWalletController>()
.addDriverWalletToInvitor('paymentMethod',
driverInvitationData[index]['driverInviterId'], '50');
// Update invitation as claimed
await CRUD().post(
link: AppLink.updatePassengerGift,
payload: {'id': driverInvitationDataToPassengers[index]['id']},
);
// Notify the inviter
NotificationCaptainController().addNotificationCaptain(
driverInvitationDataToPassengers[index]['passengerInviterId']
.toString(),
"You have got a gift for invitation".tr,
'${"You have 50".tr} ${'LE'}',
false,
);
} else {
Get.back();
MyDialog().getDialog(
"You have got a gift".tr,
"Share the app with another new passenger".tr,
() {
Get.back();
},
);
}
} else {
Get.back();
MyDialog().getDialog(
"You have got a gift".tr,
"Share the app with another new passenger".tr,
() {
Get.back();
},
);
// Authentication failed, handle accordingly
MyDialog().getDialog('Authentication failed'.tr, ''.tr, () {
Get.back();
});
}
} else {
MyDialog().getDialog('Biometric Authentication'.tr,
'You should use Touch ID or Face ID to confirm payment'.tr, () {
Get.back();
});
}
},
);

55
lib/controller/auth/captin/login_captin_controller.dart Normal file → Executable file
View File

@@ -102,18 +102,23 @@ class LoginDriverController extends GetxController {
} else {
await SecurityChecks.isDeviceRootedFromNative(Get.context!);
}
String fingerPrint = await getDeviceFingerprint();
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
dev = Platform.isAndroid ? 'android' : 'ios';
var payload = {
'id': box.read(BoxName.passengerID),
'id': box.read(BoxName.driverID),
'password': AK.passnpassenger,
'aud': '${AK.allowed}$dev',
'aud': '${AK.allowedWallet}$dev',
'fingerPrint': fingerPrint
};
var response1 = await http.post(
Uri.parse(AppLink.loginJwtWalletDriver),
body: payload,
);
Log.print('response.request: ${response1.request}');
Log.print('response.body: ${response1.body}');
print(payload);
Log.print(
'jsonDecode(response1.body)["jwt"]: ${jsonDecode(response1.body)['jwt']}');
return jsonDecode(response1.body)['jwt'].toString();
}
@@ -155,6 +160,7 @@ class LoginDriverController extends GetxController {
} else {}
} else {
await EncryptionHelper.initialize();
var emailDecrypted = (box.read(BoxName.emailDriver));
var pass = passwordController.text.isEmpty
? '$emailDecrypted${box.read(BoxName.driverID)}'
@@ -246,7 +252,10 @@ class LoginDriverController extends GetxController {
if (jsonDecoeded.isNotEmpty) {
if (jsonDecoeded['status'] == 'success' &&
jsonDecoeded['data'][0]['is_verified'].toString() == '1') {
box.write(BoxName.emailDriver, (jsonDecoeded['data'][0]['email']));
box.write(
BoxName.emailDriver,
EncryptionHelper.instance
.decryptData(jsonDecoeded['data'][0]['email']));
box.write(BoxName.firstTimeLoadKey, 'false');
box.write(BoxName.driverID, (jsonDecoeded['data'][0]['id']));
box.write(BoxName.isTest, '1');
@@ -302,11 +311,12 @@ class LoginDriverController extends GetxController {
link: AppLink.getDriverToken,
payload: {'captain_id': (box.read(BoxName.driverID)).toString()});
String? fingerPrint = await DeviceHelper.getDeviceFingerprint();
await storage.write(key: BoxName.fingerPrint, value: fingerPrint);
if (token != 'failure') {
if (EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token']) !=
EncryptionHelper.instance
.decryptData(box.read(BoxName.tokenDriver))) {
if ((jsonDecode(token)['data'][0]['token']) !=
(box.read(BoxName.tokenDriver))) {
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
@@ -315,7 +325,7 @@ class LoginDriverController extends GetxController {
.toString(),
[],
'promo.wav');
Get.defaultDialog(
await Get.defaultDialog(
title: 'you will use this device?'.tr,
middleText: '',
confirm: MyElevatedButton(
@@ -324,7 +334,8 @@ class LoginDriverController extends GetxController {
await CRUD()
.post(link: AppLink.addTokensDriver, payload: {
'token': (box.read(BoxName.tokenDriver)),
'captain_id': (box.read(BoxName.driverID)).toString()
'captain_id': (box.read(BoxName.driverID)).toString(),
'fingerPrint': (fingerPrint).toString()
});
await CRUD().post(
link:
@@ -332,7 +343,8 @@ class LoginDriverController extends GetxController {
payload: {
'token': (box.read(BoxName.tokenDriver)),
'captain_id':
(box.read(BoxName.driverID)).toString()
(box.read(BoxName.driverID)).toString(),
'fingerPrint': (fingerPrint).toString()
});
// await CRUD().post(
// link:
@@ -372,8 +384,7 @@ class LoginDriverController extends GetxController {
'email': EncryptionHelper.instance.encryptData(email),
'password': password,
});
box.write(BoxName.emailDriver,
EncryptionHelper.instance.decryptData(email).toString());
box.write(BoxName.emailDriver, (email).toString());
print(res);
if (res == 'failure') {
//Failure
@@ -439,15 +450,16 @@ class LoginDriverController extends GetxController {
}
updateAppTester(AppInformation.appName);
var fingerPrint = DeviceHelper.getDeviceFingerprint().toString();
await storage.write(key: BoxName.fingerPrint, value: fingerPrint);
var token = await CRUD().get(
link: AppLink.getDriverToken,
payload: {'captain_id': box.read(BoxName.driverID).toString()});
if (token != 'failure') {
if (EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token']) !=
EncryptionHelper.instance
.decryptData(box.read(BoxName.tokenDriver))) {
if ((jsonDecode(token)['data'][0]['token']) !=
(box.read(BoxName.tokenDriver))) {
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
@@ -465,7 +477,8 @@ class LoginDriverController extends GetxController {
await CRUD()
.post(link: AppLink.addTokensDriver, payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id': box.read(BoxName.driverID).toString()
'captain_id': box.read(BoxName.driverID).toString(),
'fingerPrint': (fingerPrint).toString()
});
await CRUD().post(
link:
@@ -473,7 +486,8 @@ class LoginDriverController extends GetxController {
payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id':
box.read(BoxName.driverID).toString()
box.read(BoxName.driverID).toString(),
'fingerPrint': (fingerPrint).toString()
});
await CRUD().post(
link:
@@ -481,7 +495,8 @@ class LoginDriverController extends GetxController {
payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id':
box.read(BoxName.driverID).toString()
box.read(BoxName.driverID).toString(),
'fingerPrint': (fingerPrint).toString()
});
Get.back();
}));

0
lib/controller/auth/captin/ml_google_doc.dart Normal file → Executable file
View File

View File