Update: 2026-06-11 18:22:57

This commit is contained in:
Hamza-Ayed
2026-06-11 18:22:59 +03:00
parent c5170a88d2
commit 727068b668
629 changed files with 46050 additions and 46109 deletions

View File

@@ -1,3 +1,4 @@
import 'package:siro_driver/constant/currency.dart';
import 'dart:convert';
import 'dart:developer';
@@ -10,6 +11,8 @@ import 'package:siro_driver/constant/box_name.dart';
import 'package:siro_driver/constant/links.dart';
import 'package:siro_driver/controller/functions/crud.dart';
import 'package:siro_driver/controller/home/payment/captain_wallet_controller.dart';
import 'package:siro_driver/print.dart';
import 'package:siro_driver/controller/functions/country_logic.dart';
import 'package:siro_driver/main.dart';
import 'package:siro_driver/views/widgets/error_snakbar.dart';
import 'package:siro_driver/views/widgets/mydialoug.dart';
@@ -299,7 +302,7 @@ Download the Siro app now and enjoy your ride!
/// **FIX**: Added the missing 'selectPhone' method.
void selectPhone(String phone) {
// Format the selected phone number and update the text field.
invitePhoneController.text = _formatSyrianPhoneNumber(phone);
invitePhoneController.text = CountryLogic.formatCurrentCountryPhone(phone);
update();
Get.back(); // Close the contacts dialog after selection.
}
@@ -357,30 +360,30 @@ Download the Siro app now and enjoy your ride!
if ((driverInvitationData[index]['isGiftToken']).toString() ==
'0') {
Get.back();
await CRUD().post(
link: AppLink.updateInviteDriver,
payload: {'id': (driverInvitationData[index]['id'])});
await Get.find<CaptainWalletController>().addDriverPayment(
'paymentMethod',
('500'),
'',
// Server-side claim validation
var response = await CRUD().post(
link: AppLink.claimInviteReward,
payload: {
'invite_id': (driverInvitationData[index]['id']).toString(),
'driver_id': box.read(BoxName.driverID).toString(),
'country_code': box.read(BoxName.countryCode).toString(),
}
);
await Get.find<CaptainWalletController>()
.addDriverWalletToInvitor(
'paymentMethod',
(driverInvitationData[index]['driverInviterId']),
('500'),
);
NotificationCaptainController().addNotificationCaptain(
driverInvitationData[index]['driverInviterId'].toString(),
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'SYP'.tr}',
false);
NotificationController().showNotification(
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'SYP'.tr}',
'tone1',
'');
if (response != 'failure') {
var data = jsonDecode(response);
if (data['status'] == 'success') {
NotificationController().showNotification(
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${CurrencyHelper.currency}',
'tone1',
'');
// refresh stats
fetchDriverStats();
} else {
mySnackeBarError(data['message'] ?? 'Claim failed'.tr);
}
}
} else {
Get.back();
MyDialog().getDialog("You have got a gift".tr,
@@ -440,7 +443,7 @@ Download the Siro app now and enjoy your ride!
driverInvitationDataToPassengers[index]['passengerInviterId']
.toString(),
"You have got a gift for invitation".tr,
'${"You have 200".tr} ${'SYP'.tr}',
'${"You have 200".tr} ${CurrencyHelper.currency}',
false,
);
} else {
@@ -465,47 +468,7 @@ Download the Siro app now and enjoy your ride!
);
}
/// Formats a phone number to the standard Syrian international format (+963...).
String _formatSyrianPhoneNumber(String input) {
String digitsOnly = input.replaceAll(RegExp(r'\D'), '');
if (digitsOnly.startsWith('09') && digitsOnly.length == 10) {
return '963${digitsOnly.substring(1)}';
}
if (digitsOnly.length == 9 && digitsOnly.startsWith('9')) {
return '963$digitsOnly';
}
return input; // Fallback for unrecognized formats
}
String normalizeSyrianPhone(String input) {
String phone = input.trim();
// احذف كل شيء غير أرقام
phone = phone.replaceAll(RegExp(r'[^0-9]'), '');
// إذا يبدأ بـ 0 → احذفها
if (phone.startsWith('0')) {
phone = phone.substring(1);
}
// إذا يبدأ بـ 963 مكررة → احذف التكرار
while (phone.startsWith('963963')) {
phone = phone.substring(3);
}
// إذا يبدأ بـ 963 ولكن داخله كمان 963 → خليه مرة واحدة فقط
if (phone.startsWith('963') && phone.length > 12) {
phone = phone.substring(phone.length - 9); // آخر 9 أرقام
}
// الآن إذا كان بلا 963 → أضفها
if (!phone.startsWith('963')) {
phone = '963' + phone;
}
return phone;
}
// removed normalizeSyrianPhone
/// Sends an invitation to a potential new driver.
void sendInvite() async {
@@ -513,9 +476,8 @@ Download the Siro app now and enjoy your ride!
mySnackeBarError('Please enter a phone number'.tr);
return;
}
// Format Syrian phone number: remove leading 0 and add +963
String formattedPhoneNumber =
normalizeSyrianPhone(invitePhoneController.text);
CountryLogic.formatCurrentCountryPhone(invitePhoneController.text);
if (formattedPhoneNumber.length != 12) {
mySnackeBarError('Please enter a correct phone'.tr);
return;
@@ -553,12 +515,7 @@ Download the Siro app now and enjoy your ride!
return;
}
// Format Syrian phone number: remove leading 0 and add +963
String formattedPhoneNumber = invitePhoneController.text.trim();
if (formattedPhoneNumber.startsWith('0')) {
formattedPhoneNumber = formattedPhoneNumber.substring(1);
}
formattedPhoneNumber = '+963$formattedPhoneNumber';
String formattedPhoneNumber = CountryLogic.formatCurrentCountryPhone(invitePhoneController.text);
if (formattedPhoneNumber.length < 12) {
// +963 + 9 digits = 12+