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+

View File

@@ -4,6 +4,7 @@ import 'package:siro_driver/controller/functions/crud.dart';
import 'package:siro_driver/print.dart';
import 'package:siro_driver/views/home/on_boarding_page.dart';
import 'package:siro_driver/views/widgets/error_snakbar.dart';
import 'package:siro_driver/controller/functions/country_logic.dart';
import '../../../constant/box_name.dart';
import '../../../constant/links.dart';
@@ -18,69 +19,12 @@ class PhoneAuthHelper {
static final String _sendOtpUrl = '${_baseUrl}sendWhatsAppDriver.php';
static final String _verifyOtpUrl = '${_baseUrl}verifyOtp.php';
static final String _registerUrl = '${_baseUrl}register_driver.php';
static String formatSyrianPhone(String phone) {
// Remove spaces, symbols, +, -, ()
phone = phone.replaceAll(RegExp(r'[ \-\(\)\+]'), '').trim();
// Normalize 00963 → 963
if (phone.startsWith('00963')) {
phone = phone.replaceFirst('00963', '963');
}
// Normalize 0963 → 963
if (phone.startsWith('0963')) {
phone = phone.replaceFirst('0963', '963');
}
if (phone.startsWith('096309')) {
phone = phone.replaceFirst('096309', '963');
}
// NEW: Fix 96309xxxx → 9639xxxx
if (phone.startsWith('96309')) {
phone = '9639' + phone.substring(5); // remove the "0" after 963
}
// If starts with 9630 → correct to 9639
if (phone.startsWith('9630')) {
phone = '9639' + phone.substring(4);
}
// If already in correct format: 9639xxxxxxxx
if (phone.startsWith('9639') && phone.length == 12) {
return phone;
}
// If starts with 963 but missing the 9
if (phone.startsWith('963') && phone.length > 3) {
// Ensure it begins with 9639
if (!phone.startsWith('9639')) {
phone = '9639' + phone.substring(3);
}
return phone;
}
// If starts with 09xxxxxxxx → 9639xxxxxxxx
if (phone.startsWith('09')) {
return '963' + phone.substring(1);
}
// If 9xxxxxxxx (9 digits)
if (phone.startsWith('9') && phone.length == 9) {
return '963' + phone;
}
// If starts with incorrect 0xxxxxxx → assume Syrian and fix
if (phone.startsWith('0') && phone.length == 10) {
return '963' + phone.substring(1);
}
return phone;
}
// removed formatSyrianPhone
/// Sends an OTP to the provided phone number.
static Future<bool> sendOtp(String phoneNumber) async {
try {
final fixedPhone = formatSyrianPhone(phoneNumber);
final fixedPhone = CountryLogic.formatCurrentCountryPhone(phoneNumber);
Log.print('fixedPhone: $fixedPhone');
final response = await CRUD().post(
@@ -112,7 +56,7 @@ class PhoneAuthHelper {
/// Verifies the OTP and logs the user in.
static Future<void> verifyOtp(String phoneNumber, String otpCode) async {
try {
final fixedPhone = formatSyrianPhone(phoneNumber);
final fixedPhone = CountryLogic.formatCurrentCountryPhone(phoneNumber);
Log.print('fixedPhone: $fixedPhone');
final response = await CRUD().post(
link: _verifyOtpUrl,

View File

@@ -1,3 +1,4 @@
import 'package:siro_driver/constant/currency.dart';
import 'dart:async';
import 'dart:convert';
import 'dart:io';
@@ -108,7 +109,7 @@ class NotificationController extends GetxController {
// تنسيق النص ليكون 4 أسطر واضحة
formattedBigText = "👤 $paxName\n"
"💰 $price ${'SYP'.tr} | 🛣️ $distance كم\n"
"💰 $price ${CurrencyHelper.currency} | 🛣️ $distance كم\n"
"🟢 من: $startLoc\n"
"🏁 إلى: $endLoc";

View File

@@ -0,0 +1,94 @@
import 'package:siro_driver/constant/box_name.dart';
import 'package:siro_driver/main.dart';
class CountryLogic {
/// Formats the phone number based on the country's dialing rules.
static String formatPhone(String phone, String country) {
phone = phone.replaceAll(RegExp(r'[ \-\(\)\+]'), '').trim();
if (country == 'Egypt') {
// Rule: 010, 011, 012, 015 -> 2010, 2011, 2012, 2015
if (phone.startsWith('0020')) phone = phone.replaceFirst('0020', '20');
if (phone.startsWith('01') && phone.length >= 10) {
return '20${phone.substring(1)}';
}
if (phone.startsWith('1') &&
phone.length >= 9 &&
!phone.startsWith('20')) {
return '20$phone';
}
if (!phone.startsWith('20') && phone.length > 8) return '20$phone';
} else if (country == 'Jordan') {
// Rule: 07x -> 9627x
if (phone.startsWith('00962')) phone = phone.replaceFirst('00962', '962');
if (phone.startsWith('07') && phone.length >= 9) {
return '962${phone.substring(1)}';
}
if (phone.startsWith('7') &&
phone.length >= 8 &&
!phone.startsWith('962')) {
return '962$phone';
}
if (!phone.startsWith('962') && phone.length > 7) return '962$phone';
} else {
// Default to Syria
if (phone.startsWith('00963')) phone = phone.replaceFirst('00963', '963');
if (phone.startsWith('0963')) phone = phone.replaceFirst('0963', '963');
if (phone.startsWith('096309')) {
phone = phone.replaceFirst('096309', '963');
}
if (phone.startsWith('96309')) phone = '9639${phone.substring(5)}';
if (phone.startsWith('9630')) phone = '9639${phone.substring(4)}';
if (phone.startsWith('9639') && phone.length == 12) return phone;
if (phone.startsWith('963') &&
phone.length > 3 &&
!phone.startsWith('9639')) {
phone = '9639${phone.substring(3)}';
}
if (phone.startsWith('09')) return '963${phone.substring(1)}';
if (phone.startsWith('9') && phone.length == 9) return '963$phone';
if (phone.startsWith('0') && phone.length == 10) {
return '963${phone.substring(1)}';
}
}
return phone;
}
/// Returns the default country prefix (EG, JO, SY) for UI initial selection.
static String getCountryPrefix(String country) {
if (country == 'Egypt') return 'EG';
if (country == 'Jordan') return 'JO';
return 'SY';
}
/// Returns the default emergency number for the country.
static String getEmergencyNumber(String country) {
if (country == 'Egypt') return '122';
if (country == 'Jordan') return '911';
return '112'; // Syria
}
/// Returns the hint text for phone inputs based on the country.
static String getPhoneHint(String country) {
if (country == 'Egypt') return 'e.g. 01012345678 (Default +20)';
if (country == 'Jordan') return 'e.g. 0791234567 (Default +962)';
return 'e.g. 0912345678 (Default +963)'; // Syria
}
/// Helper to format phone using the current country in box.
static String formatCurrentCountryPhone(String phone) {
String cleanPhone = phone.replaceAll(RegExp(r'[ \-\(\)]'), '').trim();
if (cleanPhone.startsWith('+963') || cleanPhone.startsWith('00963')) {
return formatPhone(cleanPhone, 'Syria');
}
if (cleanPhone.startsWith('+20') || cleanPhone.startsWith('0020')) {
return formatPhone(cleanPhone, 'Egypt');
}
if (cleanPhone.startsWith('+962') || cleanPhone.startsWith('00962')) {
return formatPhone(cleanPhone, 'Jordan');
}
final country = box.read(BoxName.countryCode) ?? 'Syria';
return formatPhone(cleanPhone, country);
}
}

View File

@@ -1,7 +1,6 @@
import 'package:url_launcher/url_launcher.dart';
import 'dart:io';
import 'package:get/get.dart';
import 'package:siro_driver/views/widgets/error_snakbar.dart';
import 'package:siro_driver/controller/functions/country_logic.dart';
void showInBrowser(String url) async {
if (await canLaunchUrl(Uri.parse(url))) {
@@ -10,18 +9,11 @@ void showInBrowser(String url) async {
}
String cleanAndFormatPhoneNumber(String phoneNumber) {
// 1. Clean the number
String formattedNumber = phoneNumber.replaceAll(RegExp(r'\s+'), '');
// 2. Format logic (Syria/Egypt/International)
if (formattedNumber.length > 6) {
if (formattedNumber.startsWith('09')) {
formattedNumber = '+963${formattedNumber.substring(1)}';
} else if (formattedNumber.startsWith('01') && formattedNumber.length == 11) {
formattedNumber = '+20${formattedNumber.substring(1)}';
} else if (formattedNumber.startsWith('00')) {
formattedNumber = '+${formattedNumber.substring(2)}';
} else if (!formattedNumber.startsWith('+')) {
formattedNumber = CountryLogic.formatCurrentCountryPhone(formattedNumber);
if (!formattedNumber.startsWith('+')) {
formattedNumber = '+$formattedNumber';
}
}
@@ -30,11 +22,6 @@ String cleanAndFormatPhoneNumber(String phoneNumber) {
Future<void> makePhoneCall(String phoneNumber) async {
String formattedNumber = cleanAndFormatPhoneNumber(phoneNumber);
if (!formattedNumber.startsWith('+963')) {
mySnackeBarError("Calling non-Syrian numbers is not supported".tr);
return;
}
// Create URI directly from String to avoid double encoding '+' as '%2B'
final Uri launchUri = Uri.parse('tel:$formattedNumber');
@@ -63,10 +50,6 @@ void launchCommunication(
if (Platform.isIOS) {
switch (method) {
case 'phone':
if (!formattedContact.startsWith('+963')) {
mySnackeBarError("Calling non-Syrian numbers is not supported".tr);
return;
}
url = 'tel:$formattedContact';
break;
case 'sms':
@@ -86,10 +69,6 @@ void launchCommunication(
} else if (Platform.isAndroid) {
switch (method) {
case 'phone':
if (!formattedContact.startsWith('+963')) {
mySnackeBarError("Calling non-Syrian numbers is not supported".tr);
return;
}
url = 'tel:$formattedContact';
break;
case 'sms':

View File

@@ -1,3 +1,4 @@
import 'package:siro_driver/constant/currency.dart';
import 'dart:io';
import 'package:siro_driver/constant/links.dart';
@@ -35,7 +36,7 @@ Future<void> showDriverGiftClaim(BuildContext context) async {
if (box.read(BoxName.is_claimed).toString() == '0' ||
box.read(BoxName.is_claimed) == null) {
MyDialog().getDialog(
'You have gift 300 SYP'.tr, 'This for new registration'.tr, () async {
'You have gift 300 ${CurrencyHelper.currency}'.tr, 'This for new registration'.tr, () async {
Get.back();
var res = await CRUD().post(link: AppLink.updateDriverClaim, payload: {
'driverId': box.read(BoxName.driverID),

View File

@@ -1,3 +1,4 @@
import 'package:siro_driver/constant/currency.dart';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -97,7 +98,7 @@ class ChallengesController extends GetxController {
id: 'daily_earnings',
titleEn: 'Money Maker',
titleAr: 'صانع المال',
descriptionEn: 'Earn 3000 SYP today',
descriptionEn: 'Earn 3000 ${CurrencyHelper.currency} today',
descriptionAr: 'اربح 3000 ل.س اليوم',
icon: Icons.monetization_on_rounded,
color: const Color(0xFF4CAF50),
@@ -140,7 +141,7 @@ class ChallengesController extends GetxController {
id: 'weekly_earnings',
titleEn: 'Big Earner',
titleAr: 'الربح الكبير',
descriptionEn: 'Earn 20,000 SYP this week',
descriptionEn: 'Earn 20,000 ${CurrencyHelper.currency} this week',
descriptionAr: 'اربح 20,000 ل.س هذا الأسبوع',
icon: Icons.account_balance_wallet_rounded,
color: const Color(0xFF9C27B0),

View File

@@ -1395,6 +1395,8 @@ class MyTranslation extends Translations {
"SOS Phone": "هاتف الطوارئ",
"SUBMIT": "إرسال",
"SYP": "ل.س",
"EGP": "ج.م",
"JOD": "د.أ",
"Safety & Security": "السلامة والأمان",
"Saudi Arabia": "السعودية",
"Save": "حفظ",
@@ -2078,7 +2080,11 @@ class MyTranslation extends Translations {
"You have finished all times": "خلصت كل الأوقات",
"You have gift 300 L.E": "عندك هدية 300 ل.م",
"You have gift 300 SYP": "عندك هدية 300 ل.س",
"You have gift 300 EGP": "عندك هدية 300 ج.م",
"You have gift 300 JOD": "عندك هدية 300 د.أ",
"You have gift 30000 SYP": "عندك هدية 30000 ل.س",
"You have gift 30000 EGP": "عندك هدية 30000 ج.م",
"You have gift 30000 JOD": "عندك هدية 30000 د.أ",
"You have got a gift": "وصلتك هدية",
"You have got a gift for invitation": "وصلتك هدية للدعوة",
"You have in account": "عندك بالحساب",
@@ -2608,6 +2614,8 @@ class MyTranslation extends Translations {
"Confirm": "تأكيد",
"PTS": "نقطة",
"SYP": "ل.س",
"EGP": "ج.م",
"JOD": "د.أ",
"You are buying": "أنت تقوم بشراء",
"for": "بـ",
"Points": "نقاط",
@@ -2634,6 +2642,8 @@ class MyTranslation extends Translations {
"اختر كيف تريد شحن حسابك",
"Add Balance": "إضافة رصيد",
"SYP": "ل.س",
"EGP": "ج.م",
"JOD": "د.أ",
"Your completed trips will appear here": "ستظهر رحلاتك المكتملة هنا",
"Cancelled by Passenger": "تم الإلغاء بواسطة الراكب",
},