المجلدات وأسماء حزم dart واستيراداتها: siro_rider → intaleq_rider siro_driver → intaleq_driver siro_admin → intaleq_admin siro_service → intaleq_service شمل ذلك `name:` في كل pubspec وكل `package:siro_*` في الاستيرادات (115 ملفاً في rider وحده)، وإشارات أسماء المجلدات في docs/ وتعليق في backend/Admin/notifications/broadcast.php. لم تبقَ إشارة واحدة (تحقّقت). + ضُمّت حزم get و get_storage داخل intaleq_driver/packages/ وحُوّلت مساراتها الثلاثة من `../../Intaleq/packages/*` إلى `./packages/*`. كانت تُحل عرضاً إلى مجلد App/Intaleq القديم المجاور — تبعية خارج المستودع تنكسر بأول نقل. لم يبقَ في أي تطبيق تبعية مسار خارج الشجرة. ⚠️ لم تُمسّ بعد: هويات المتاجر (applicationId · PRODUCT_BUNDLE_IDENTIFIER · shorebird app_id) ولا الألوان ولا النصوص المرئية ولا النطاقات — كل منها كوميت منفصل، والهويات تحتاج قرار المالك. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
132 lines
3.6 KiB
Dart
132 lines
3.6 KiB
Dart
import 'package:url_launcher/url_launcher.dart';
|
|
import 'dart:io';
|
|
import 'package:intaleq_service/main.dart';
|
|
|
|
String _formatPhoneNumberForCommunication(String rawPhone, String country) {
|
|
String digits = rawPhone.replaceAll(RegExp(r'[^0-9]'), '');
|
|
if (digits.startsWith('00')) {
|
|
digits = digits.substring(2);
|
|
}
|
|
if (country == 'Jordan') {
|
|
if (digits.startsWith('962') && digits.length >= 12) {
|
|
return digits;
|
|
}
|
|
if (digits.startsWith('0')) {
|
|
digits = digits.substring(1);
|
|
}
|
|
if (!digits.startsWith('962')) {
|
|
digits = '962$digits';
|
|
}
|
|
} else if (country == 'Egypt') {
|
|
if (digits.startsWith('20') && digits.length >= 11) {
|
|
return digits;
|
|
}
|
|
if (digits.startsWith('0')) {
|
|
digits = digits.substring(1);
|
|
}
|
|
if (!digits.startsWith('20')) {
|
|
digits = '20$digits';
|
|
}
|
|
} else if (country == 'Syria') {
|
|
if (digits.startsWith('963') && digits.length >= 11) {
|
|
return digits;
|
|
}
|
|
if (digits.startsWith('0')) {
|
|
digits = digits.substring(1);
|
|
}
|
|
if (!digits.startsWith('963')) {
|
|
digits = '963$digits';
|
|
}
|
|
} else {
|
|
if (digits.startsWith('0') && digits.length > 5) {
|
|
digits = digits.substring(1);
|
|
}
|
|
}
|
|
return digits;
|
|
}
|
|
|
|
void showInBrowser(String url) async {
|
|
if (await canLaunchUrl(Uri.parse(url))) {
|
|
launchUrl(Uri.parse(url));
|
|
} else {}
|
|
}
|
|
|
|
Future<void> makePhoneCall(String phoneNumber) async {
|
|
final cleanPhone = phoneNumber.replaceAll(RegExp(r'[^0-9+]'), '');
|
|
final Uri launchUri = Uri(
|
|
scheme: 'tel',
|
|
path: cleanPhone,
|
|
);
|
|
if (await canLaunchUrl(launchUri)) {
|
|
await launchUrl(launchUri);
|
|
} else {
|
|
final String telUrl = 'tel:$cleanPhone';
|
|
if (await canLaunchUrl(Uri.parse(telUrl))) {
|
|
await launchUrl(Uri.parse(telUrl));
|
|
}
|
|
}
|
|
}
|
|
|
|
void launchCommunication(
|
|
String method, String contactInfo, String message) async {
|
|
String url;
|
|
final cleanPhone = contactInfo.replaceAll(RegExp(r'[^0-9+]'), '');
|
|
final country = box.read('countryCode')?.toString() ?? 'Jordan';
|
|
final phone = _formatPhoneNumberForCommunication(contactInfo, country);
|
|
|
|
if (Platform.isIOS) {
|
|
switch (method) {
|
|
case 'phone':
|
|
url = 'tel:$cleanPhone';
|
|
break;
|
|
case 'sms':
|
|
url = 'sms:$cleanPhone?body=${Uri.encodeComponent(message)}';
|
|
break;
|
|
case 'whatsapp':
|
|
url =
|
|
'https://api.whatsapp.com/send?phone=$phone&text=${Uri.encodeComponent(message)}';
|
|
break;
|
|
case 'email':
|
|
url =
|
|
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
} else if (Platform.isAndroid) {
|
|
switch (method) {
|
|
case 'phone':
|
|
url = 'tel:$cleanPhone';
|
|
break;
|
|
case 'sms':
|
|
url = 'sms:$cleanPhone?body=${Uri.encodeComponent(message)}';
|
|
break;
|
|
case 'whatsapp':
|
|
// Check if WhatsApp is installed
|
|
final bool whatsappInstalled =
|
|
await canLaunchUrl(Uri.parse('whatsapp://'));
|
|
if (whatsappInstalled) {
|
|
url =
|
|
'whatsapp://send?phone=$phone&text=${Uri.encodeComponent(message)}';
|
|
} else {
|
|
// Provide an alternative action, such as opening the WhatsApp Web API
|
|
url =
|
|
'https://api.whatsapp.com/send?phone=$phone&text=${Uri.encodeComponent(message)}';
|
|
}
|
|
break;
|
|
case 'email':
|
|
url =
|
|
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
if (await canLaunchUrl(Uri.parse(url))) {
|
|
await launchUrl(Uri.parse(url));
|
|
} else {}
|
|
}
|