Update: 2026-06-11 18:22:57
This commit is contained in:
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user