This commit is contained in:
Hamza-Ayed
2024-11-10 18:38:07 +02:00
parent c9ac8da2ec
commit e8c72d79a9
25 changed files with 1211 additions and 329 deletions

View File

@@ -187,12 +187,12 @@ class LoginDriverController extends GetxController {
if (token != 'failure') {
if (jsonDecode(token)['data'][0]['token'] !=
box.read(BoxName.tokenDriver)) {
Get.put(FirebaseMessagesController())
.sendNotificationToAnyWithoutData(
'token change'.tr,
'change device'.tr,
jsonDecode(token)['data'][0]['token'].toString(),
'promo.wav');
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
jsonDecode(token)['data'][0]['token'].toString(),
[],
'promo.wav');
Get.defaultDialog(
title: 'you will use this device?'.tr,
middleText: '',
@@ -316,12 +316,12 @@ class LoginDriverController extends GetxController {
if (token != 'failure') {
if (jsonDecode(token)['data'][0]['token'] !=
box.read(BoxName.tokenDriver)) {
Get.put(FirebaseMessagesController())
.sendNotificationToAnyWithoutData(
'token change'.tr,
'change device'.tr,
jsonDecode(token)['data'][0]['token'].toString(),
'promo.wav');
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
jsonDecode(token)['data'][0]['token'].toString(),
[],
'promo.wav');
Get.defaultDialog(
title: 'you will use this device?'.tr,
middleText: '',

View File

@@ -90,15 +90,28 @@ class GoogleSignInHelper {
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
if (googleUser != null) {
// Handle sign-up and store user information
await _handleSignUp(googleUser);
// Add detailed debug print statements
// Retrieve driverID and emailDriver with added validation
final driverID = box.read(BoxName.driverID)?.toString() ?? 'Unknown ID';
final emailDriver =
box.read(BoxName.emailDriver)?.toString() ?? 'Unknown Email';
// Debug print statements
print('Driver ID: $driverID');
print('Driver Email: $emailDriver');
// Check if driverID is a valid numeric string
// if (driverID != 'Unknown ID' && int.tryParse(driverID) != null) {
await Get.find<LoginDriverController>()
.loginUsingCredentials(driverID, emailDriver);
// }
// else {
// print('Invalid driverID format: $driverID');
// Get.snackbar('Login Error', 'Invalid driver ID format.',
// backgroundColor: AppColor.redColor);
// }
}
return googleUser;
@@ -110,6 +123,13 @@ class GoogleSignInHelper {
}
}
static Future<void> _handleSignUp(GoogleSignInAccount user) async {
// Store driver information
box.write(BoxName.driverID,
user.id ?? 'Unknown ID'); // Ensure there's a fallback value
box.write(BoxName.emailDriver, user.email ?? 'Unknown Email');
}
// Method to handle Google Sign-Out
static Future<void> signOut() async {
try {
@@ -145,16 +165,4 @@ class GoogleSignInHelper {
static GoogleSignInAccount? getCurrentUser() {
return _googleSignIn.currentUser;
}
// Method to handle sign-up process
static Future<void> _handleSignUp(GoogleSignInAccount user) async {
// Store driver information
box.write(BoxName.driverID, user.id);
box.write(BoxName.emailDriver, user.email);
// box.write(BoxName.nameDriver, user.displayName);
// box.write(BoxName.driverPhotoUrl, user.photoUrl);
// Perform any additional sign-up tasks or API calls here
// For example, you can send the user data to your server for registration
}
}