Update: 2026-06-29 00:07:33
This commit is contained in:
@@ -188,4 +188,15 @@ class AppLink {
|
||||
static String addCartoDriver = "$serviceApp/addCartoDriver.php";
|
||||
static String getRegisrationCar = "$ride/RegisrationCar/get.php";
|
||||
static String updateRegisrationCar = "$ride/RegisrationCar/update.php";
|
||||
|
||||
static String detectCountryFromPhone(String phone) {
|
||||
final clean = phone.replaceAll(RegExp(r'[^0-9]'), '');
|
||||
if (clean.startsWith('962')) return 'Jordan';
|
||||
if (clean.startsWith('963')) return 'Syria';
|
||||
if (clean.startsWith('20')) return 'Egypt';
|
||||
if (clean.startsWith('07') || clean.startsWith('7')) return 'Jordan';
|
||||
if (clean.startsWith('09') || clean.startsWith('9')) return 'Syria';
|
||||
if (clean.startsWith('01') || clean.startsWith('1')) return 'Egypt';
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@ class LoginController extends GetxController {
|
||||
final FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||
|
||||
void login() async {
|
||||
final emailStr = email.text.trim();
|
||||
final detectedCountry = AppLink.detectCountryFromPhone(emailStr);
|
||||
if (detectedCountry.isNotEmpty) {
|
||||
await box.write(BoxName.countryCode, detectedCountry);
|
||||
}
|
||||
|
||||
// Ensure fingerprint is ready
|
||||
String fingerprint = box.read(BoxName.fingerPrint) ?? '';
|
||||
if (fingerprint.isEmpty) {
|
||||
|
||||
@@ -50,7 +50,8 @@ class MainController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
// refreshDashboardStats(); // Removed to save data consumption at start
|
||||
final country = box.read('countryCode')?.toString() ?? 'Jordan';
|
||||
Log.print('🌍 [SIRO-SERVICE-STARTUP] Current countryCode stored in box: $country');
|
||||
}
|
||||
|
||||
Future<void> refreshDashboardStats() async {
|
||||
|
||||
@@ -123,6 +123,42 @@ class ReviewDriverController extends GetxController {
|
||||
};
|
||||
|
||||
List<List<dynamic>> getFieldsForTab(String tabKey) {
|
||||
final countryCode = country;
|
||||
if (countryCode == 'Syria') {
|
||||
if (tabKey == 'driver_license_front') {
|
||||
return [
|
||||
['licenseTypeController', 'License Type', false, false, false, false],
|
||||
[
|
||||
'licenseIssueDateController',
|
||||
'License Issue Date',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
],
|
||||
[
|
||||
'expiryDateController',
|
||||
'License Expiry Date',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
],
|
||||
];
|
||||
}
|
||||
if (tabKey == 'driver_license_back') {
|
||||
return [
|
||||
[
|
||||
'licenseCategoriesController',
|
||||
'License Categories',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
return fieldConfig[tabKey] ?? [];
|
||||
}
|
||||
|
||||
@@ -161,6 +197,10 @@ class ReviewDriverController extends GetxController {
|
||||
driverId.value = args['driverId'] ?? '';
|
||||
phone.value = args['phone'] ?? '';
|
||||
}
|
||||
if (country == 'Jordan' || country == 'Egypt') {
|
||||
docUrls.remove('driver_license_back');
|
||||
}
|
||||
_initializeDocUrls();
|
||||
fetchData();
|
||||
}
|
||||
|
||||
@@ -210,13 +250,64 @@ class ReviewDriverController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
String reconstructDocumentUrl(String originalLink, String docType) {
|
||||
if (originalLink.isEmpty) {
|
||||
return "${AppLink.server}/auth/syria/driversDocs/syria.intaleq.xyz-${driverId.value}-$docType.jpg";
|
||||
}
|
||||
|
||||
try {
|
||||
final origUri = Uri.parse(originalLink);
|
||||
final query = origUri.query;
|
||||
final path = origUri.path;
|
||||
|
||||
if (path.contains('secure_image.php')) {
|
||||
return "${AppLink.server}/secure_image.php?$query";
|
||||
}
|
||||
|
||||
if (path.contains('auth/syria/driversDocs/')) {
|
||||
final parts = path.split('auth/syria/driversDocs/');
|
||||
final filename = parts.last;
|
||||
return "${AppLink.server}/auth/syria/driversDocs/$filename";
|
||||
}
|
||||
|
||||
if (originalLink.startsWith('http://') ||
|
||||
originalLink.startsWith('https://')) {
|
||||
final serverUri = Uri.parse(AppLink.server);
|
||||
final host = serverUri.host;
|
||||
|
||||
final newUri = Uri(
|
||||
scheme: 'https',
|
||||
host: host,
|
||||
path: path,
|
||||
query: query.isNotEmpty ? query : null,
|
||||
);
|
||||
return newUri.toString();
|
||||
}
|
||||
|
||||
final cleanPath = path.startsWith('/') ? path : '/$path';
|
||||
return "${AppLink.server}$cleanPath${query.isNotEmpty ? '?$query' : ''}";
|
||||
} catch (e) {
|
||||
if (originalLink.startsWith('http://')) {
|
||||
return originalLink.replaceFirst('http://', 'https://');
|
||||
}
|
||||
return originalLink;
|
||||
}
|
||||
}
|
||||
|
||||
void _initializeDocUrls() {
|
||||
for (var key in docUrls.keys) {
|
||||
docUrls[key]!.value = reconstructDocumentUrl('', key);
|
||||
}
|
||||
}
|
||||
|
||||
void _populateDocUrls(dynamic docs) {
|
||||
if (docs is List) {
|
||||
for (var doc in docs) {
|
||||
if (doc is Map && doc['doc_type'] != null && doc['link'] != null) {
|
||||
String type = doc['doc_type'].toString();
|
||||
if (docUrls.containsKey(type)) {
|
||||
docUrls[type]!.value = doc['link'].toString();
|
||||
docUrls[type]!.value =
|
||||
reconstructDocumentUrl(doc['link'].toString(), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user