Update: 2026-06-14 05:48:58
This commit is contained in:
@@ -17,6 +17,7 @@ import '../../../constant/colors.dart';
|
|||||||
import '../../../views/auth/captin/ai_page.dart';
|
import '../../../views/auth/captin/ai_page.dart';
|
||||||
import '../../../views/auth/syria/registration_view.dart';
|
import '../../../views/auth/syria/registration_view.dart';
|
||||||
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||||
|
import '../../functions/country_logic.dart';
|
||||||
import '../../functions/sms_egypt_controller.dart';
|
import '../../functions/sms_egypt_controller.dart';
|
||||||
|
|
||||||
class RegisterCaptainController extends GetxController {
|
class RegisterCaptainController extends GetxController {
|
||||||
@@ -385,11 +386,13 @@ class RegisterCaptainController extends GetxController {
|
|||||||
if (formKey.currentState!.validate()) {
|
if (formKey.currentState!.validate()) {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
update();
|
update();
|
||||||
|
final fixedPhone =
|
||||||
|
CountryLogic.formatCurrentCountryPhone(phoneController.text);
|
||||||
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: {
|
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: {
|
||||||
'first_name': name.split(' ')[1],
|
'first_name': name.split(' ')[1],
|
||||||
'last_name': name.split(' ')[0],
|
'last_name': name.split(' ')[0],
|
||||||
'email': emailController.text,
|
'email': emailController.text,
|
||||||
'phone': phoneController.text,
|
'phone': fixedPhone,
|
||||||
'password': passwordController.text,
|
'password': passwordController.text,
|
||||||
'gender': sex,
|
'gender': sex,
|
||||||
'site': address,
|
'site': address,
|
||||||
|
|||||||
@@ -211,9 +211,11 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
notificationController.showNotification(title, body, 'ding', '');
|
notificationController.showNotification(title, body, 'ding', '');
|
||||||
}
|
}
|
||||||
MyDialog().getDialog(title, body, () {
|
MyDialog().getChatDialog(
|
||||||
// Empty callback, MyDialog already closes itself using pop().
|
title.isNotEmpty ? title : 'message From passenger'.tr,
|
||||||
});
|
body,
|
||||||
|
() {},
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'token change':
|
case 'token change':
|
||||||
|
|||||||
@@ -83,17 +83,55 @@ class CountryLogic {
|
|||||||
|
|
||||||
/// Helper to format phone using the current country in box.
|
/// Helper to format phone using the current country in box.
|
||||||
static String formatCurrentCountryPhone(String phone) {
|
static String formatCurrentCountryPhone(String phone) {
|
||||||
String cleanPhone = phone.replaceAll(RegExp(r'[ \-\(\)]'), '').trim();
|
String cleanPhone = phone.replaceAll(RegExp(r'[ \-\(\)\+]'), '').trim();
|
||||||
if (cleanPhone.startsWith('+963') || cleanPhone.startsWith('00963')) {
|
|
||||||
|
// 1. Explicit International Code Detection
|
||||||
|
if (cleanPhone.startsWith('00963')) {
|
||||||
|
cleanPhone = cleanPhone.replaceFirst('00963', '963');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('00962')) {
|
||||||
|
cleanPhone = cleanPhone.replaceFirst('00962', '962');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('0020')) {
|
||||||
|
cleanPhone = cleanPhone.replaceFirst('0020', '20');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cleanPhone.startsWith('963')) {
|
||||||
return formatPhone(cleanPhone, 'Syria');
|
return formatPhone(cleanPhone, 'Syria');
|
||||||
}
|
}
|
||||||
if (cleanPhone.startsWith('+20') || cleanPhone.startsWith('0020')) {
|
if (cleanPhone.startsWith('962')) {
|
||||||
|
return formatPhone(cleanPhone, 'Jordan');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('20')) {
|
||||||
return formatPhone(cleanPhone, 'Egypt');
|
return formatPhone(cleanPhone, 'Egypt');
|
||||||
}
|
}
|
||||||
if (cleanPhone.startsWith('+962') || cleanPhone.startsWith('00962')) {
|
|
||||||
|
// 2. Local/National Format Detection by Country-Specific Mobile Prefixes
|
||||||
|
// Jordan: 07x / 7x (9 national digits)
|
||||||
|
if (cleanPhone.startsWith('07') && cleanPhone.length == 10) {
|
||||||
|
return formatPhone(cleanPhone, 'Jordan');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('7') && cleanPhone.length == 9) {
|
||||||
return formatPhone(cleanPhone, 'Jordan');
|
return formatPhone(cleanPhone, 'Jordan');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Syria: 09x / 9x (9 national digits)
|
||||||
|
if (cleanPhone.startsWith('09') && cleanPhone.length == 10) {
|
||||||
|
return formatPhone(cleanPhone, 'Syria');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('9') && cleanPhone.length == 9) {
|
||||||
|
return formatPhone(cleanPhone, 'Syria');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Egypt: 01x (10 national digits) / 1x (9 national digits)
|
||||||
|
if (cleanPhone.startsWith('01') && cleanPhone.length == 11) {
|
||||||
|
return formatPhone(cleanPhone, 'Egypt');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('1') && cleanPhone.length == 10) {
|
||||||
|
return formatPhone(cleanPhone, 'Egypt');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Fallback: Default to current user's country code saved in box
|
||||||
final country = box.read(BoxName.countryCode) ?? 'Syria';
|
final country = box.read(BoxName.countryCode) ?? 'Syria';
|
||||||
return formatPhone(cleanPhone, country);
|
return formatPhone(cleanPhone, country);
|
||||||
}
|
}
|
||||||
|
|||||||
30
siro_driver/lib/controller/functions/translate_helper.dart
Normal file
30
siro_driver/lib/controller/functions/translate_helper.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
class TranslateHelper {
|
||||||
|
static Future<String> translateText(String text, String targetLang) async {
|
||||||
|
if (text.isEmpty) return text;
|
||||||
|
try {
|
||||||
|
final url = Uri.parse(
|
||||||
|
'https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=$targetLang&dt=t&q=${Uri.encodeComponent(text)}'
|
||||||
|
);
|
||||||
|
final response = await http.get(url);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final decoded = jsonDecode(response.body);
|
||||||
|
if (decoded != null && decoded is List && decoded.isNotEmpty && decoded[0] is List) {
|
||||||
|
final List parts = decoded[0];
|
||||||
|
String translated = '';
|
||||||
|
for (var part in parts) {
|
||||||
|
if (part is List && part.isNotEmpty) {
|
||||||
|
translated += part[0].toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return translated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Fallback to original text on any exception
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,12 +67,16 @@ class OrderRequestController extends GetxController
|
|||||||
String timeToPassenger = "Calculating...".tr;
|
String timeToPassenger = "Calculating...".tr;
|
||||||
String distanceToPassenger = "--";
|
String distanceToPassenger = "--";
|
||||||
|
|
||||||
|
String apiStartName = "";
|
||||||
|
String apiEndName = "";
|
||||||
|
|
||||||
// --- الخريطة ---
|
// --- الخريطة ---
|
||||||
Set<Polyline> polylines = {};
|
Set<Polyline> polylines = {};
|
||||||
bool _hasCalculatedFullJourney = false;
|
bool _hasCalculatedFullJourney = false;
|
||||||
|
|
||||||
// حالة التطبيق والصوت
|
// حالة التطبيق والصوت
|
||||||
bool isInBackground = false;
|
bool isInBackground = false;
|
||||||
|
bool isAccepting = false;
|
||||||
final AudioPlayer audioPlayer = AudioPlayer();
|
final AudioPlayer audioPlayer = AudioPlayer();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -288,6 +292,15 @@ class OrderRequestController extends GetxController
|
|||||||
totalTripDuration = tripResult['duration_text'];
|
totalTripDuration = tripResult['duration_text'];
|
||||||
polylines.add(tripResult['polyline']);
|
polylines.add(tripResult['polyline']);
|
||||||
|
|
||||||
|
if (tripResult['start_name'] != null &&
|
||||||
|
tripResult['start_name'].toString().isNotEmpty) {
|
||||||
|
apiStartName = tripResult['start_name'].toString();
|
||||||
|
}
|
||||||
|
if (tripResult['end_name'] != null &&
|
||||||
|
tripResult['end_name'].toString().isNotEmpty) {
|
||||||
|
apiEndName = tripResult['end_name'].toString();
|
||||||
|
}
|
||||||
|
|
||||||
// 🔥 تخزين استجابة السيرفر كاملة (بما فيها الـ points والـ instructions)
|
// 🔥 تخزين استجابة السيرفر كاملة (بما فيها الـ points والـ instructions)
|
||||||
if (tripResult['raw_response'] != null) {
|
if (tripResult['raw_response'] != null) {
|
||||||
box.write('cached_trip_route', tripResult['raw_response']);
|
box.write('cached_trip_route', tripResult['raw_response']);
|
||||||
@@ -385,6 +398,8 @@ class OrderRequestController extends GetxController
|
|||||||
'duration_text': durationText,
|
'duration_text': durationText,
|
||||||
'polyline': polyline,
|
'polyline': polyline,
|
||||||
'encoded_polyline': encodedPoints,
|
'encoded_polyline': encodedPoints,
|
||||||
|
'start_name': data['startName']?.toString(),
|
||||||
|
'end_name': data['endName']?.toString(),
|
||||||
'raw_response': response.body, // 🔥 نمرر الـ JSON كاملاً
|
'raw_response': response.body, // 🔥 نمرر الـ JSON كاملاً
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -618,91 +633,102 @@ class OrderRequestController extends GetxController
|
|||||||
|
|
||||||
// Accept Order Logic
|
// Accept Order Logic
|
||||||
Future<void> acceptOrder() async {
|
Future<void> acceptOrder() async {
|
||||||
|
if (isAccepting) return;
|
||||||
|
isAccepting = true;
|
||||||
|
update();
|
||||||
|
|
||||||
endTimer();
|
endTimer();
|
||||||
_stopAudio();
|
_stopAudio();
|
||||||
|
|
||||||
// 1. إرسال الطلب
|
try {
|
||||||
var res = await CRUD()
|
// 1. إرسال الطلب
|
||||||
.post(link: "${AppLink.ride}/rides/acceptRide.php", payload: {
|
var res = await CRUD()
|
||||||
'id': _safeGet(16),
|
.post(link: "${AppLink.ride}/rides/acceptRide.php", payload: {
|
||||||
'rideTimeStart': DateTime.now().toString(),
|
'id': _safeGet(16),
|
||||||
'status': 'Apply',
|
'rideTimeStart': DateTime.now().toString(),
|
||||||
'passengerToken': _safeGet(9),
|
'status': 'Apply',
|
||||||
'driver_id': box.read(BoxName.driverID),
|
'passengerToken': _safeGet(9),
|
||||||
});
|
'driver_id': box.read(BoxName.driverID),
|
||||||
|
|
||||||
Log.print('res from orderrequestpage: ${res}');
|
|
||||||
|
|
||||||
// ============================================================
|
|
||||||
// تصحيح: فحص الرد بدقة (Map أو String)
|
|
||||||
// ============================================================
|
|
||||||
bool isFailure = false;
|
|
||||||
|
|
||||||
if (res is Map && res['status'] == 'failure') {
|
|
||||||
isFailure = true;
|
|
||||||
} else if (res == 'failure') {
|
|
||||||
isFailure = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFailure) {
|
|
||||||
// ⛔ حالة الفشل: الطلب مأخوذ
|
|
||||||
MyDialog().getDialog(
|
|
||||||
"Sorry, the order was taken by another driver.".tr, '', () {
|
|
||||||
// بما أن MyDialog يغلق نفسه الآن، نحتاج Get.back() واحدة فقط لإغلاق صفحة الطلب
|
|
||||||
Get.back();
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// ✅ حالة النجاح
|
|
||||||
|
|
||||||
// حماية من الكراش: التأكد من وجود HomeCaptainController قبل استخدامه
|
Log.print('res from orderrequestpage: ${res}');
|
||||||
if (!Get.isRegistered<HomeCaptainController>()) {
|
|
||||||
Get.put(HomeCaptainController());
|
// ============================================================
|
||||||
} else {
|
// تصحيح: فحص الرد بدقة (Map أو String)
|
||||||
Get.find<HomeCaptainController>().changeRideId();
|
// ============================================================
|
||||||
|
bool isFailure = false;
|
||||||
|
|
||||||
|
if (res is Map && res['status'] == 'failure') {
|
||||||
|
isFailure = true;
|
||||||
|
} else if (res == 'failure') {
|
||||||
|
isFailure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
box.write(BoxName.statusDriverLocation, 'on');
|
if (isFailure) {
|
||||||
changeApplied();
|
// ⛔ حالة الفشل: الطلب مأخوذ
|
||||||
|
MyDialog().getDialog(
|
||||||
|
"Sorry, the order was taken by another driver.".tr, '', () {
|
||||||
|
// بما أن MyDialog يغلق نفسه الآن، نحتاج Get.back() واحدة فقط لإغلاق صفحة الطلب
|
||||||
|
Get.back();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// ✅ حالة النجاح
|
||||||
|
|
||||||
var rideArgs = {
|
// حماية من الكراش: التأكد من وجود HomeCaptainController قبل استخدامه
|
||||||
'passengerLocation': '${_safeGet(0)},${_safeGet(1)}',
|
if (!Get.isRegistered<HomeCaptainController>()) {
|
||||||
'passengerDestination': '${_safeGet(3)},${_safeGet(4)}',
|
Get.put(HomeCaptainController());
|
||||||
'Duration': totalTripDuration,
|
} else {
|
||||||
'totalCost': _safeGet(26),
|
Get.find<HomeCaptainController>().changeRideId();
|
||||||
'Distance': totalTripDistance,
|
}
|
||||||
'name': _safeGet(8),
|
|
||||||
'phone': _safeGet(10),
|
|
||||||
'email': _safeGet(28),
|
|
||||||
'WalletChecked': _safeGet(13),
|
|
||||||
'tokenPassenger': _safeGet(9),
|
|
||||||
'direction':
|
|
||||||
'https://www.google.com/maps/dir/${_safeGet(0)}/${_safeGet(1)}/',
|
|
||||||
'DurationToPassenger': timeToPassenger,
|
|
||||||
'rideId': _safeGet(16),
|
|
||||||
'passengerId': _safeGet(7),
|
|
||||||
'driverId': _safeGet(18),
|
|
||||||
'durationOfRideValue': totalTripDuration,
|
|
||||||
'paymentAmount': _safeGet(2),
|
|
||||||
'paymentMethod': _safeGet(13) == 'true' ? 'visa' : 'cash',
|
|
||||||
'isHaveSteps': _safeGet(20),
|
|
||||||
'step0': _safeGet(21),
|
|
||||||
'step1': _safeGet(22),
|
|
||||||
'step2': _safeGet(23),
|
|
||||||
'step3': _safeGet(24),
|
|
||||||
'step4': _safeGet(25),
|
|
||||||
'passengerWalletBurc': _safeGet(26),
|
|
||||||
'timeOfOrder': DateTime.now().toString(),
|
|
||||||
'totalPassenger': _safeGet(2),
|
|
||||||
'carType': _safeGet(31),
|
|
||||||
'kazan': _safeGet(32),
|
|
||||||
'startNameLocation': _safeGet(29),
|
|
||||||
'endNameLocation': _safeGet(30),
|
|
||||||
};
|
|
||||||
|
|
||||||
box.write(BoxName.rideArguments, rideArgs);
|
box.write(BoxName.statusDriverLocation, 'on');
|
||||||
|
changeApplied();
|
||||||
|
|
||||||
// الانتقال النهائي
|
var rideArgs = {
|
||||||
Get.off(() => PassengerLocationMapPage(), arguments: rideArgs);
|
'passengerLocation': '${_safeGet(0)},${_safeGet(1)}',
|
||||||
|
'passengerDestination': '${_safeGet(3)},${_safeGet(4)}',
|
||||||
|
'Duration': totalTripDuration,
|
||||||
|
'totalCost': _safeGet(26),
|
||||||
|
'Distance': totalTripDistance,
|
||||||
|
'name': _safeGet(8),
|
||||||
|
'phone': _safeGet(10),
|
||||||
|
'email': _safeGet(28),
|
||||||
|
'WalletChecked': _safeGet(13),
|
||||||
|
'tokenPassenger': _safeGet(9),
|
||||||
|
'direction':
|
||||||
|
'https://www.google.com/maps/dir/${_safeGet(0)}/${_safeGet(1)}/',
|
||||||
|
'DurationToPassenger': timeToPassenger,
|
||||||
|
'rideId': _safeGet(16),
|
||||||
|
'passengerId': _safeGet(7),
|
||||||
|
'driverId': _safeGet(18),
|
||||||
|
'durationOfRideValue': totalTripDuration,
|
||||||
|
'paymentAmount': _safeGet(2),
|
||||||
|
'paymentMethod': _safeGet(13) == 'true' ? 'visa' : 'cash',
|
||||||
|
'isHaveSteps': _safeGet(20),
|
||||||
|
'step0': _safeGet(21),
|
||||||
|
'step1': _safeGet(22),
|
||||||
|
'step2': _safeGet(23),
|
||||||
|
'step3': _safeGet(24),
|
||||||
|
'step4': _safeGet(25),
|
||||||
|
'passengerWalletBurc': _safeGet(26),
|
||||||
|
'timeOfOrder': DateTime.now().toString(),
|
||||||
|
'totalPassenger': _safeGet(2),
|
||||||
|
'carType': _safeGet(31),
|
||||||
|
'kazan': _safeGet(32),
|
||||||
|
'startNameLocation': _safeGet(29),
|
||||||
|
'endNameLocation': _safeGet(30),
|
||||||
|
};
|
||||||
|
|
||||||
|
box.write(BoxName.rideArguments, rideArgs);
|
||||||
|
|
||||||
|
// الانتقال النهائي
|
||||||
|
Get.off(() => PassengerLocationMapPage(), arguments: rideArgs);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Log.print("Error in acceptOrder: $e");
|
||||||
|
} finally {
|
||||||
|
isAccepting = false;
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -412,10 +412,21 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==============================================================================
|
||||||
|
// 🟢 دوال معالجة قبول الطلب وتجهيز المتغيرات 🟢
|
||||||
|
// ==============================================================================
|
||||||
|
bool _isProcessingAccept = false;
|
||||||
|
|
||||||
// ==============================================================================
|
// ==============================================================================
|
||||||
// 🟢 دوال معالجة قبول الطلب وتجهيز المتغيرات 🟢
|
// 🟢 دوال معالجة قبول الطلب وتجهيز المتغيرات 🟢
|
||||||
// ==============================================================================
|
// ==============================================================================
|
||||||
Future<void> _processAcceptOrder(List<dynamic> data) async {
|
Future<void> _processAcceptOrder(List<dynamic> data) async {
|
||||||
|
if (_isProcessingAccept) {
|
||||||
|
print("⏳ _processAcceptOrder: Already accepting order, skipping duplicate request.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_isProcessingAccept = true;
|
||||||
|
|
||||||
Get.dialog(
|
Get.dialog(
|
||||||
WillPopScope(
|
WillPopScope(
|
||||||
onWillPop: () async => false,
|
onWillPop: () async => false,
|
||||||
@@ -485,6 +496,8 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
print("❌ Error in accept process: $e");
|
print("❌ Error in accept process: $e");
|
||||||
Get.snackbar("خطأ", "حدث خطأ غير متوقع");
|
Get.snackbar("خطأ", "حدث خطأ غير متوقع");
|
||||||
|
} finally {
|
||||||
|
_isProcessingAccept = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:siro_driver/constant/box_name.dart';
|
|
||||||
import 'package:siro_driver/constant/style.dart';
|
import 'package:siro_driver/constant/style.dart';
|
||||||
import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
||||||
import 'package:siro_driver/controller/home/captin/map_driver_controller.dart';
|
import 'package:siro_driver/controller/home/captin/map_driver_controller.dart';
|
||||||
|
import 'package:siro_driver/constant/currency.dart';
|
||||||
import '../../../constant/colors.dart';
|
import '../../../constant/colors.dart';
|
||||||
import '../../../controller/functions/location_controller.dart';
|
import '../../../controller/functions/location_controller.dart';
|
||||||
import '../../../main.dart';
|
|
||||||
import '../../Rate/rate_passenger.dart';
|
import '../../Rate/rate_passenger.dart';
|
||||||
import '../../widgets/my_textField.dart';
|
import '../../widgets/my_textField.dart';
|
||||||
import 'mapDriverWidgets/driver_end_ride_bar.dart';
|
import 'mapDriverWidgets/driver_end_ride_bar.dart';
|
||||||
@@ -15,7 +14,6 @@ import 'mapDriverWidgets/google_driver_map_page.dart';
|
|||||||
import 'mapDriverWidgets/google_map_app.dart';
|
import 'mapDriverWidgets/google_map_app.dart';
|
||||||
import 'mapDriverWidgets/passenger_info_window.dart';
|
import 'mapDriverWidgets/passenger_info_window.dart';
|
||||||
import 'mapDriverWidgets/sos_connect.dart';
|
import 'mapDriverWidgets/sos_connect.dart';
|
||||||
import 'mapDriverWidgets/sped_circle.dart';
|
|
||||||
|
|
||||||
class PassengerLocationMapPage extends StatelessWidget {
|
class PassengerLocationMapPage extends StatelessWidget {
|
||||||
PassengerLocationMapPage({super.key});
|
PassengerLocationMapPage({super.key});
|
||||||
@@ -409,7 +407,7 @@ class PricesWindow extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
Text(
|
||||||
'${controller.totalCost} ${'\$'.tr}',
|
'${controller.totalCost} ${CurrencyHelper.currency}',
|
||||||
style: AppStyle.headTitle2.copyWith(
|
style: AppStyle.headTitle2.copyWith(
|
||||||
color: Theme.of(context).textTheme.bodyLarge?.color,
|
color: Theme.of(context).textTheme.bodyLarge?.color,
|
||||||
fontSize: 42,
|
fontSize: 42,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import '../../../../controller/home/navigation/navigation_view.dart';
|
|||||||
import '../../../../controller/profile/setting_controller.dart';
|
import '../../../../controller/profile/setting_controller.dart';
|
||||||
import '../../../../env/env.dart';
|
import '../../../../env/env.dart';
|
||||||
import '../../../../main.dart';
|
import '../../../../main.dart';
|
||||||
|
import '../../../../print.dart';
|
||||||
import '../../../notification/available_rides_page.dart';
|
import '../../../notification/available_rides_page.dart';
|
||||||
import '../driver_map_page.dart';
|
import '../driver_map_page.dart';
|
||||||
import 'widget/connect.dart';
|
import 'widget/connect.dart';
|
||||||
@@ -603,11 +604,13 @@ class _FloatingControls extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
// Continue active ride
|
// Continue active ride
|
||||||
if (box.read(BoxName.rideStatus) == 'Applied' ||
|
if (box.read(BoxName.rideStatus) == 'Applied' ||
|
||||||
|
box.read(BoxName.rideStatus) == 'Apply' ||
|
||||||
box.read(BoxName.rideStatus) == 'Begin') ...[
|
box.read(BoxName.rideStatus) == 'Begin') ...[
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
_Fab(
|
_Fab(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (box.read(BoxName.rideStatus) == 'Applied') {
|
final status = box.read(BoxName.rideStatus);
|
||||||
|
if (status == 'Applied' || status == 'Apply') {
|
||||||
Get.to(() => PassengerLocationMapPage(),
|
Get.to(() => PassengerLocationMapPage(),
|
||||||
arguments: box.read(BoxName.rideArguments));
|
arguments: box.read(BoxName.rideArguments));
|
||||||
Get.put(MapDriverController())
|
Get.put(MapDriverController())
|
||||||
@@ -669,5 +672,27 @@ class _Fab extends StatelessWidget {
|
|||||||
// Helper
|
// Helper
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
Future<void> checkForAppliedRide(BuildContext context) async {
|
Future<void> checkForAppliedRide(BuildContext context) async {
|
||||||
checkForPendingOrderFromServer();
|
if (Get.currentRoute == '/passenger-location-map') return;
|
||||||
|
|
||||||
|
final localStatus = box.read(BoxName.rideStatus);
|
||||||
|
final localArgs = box.read(BoxName.rideArguments) ??
|
||||||
|
box.read(BoxName.rideArgumentsFromBackground);
|
||||||
|
|
||||||
|
if ((localStatus == 'Apply' ||
|
||||||
|
localStatus == 'Applied' ||
|
||||||
|
localStatus == 'Begin') &&
|
||||||
|
localArgs != null &&
|
||||||
|
localArgs != 'failure') {
|
||||||
|
Log.print("🔄 Auto-recovering active ride: status=$localStatus");
|
||||||
|
if (localStatus == 'Apply' || localStatus == 'Applied') {
|
||||||
|
Get.to(() => PassengerLocationMapPage(), arguments: localArgs);
|
||||||
|
Get.put(MapDriverController()).changeRideToBeginToPassenger();
|
||||||
|
} else if (localStatus == 'Begin') {
|
||||||
|
Get.to(() => PassengerLocationMapPage(), arguments: localArgs);
|
||||||
|
Get.put(MapDriverController()).startRideFromStartApp();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If no local active ride, check the server
|
||||||
|
await checkForPendingOrderFromServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,14 +219,16 @@ class _Divider extends StatelessWidget {
|
|||||||
// Server Helpers (unchanged logic)
|
// Server Helpers (unchanged logic)
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
bool _isCheckingPendingOrder = false;
|
||||||
|
|
||||||
Future<void> checkForPendingOrderFromServer() async {
|
Future<void> checkForPendingOrderFromServer() async {
|
||||||
bool isProcessing = false;
|
if (_isCheckingPendingOrder) return;
|
||||||
if (isProcessing) return;
|
if (Get.currentRoute == '/passenger-location-map') return;
|
||||||
|
|
||||||
final driverId = box.read(BoxName.driverID)?.toString();
|
final driverId = box.read(BoxName.driverID)?.toString();
|
||||||
if (driverId == null) return;
|
if (driverId == null) return;
|
||||||
|
|
||||||
isProcessing = true;
|
_isCheckingPendingOrder = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response = await CRUD().post(
|
var response = await CRUD().post(
|
||||||
@@ -258,7 +260,7 @@ Future<void> checkForPendingOrderFromServer() async {
|
|||||||
} catch (_) {
|
} catch (_) {
|
||||||
// silent
|
// silent
|
||||||
} finally {
|
} finally {
|
||||||
isProcessing = false;
|
_isCheckingPendingOrder = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import '../../../../controller/firebase/notification_service.dart';
|
|||||||
import '../../../../controller/functions/crud.dart';
|
import '../../../../controller/functions/crud.dart';
|
||||||
import '../../../../constant/links.dart';
|
import '../../../../constant/links.dart';
|
||||||
import '../../../widgets/my_textField.dart';
|
import '../../../widgets/my_textField.dart';
|
||||||
|
import '../../../../views/widgets/elevated_btn.dart';
|
||||||
|
|
||||||
class PassengerInfoWindow extends StatelessWidget {
|
class PassengerInfoWindow extends StatelessWidget {
|
||||||
const PassengerInfoWindow({super.key});
|
const PassengerInfoWindow({super.key});
|
||||||
@@ -251,7 +252,7 @@ class PassengerInfoWindow extends StatelessWidget {
|
|||||||
|
|
||||||
// --- الأزرار الرئيسية (وصلت / ابدأ) ---
|
// --- الأزرار الرئيسية (وصلت / ابدأ) ---
|
||||||
if (!controller.isRideBegin)
|
if (!controller.isRideBegin)
|
||||||
_buildActionButtons(controller),
|
_buildActionButtons(context, controller),
|
||||||
|
|
||||||
// --- زر الإلغاء المدفوع (بعد انتهاء وقت الانتظار) ---
|
// --- زر الإلغاء المدفوع (بعد انتهاء وقت الانتظار) ---
|
||||||
if (controller.isdriverWaitTimeEnd &&
|
if (controller.isdriverWaitTimeEnd &&
|
||||||
@@ -372,7 +373,7 @@ class PassengerInfoWindow extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildActionButtons(MapDriverController controller) {
|
Widget _buildActionButtons(BuildContext context, MapDriverController controller) {
|
||||||
if (controller.isArrivedSend) {
|
if (controller.isArrivedSend) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@@ -413,33 +414,33 @@ class PassengerInfoWindow extends StatelessWidget {
|
|||||||
// وقد يُسبب Get.back() اللاحق إغلاق صفحة الماب بدلاً من الـ loading dialog
|
// وقد يُسبب Get.back() اللاحق إغلاق صفحة الماب بدلاً من الـ loading dialog
|
||||||
Get.defaultDialog(
|
Get.defaultDialog(
|
||||||
title: "Start Trip?".tr,
|
title: "Start Trip?".tr,
|
||||||
titleStyle: const TextStyle(
|
titleStyle: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppColor.writeColor,
|
||||||
),
|
),
|
||||||
middleText: "Ensure the passenger is in the car.".tr,
|
middleText: "Ensure the passenger is in the car.".tr,
|
||||||
|
middleTextStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: AppColor.grayColor,
|
||||||
|
),
|
||||||
|
backgroundColor: Theme.of(context).cardColor,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
radius: 14,
|
radius: 18,
|
||||||
confirm: ElevatedButton(
|
confirm: MyElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
title: 'Start'.tr,
|
||||||
backgroundColor: const Color(0xFF27AE60),
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10)),
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// نُغلق الديالوج بـ Get.back() لضمان أن GetX يعرف أنه أُغلق
|
|
||||||
Get.back();
|
Get.back();
|
||||||
// ثم نُنفذ startRideFromDriver الذي يستخدم Get.dialog و Get.back بأمان
|
|
||||||
await controller.startRideFromDriver();
|
await controller.startRideFromDriver();
|
||||||
},
|
},
|
||||||
child: Text('Start'.tr,
|
kolor: AppColor.greenColor,
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold)),
|
|
||||||
),
|
),
|
||||||
cancel: TextButton(
|
cancel: TextButton(
|
||||||
onPressed: () => Get.back(),
|
onPressed: () => Get.back(),
|
||||||
child: Text('Cancel'.tr,
|
child: Text(
|
||||||
style: const TextStyle(color: Colors.grey)),
|
'Cancel'.tr,
|
||||||
|
style: TextStyle(color: AppColor.grayColor, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,13 +9,12 @@ import 'package:siro_driver/constant/api_key.dart';
|
|||||||
import 'package:siro_driver/models/overlay_service.dart';
|
import 'package:siro_driver/models/overlay_service.dart';
|
||||||
import '../../../../constant/box_name.dart';
|
import '../../../../constant/box_name.dart';
|
||||||
import '../../../../constant/links.dart';
|
import '../../../../constant/links.dart';
|
||||||
import '../../../../controller/firebase/firbase_messge.dart';
|
|
||||||
import '../../../../controller/firebase/local_notification.dart';
|
import '../../../../controller/firebase/local_notification.dart';
|
||||||
import '../../../../controller/firebase/notification_service.dart';
|
|
||||||
import '../../../../controller/functions/crud.dart';
|
import '../../../../controller/functions/crud.dart';
|
||||||
import '../../../../main.dart';
|
import '../../../../main.dart';
|
||||||
import '../../../../models/model/order_data.dart';
|
import '../../../../models/model/order_data.dart';
|
||||||
import '../../../../print.dart';
|
import '../../../../print.dart';
|
||||||
|
import '../../../../constant/currency.dart';
|
||||||
|
|
||||||
// === Enhanced Colors for Better Readability ===
|
// === Enhanced Colors for Better Readability ===
|
||||||
class AppColors {
|
class AppColors {
|
||||||
@@ -510,7 +509,7 @@ class _OrderOverlayState extends State<OrderOverlay>
|
|||||||
flex: 3,
|
flex: 3,
|
||||||
child: _buildHighlightInfo(
|
child: _buildHighlightInfo(
|
||||||
// FIX: Use the parsed priceValue here
|
// FIX: Use the parsed priceValue here
|
||||||
"${NumberFormat('#,##0').format(priceValue)} ل.س",
|
"${NumberFormat('#,##0').format(priceValue)} ${CurrencyHelper.currency}",
|
||||||
"السعر".tr,
|
"السعر".tr,
|
||||||
Icons.monetization_on_rounded,
|
Icons.monetization_on_rounded,
|
||||||
AppColors.priceHighlight,
|
AppColors.priceHighlight,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:intaleq_maps/intaleq_maps.dart';
|
|||||||
import 'package:siro_driver/constant/api_key.dart';
|
import 'package:siro_driver/constant/api_key.dart';
|
||||||
import 'package:siro_driver/constant/colors.dart';
|
import 'package:siro_driver/constant/colors.dart';
|
||||||
import 'package:siro_driver/controller/home/captin/order_request_controller.dart';
|
import 'package:siro_driver/controller/home/captin/order_request_controller.dart';
|
||||||
|
import 'package:siro_driver/constant/currency.dart';
|
||||||
|
|
||||||
class OrderRequestPage extends StatelessWidget {
|
class OrderRequestPage extends StatelessWidget {
|
||||||
const OrderRequestPage({super.key});
|
const OrderRequestPage({super.key});
|
||||||
@@ -43,10 +44,12 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
|
|
||||||
final String passengerName =
|
final String passengerName =
|
||||||
getValue(8).isEmpty ? "عميل" : getValue(8);
|
getValue(8).isEmpty ? "عميل" : getValue(8);
|
||||||
final String startAddr =
|
final String startAddr = controller.apiStartName.isNotEmpty
|
||||||
getValue(29).isEmpty ? "موقع الانطلاق" : getValue(29);
|
? controller.apiStartName
|
||||||
final String endAddr =
|
: (getValue(29).isEmpty ? "موقع الانطلاق" : getValue(29));
|
||||||
getValue(30).isEmpty ? "الوجهة" : getValue(30);
|
final String endAddr = controller.apiEndName.isNotEmpty
|
||||||
|
? controller.apiEndName
|
||||||
|
: (getValue(30).isEmpty ? "الوجهة" : getValue(30));
|
||||||
final bool isVisa = (getValue(13) == 'true');
|
final bool isVisa = (getValue(13) == 'true');
|
||||||
|
|
||||||
// منطق Speed = سعر ثابت
|
// منطق Speed = سعر ثابت
|
||||||
@@ -194,7 +197,7 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text("${controller.tripPrice} ل.س",
|
Text("${controller.tripPrice} ${CurrencyHelper.currency}",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -294,12 +297,12 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const Icon(Icons.my_location,
|
const Icon(Icons.my_location,
|
||||||
size: 18, color: Colors.green),
|
size: 18, color: Colors.green),
|
||||||
Expanded(
|
Container(
|
||||||
child: Container(
|
width: 2,
|
||||||
width: 2,
|
height: 38,
|
||||||
color: Colors.grey.shade300,
|
color: Colors.grey.shade300,
|
||||||
margin: const EdgeInsets.symmetric(
|
margin: const EdgeInsets.symmetric(
|
||||||
vertical: 2))),
|
vertical: 4)),
|
||||||
const Icon(Icons.location_on,
|
const Icon(Icons.location_on,
|
||||||
size: 18, color: Colors.red),
|
size: 18, color: Colors.red),
|
||||||
],
|
],
|
||||||
@@ -307,8 +310,6 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
@@ -319,15 +320,16 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color: Colors.grey)),
|
color: Colors.grey)),
|
||||||
|
const SizedBox(height: 2),
|
||||||
Text(startAddr,
|
Text(startAddr,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w600),
|
fontWeight: FontWeight.w600),
|
||||||
maxLines: 1,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis),
|
overflow: TextOverflow.ellipsis),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const SizedBox(height: 14),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
@@ -336,11 +338,12 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color: Colors.grey)),
|
color: Colors.grey)),
|
||||||
|
const SizedBox(height: 2),
|
||||||
Text(endAddr,
|
Text(endAddr,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w600),
|
fontWeight: FontWeight.w600),
|
||||||
maxLines: 1,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis),
|
overflow: TextOverflow.ellipsis),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -373,7 +376,9 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () => controller.acceptOrder(),
|
onPressed: controller.isAccepting
|
||||||
|
? null
|
||||||
|
: () => controller.acceptOrder(),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppColor.primaryColor,
|
backgroundColor: AppColor.primaryColor,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
@@ -386,24 +391,35 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Text("قبول الرحلة",
|
Text(
|
||||||
style: TextStyle(
|
controller.isAccepting
|
||||||
|
? "جاري القبول...".tr
|
||||||
|
: "قبول الرحلة".tr,
|
||||||
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
child: CircularProgressIndicator(
|
child: controller.isAccepting
|
||||||
value: controller.progress,
|
? const CircularProgressIndicator(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
strokeWidth: 2.5,
|
strokeWidth: 2.5,
|
||||||
backgroundColor: Colors.white24),
|
)
|
||||||
|
: CircularProgressIndicator(
|
||||||
|
value: controller.progress,
|
||||||
|
color: Colors.white,
|
||||||
|
strokeWidth: 2.5,
|
||||||
|
backgroundColor: Colors.white24),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
if (!controller.isAccepting) ...[
|
||||||
Text("${controller.remainingTime}",
|
const SizedBox(width: 8),
|
||||||
style: const TextStyle(
|
Text("${controller.remainingTime}",
|
||||||
fontSize: 14, color: Colors.white)),
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.white)),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:siro_driver/constant/colors.dart';
|
import 'package:siro_driver/constant/colors.dart';
|
||||||
import 'package:siro_driver/constant/style.dart';
|
import 'package:siro_driver/constant/style.dart';
|
||||||
import 'package:siro_driver/controller/functions/tts.dart';
|
import 'package:siro_driver/controller/functions/tts.dart';
|
||||||
|
import 'package:siro_driver/controller/functions/translate_helper.dart';
|
||||||
|
|
||||||
class DialogConfig {
|
class DialogConfig {
|
||||||
static const Duration animationDuration = Duration(milliseconds: 200);
|
static const Duration animationDuration = Duration(milliseconds: 200);
|
||||||
@@ -136,6 +137,158 @@ class MyDialog extends GetxController {
|
|||||||
barrierColor: Colors.black.withAlpha(102), // 0.4 opacity
|
barrierColor: Colors.black.withAlpha(102), // 0.4 opacity
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getChatDialog(String title, String body, VoidCallback onPressed) {
|
||||||
|
final textToSpeechController = Get.put(TextToSpeechController());
|
||||||
|
|
||||||
|
HapticFeedback.mediumImpact();
|
||||||
|
|
||||||
|
String currentText = body;
|
||||||
|
bool isTranslated = false;
|
||||||
|
bool isLoading = false;
|
||||||
|
|
||||||
|
Get.dialog(
|
||||||
|
StatefulBuilder(
|
||||||
|
builder: (context, setState) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return TweenAnimationBuilder<double>(
|
||||||
|
duration: DialogConfig.animationDuration,
|
||||||
|
tween: Tween(begin: 0.0, end: 1.0),
|
||||||
|
builder: (context, value, child) {
|
||||||
|
return Transform.scale(
|
||||||
|
scale: 0.95 + (0.05 * value),
|
||||||
|
child: Opacity(opacity: value, child: child),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(
|
||||||
|
sigmaX: DialogConfig.blurStrength,
|
||||||
|
sigmaY: DialogConfig.blurStrength,
|
||||||
|
),
|
||||||
|
child: Builder(builder: (context) {
|
||||||
|
return CupertinoAlertDialog(
|
||||||
|
title: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
title.tr,
|
||||||
|
style: AppStyle.title.copyWith(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
letterSpacing: -0.5,
|
||||||
|
color: AppColor.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
CupertinoButton(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
onPressed: () async {
|
||||||
|
HapticFeedback.selectionClick();
|
||||||
|
await textToSpeechController.speakText(title);
|
||||||
|
await textToSpeechController.speakText(currentText);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color:
|
||||||
|
AppColor.primaryColor.withAlpha(26), // 0.1 opacity
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
CupertinoIcons.speaker_2_fill,
|
||||||
|
color: AppColor.primaryColor,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
if (isLoading)
|
||||||
|
const Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
child: CupertinoActivityIndicator(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Text(
|
||||||
|
currentText,
|
||||||
|
style: AppStyle.title.copyWith(
|
||||||
|
fontSize: 16,
|
||||||
|
height: 1.3,
|
||||||
|
color: theme.textTheme.bodyLarge?.color ?? AppColor.writeColor,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
CupertinoDialogAction(
|
||||||
|
onPressed: () async {
|
||||||
|
if (isLoading) return;
|
||||||
|
HapticFeedback.lightImpact();
|
||||||
|
if (isTranslated) {
|
||||||
|
setState(() {
|
||||||
|
currentText = body;
|
||||||
|
isTranslated = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
final targetLang = Get.locale?.languageCode ?? 'ar';
|
||||||
|
final translated = await TranslateHelper.translateText(body, targetLang);
|
||||||
|
setState(() {
|
||||||
|
currentText = translated;
|
||||||
|
isTranslated = true;
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
isTranslated ? 'Original'.tr : 'Translate'.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColor.blueColor,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 17,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
CupertinoDialogAction(
|
||||||
|
onPressed: () {
|
||||||
|
HapticFeedback.mediumImpact();
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
onPressed();
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'OK'.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColor.greenColor,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 17,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
barrierDismissible: true,
|
||||||
|
barrierColor: Colors.black.withAlpha(102), // 0.4 opacity
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyDialogContent extends GetxController {
|
class MyDialogContent extends GetxController {
|
||||||
|
|||||||
@@ -117,10 +117,11 @@ class PhoneAuthHelper {
|
|||||||
String? email,
|
String? email,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
|
final fixedPhone = CountryLogic.formatCurrentCountryPhone(phoneNumber);
|
||||||
final response = await CRUD().post(
|
final response = await CRUD().post(
|
||||||
link: _registerUrl,
|
link: _registerUrl,
|
||||||
payload: {
|
payload: {
|
||||||
'phone_number': phoneNumber,
|
'phone_number': fixedPhone,
|
||||||
'first_name': firstName,
|
'first_name': firstName,
|
||||||
'last_name': lastName,
|
'last_name': lastName,
|
||||||
'email': email ?? '', // Send empty string if null
|
'email': email ?? '', // Send empty string if null
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import 'package:siro_rider/controller/voice_call_controller.dart';
|
|||||||
import '../home/map/ride_lifecycle_controller.dart';
|
import '../home/map/ride_lifecycle_controller.dart';
|
||||||
import '../home/map/ride_state.dart';
|
import '../home/map/ride_state.dart';
|
||||||
import 'local_notification.dart';
|
import 'local_notification.dart';
|
||||||
|
import '../../views/widgets/mydialoug.dart';
|
||||||
|
|
||||||
class FirebaseMessagesController extends GetxController {
|
class FirebaseMessagesController extends GetxController {
|
||||||
final fcmToken = FirebaseMessaging.instance;
|
final fcmToken = FirebaseMessaging.instance;
|
||||||
@@ -171,14 +172,22 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
notificationController.showNotification(title, body, 'ding');
|
notificationController.showNotification(title, body, 'ding');
|
||||||
}
|
}
|
||||||
passengerDialog(body);
|
MyDialog().getChatDialog(
|
||||||
|
title.isNotEmpty ? title : 'message From passenger'.tr,
|
||||||
|
body,
|
||||||
|
() {},
|
||||||
|
);
|
||||||
update();
|
update();
|
||||||
} else if (category == 'message From Driver') {
|
} else if (category == 'message From Driver') {
|
||||||
// <-- كان 'message From Driver'
|
// <-- كان 'message From Driver'
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
notificationController.showNotification(title, body, 'ding');
|
notificationController.showNotification(title, body, 'ding');
|
||||||
}
|
}
|
||||||
passengerDialog(body);
|
MyDialog().getChatDialog(
|
||||||
|
title.isNotEmpty ? title : 'message From Driver'.tr,
|
||||||
|
body,
|
||||||
|
() {},
|
||||||
|
);
|
||||||
update();
|
update();
|
||||||
} else if (category == 'Trip is Begin') {
|
} else if (category == 'Trip is Begin') {
|
||||||
// <-- كان 'Trip is Begin'
|
// <-- كان 'Trip is Begin'
|
||||||
|
|||||||
@@ -81,17 +81,55 @@ class CountryLogic {
|
|||||||
|
|
||||||
/// Helper to format phone using the current country in box.
|
/// Helper to format phone using the current country in box.
|
||||||
static String formatCurrentCountryPhone(String phone) {
|
static String formatCurrentCountryPhone(String phone) {
|
||||||
String cleanPhone = phone.replaceAll(RegExp(r'[ \-\(\)]'), '').trim();
|
String cleanPhone = phone.replaceAll(RegExp(r'[ \-\(\)\+]'), '').trim();
|
||||||
if (cleanPhone.startsWith('+963') || cleanPhone.startsWith('00963')) {
|
|
||||||
|
// 1. Explicit International Code Detection
|
||||||
|
if (cleanPhone.startsWith('00963')) {
|
||||||
|
cleanPhone = cleanPhone.replaceFirst('00963', '963');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('00962')) {
|
||||||
|
cleanPhone = cleanPhone.replaceFirst('00962', '962');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('0020')) {
|
||||||
|
cleanPhone = cleanPhone.replaceFirst('0020', '20');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cleanPhone.startsWith('963')) {
|
||||||
return formatPhone(cleanPhone, 'Syria');
|
return formatPhone(cleanPhone, 'Syria');
|
||||||
}
|
}
|
||||||
if (cleanPhone.startsWith('+20') || cleanPhone.startsWith('0020')) {
|
if (cleanPhone.startsWith('962')) {
|
||||||
|
return formatPhone(cleanPhone, 'Jordan');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('20')) {
|
||||||
return formatPhone(cleanPhone, 'Egypt');
|
return formatPhone(cleanPhone, 'Egypt');
|
||||||
}
|
}
|
||||||
if (cleanPhone.startsWith('+962') || cleanPhone.startsWith('00962')) {
|
|
||||||
|
// 2. Local/National Format Detection by Country-Specific Mobile Prefixes
|
||||||
|
// Jordan: 07x / 7x (9 national digits)
|
||||||
|
if (cleanPhone.startsWith('07') && cleanPhone.length == 10) {
|
||||||
|
return formatPhone(cleanPhone, 'Jordan');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('7') && cleanPhone.length == 9) {
|
||||||
return formatPhone(cleanPhone, 'Jordan');
|
return formatPhone(cleanPhone, 'Jordan');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Syria: 09x / 9x (9 national digits)
|
||||||
|
if (cleanPhone.startsWith('09') && cleanPhone.length == 10) {
|
||||||
|
return formatPhone(cleanPhone, 'Syria');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('9') && cleanPhone.length == 9) {
|
||||||
|
return formatPhone(cleanPhone, 'Syria');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Egypt: 01x (10 national digits) / 1x (9 national digits)
|
||||||
|
if (cleanPhone.startsWith('01') && cleanPhone.length == 11) {
|
||||||
|
return formatPhone(cleanPhone, 'Egypt');
|
||||||
|
}
|
||||||
|
if (cleanPhone.startsWith('1') && cleanPhone.length == 10) {
|
||||||
|
return formatPhone(cleanPhone, 'Egypt');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Fallback: Default to current user's country code saved in box
|
||||||
final country = box.read(BoxName.countryCode) ?? 'Jordan';
|
final country = box.read(BoxName.countryCode) ?? 'Jordan';
|
||||||
return formatPhone(cleanPhone, country);
|
return formatPhone(cleanPhone, country);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ void showInBrowser(String url) async {
|
|||||||
} else {}
|
} else {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> makePhoneCall(String phoneNumber) async {
|
String cleanAndFormatPhoneNumber(String phoneNumber) {
|
||||||
String formattedNumber = phoneNumber.replaceAll(RegExp(r'\s+'), '');
|
String formattedNumber = phoneNumber.replaceAll(RegExp(r'\s+'), '');
|
||||||
|
|
||||||
if (formattedNumber.length > 6) {
|
if (formattedNumber.length > 6) {
|
||||||
@@ -18,6 +18,11 @@ Future<void> makePhoneCall(String phoneNumber) async {
|
|||||||
formattedNumber = '+$formattedNumber';
|
formattedNumber = '+$formattedNumber';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return formattedNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> makePhoneCall(String phoneNumber) async {
|
||||||
|
String formattedNumber = cleanAndFormatPhoneNumber(phoneNumber);
|
||||||
// ملاحظة: الأرقام القصيرة (مثل 112) ستتجاوز الشرط أعلاه وتبقى "112" وهو الصحيح
|
// ملاحظة: الأرقام القصيرة (مثل 112) ستتجاوز الشرط أعلاه وتبقى "112" وهو الصحيح
|
||||||
|
|
||||||
// 3. التنفيذ (Launch)
|
// 3. التنفيذ (Launch)
|
||||||
@@ -44,23 +49,26 @@ Future<void> makePhoneCall(String phoneNumber) async {
|
|||||||
|
|
||||||
void launchCommunication(
|
void launchCommunication(
|
||||||
String method, String contactInfo, String message) async {
|
String method, String contactInfo, String message) async {
|
||||||
|
String formattedContact = cleanAndFormatPhoneNumber(contactInfo);
|
||||||
|
// WhatsApp prefers the phone number without the '+' prefix
|
||||||
|
String whatsappContact = formattedContact.replaceAll('+', '');
|
||||||
String url;
|
String url;
|
||||||
|
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'phone':
|
case 'phone':
|
||||||
url = 'tel:$contactInfo';
|
url = 'tel:$formattedContact';
|
||||||
break;
|
break;
|
||||||
case 'sms':
|
case 'sms':
|
||||||
url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}';
|
url = 'sms:$formattedContact?body=${Uri.encodeComponent(message)}';
|
||||||
break;
|
break;
|
||||||
case 'whatsapp':
|
case 'whatsapp':
|
||||||
url =
|
url =
|
||||||
'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
|
'https://api.whatsapp.com/send?phone=$whatsappContact&text=${Uri.encodeComponent(message)}';
|
||||||
break;
|
break;
|
||||||
case 'email':
|
case 'email':
|
||||||
url =
|
url =
|
||||||
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
|
'mailto:$formattedContact?subject=Subject&body=${Uri.encodeComponent(message)}';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@@ -68,11 +76,11 @@ void launchCommunication(
|
|||||||
} else if (Platform.isAndroid) {
|
} else if (Platform.isAndroid) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'phone':
|
case 'phone':
|
||||||
url = 'tel:$contactInfo';
|
url = 'tel:$formattedContact';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sms':
|
case 'sms':
|
||||||
url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}';
|
url = 'sms:$formattedContact?body=${Uri.encodeComponent(message)}';
|
||||||
break;
|
break;
|
||||||
case 'whatsapp':
|
case 'whatsapp':
|
||||||
// Check if WhatsApp is installed
|
// Check if WhatsApp is installed
|
||||||
@@ -80,16 +88,16 @@ void launchCommunication(
|
|||||||
await canLaunchUrl(Uri.parse('whatsapp://'));
|
await canLaunchUrl(Uri.parse('whatsapp://'));
|
||||||
if (whatsappInstalled) {
|
if (whatsappInstalled) {
|
||||||
url =
|
url =
|
||||||
'whatsapp://send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
|
'whatsapp://send?phone=$whatsappContact&text=${Uri.encodeComponent(message)}';
|
||||||
} else {
|
} else {
|
||||||
// Provide an alternative action, such as opening the WhatsApp Web API
|
// Provide an alternative action, such as opening the WhatsApp Web API
|
||||||
url =
|
url =
|
||||||
'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
|
'https://api.whatsapp.com/send?phone=$whatsappContact&text=${Uri.encodeComponent(message)}';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'email':
|
case 'email':
|
||||||
url =
|
url =
|
||||||
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
|
'mailto:$formattedContact?subject=Subject&body=${Uri.encodeComponent(message)}';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
|||||||
30
siro_rider/lib/controller/functions/translate_helper.dart
Normal file
30
siro_rider/lib/controller/functions/translate_helper.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
class TranslateHelper {
|
||||||
|
static Future<String> translateText(String text, String targetLang) async {
|
||||||
|
if (text.isEmpty) return text;
|
||||||
|
try {
|
||||||
|
final url = Uri.parse(
|
||||||
|
'https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=$targetLang&dt=t&q=${Uri.encodeComponent(text)}'
|
||||||
|
);
|
||||||
|
final response = await http.get(url);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final decoded = jsonDecode(response.body);
|
||||||
|
if (decoded != null && decoded is List && decoded.isNotEmpty && decoded[0] is List) {
|
||||||
|
final List parts = decoded[0];
|
||||||
|
String translated = '';
|
||||||
|
for (var part in parts) {
|
||||||
|
if (part is List && part.isNotEmpty) {
|
||||||
|
translated += part[0].toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return translated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Fallback to original text on any exception
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -293,7 +293,7 @@ class ApplyOrderWidget extends StatelessWidget {
|
|||||||
const Icon(Icons.star_rounded,
|
const Icon(Icons.star_rounded,
|
||||||
color: Colors.amber, size: 14),
|
color: Colors.amber, size: 14),
|
||||||
Text(
|
Text(
|
||||||
" ${controller.driverRate} • ${controller.model}",
|
" ${controller.driverRate} • ${controller.model}${controller.carColor.isNotEmpty ? ' • ${controller.carColor.tr}' : ''}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: Colors.grey[700],
|
color: Colors.grey[700],
|
||||||
@@ -356,23 +356,25 @@ class ApplyOrderWidget extends StatelessWidget {
|
|||||||
final bool isBike = vehicleText.contains('scooter') ||
|
final bool isBike = vehicleText.contains('scooter') ||
|
||||||
vehicleText.contains('bike') ||
|
vehicleText.contains('bike') ||
|
||||||
vehicleText.contains('دراجة');
|
vehicleText.contains('دراجة');
|
||||||
return Container(
|
return AnimatedCarIcon(
|
||||||
height: 40, // تصغير من 50
|
child: Container(
|
||||||
width: 40,
|
height: 40, // تصغير من 50
|
||||||
decoration: BoxDecoration(
|
width: 40,
|
||||||
color: carColor.withOpacity(0.1),
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
color: carColor.withOpacity(0.1),
|
||||||
),
|
borderRadius: BorderRadius.circular(8),
|
||||||
padding: const EdgeInsets.all(4),
|
),
|
||||||
child: ColorFiltered(
|
padding: const EdgeInsets.all(4),
|
||||||
colorFilter: ColorFilter.mode(carColor, BlendMode.srcIn),
|
child: ColorFiltered(
|
||||||
child: Image.asset(
|
colorFilter: ColorFilter.mode(carColor, BlendMode.srcIn),
|
||||||
isBike ||
|
child: Image.asset(
|
||||||
box.read(BoxName.carType) == 'Scooter' ||
|
isBike ||
|
||||||
box.read(BoxName.carType) == 'Pink Bike'
|
box.read(BoxName.carType) == 'Scooter' ||
|
||||||
? 'assets/images/moto.png'
|
box.read(BoxName.carType) == 'Pink Bike'
|
||||||
: 'assets/images/car3.png',
|
? 'assets/images/moto.png'
|
||||||
fit: BoxFit.contain,
|
: 'assets/images/car3.png',
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -841,3 +843,48 @@ class TimeDriverToPassenger extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AnimatedCarIcon extends StatefulWidget {
|
||||||
|
final Widget child;
|
||||||
|
const AnimatedCarIcon({Key? key, required this.child}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AnimatedCarIcon> createState() => _AnimatedCarIconState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AnimatedCarIconState extends State<AnimatedCarIcon>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController _controller;
|
||||||
|
late final Animation<Offset> _animation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_controller = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
)..repeat(reverse: true);
|
||||||
|
|
||||||
|
_animation = Tween<Offset>(
|
||||||
|
begin: const Offset(-0.06, 0.0),
|
||||||
|
end: const Offset(0.06, 0.0),
|
||||||
|
).animate(CurvedAnimation(
|
||||||
|
parent: _controller,
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SlideTransition(
|
||||||
|
position: _animation,
|
||||||
|
child: widget.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class RideBeginPassenger extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${controller.model} • ',
|
'${controller.model}${controller.carColor.isNotEmpty ? " • ${controller.carColor.tr}" : ""} • ',
|
||||||
style: TextStyle(fontSize: 12, color: AppColor.grayColor),
|
style: TextStyle(fontSize: 12, color: AppColor.grayColor),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
|||||||
@@ -97,6 +97,15 @@ class VipRideBeginPassenger extends StatelessWidget {
|
|||||||
controller.model,
|
controller.model,
|
||||||
style: AppStyle.title,
|
style: AppStyle.title,
|
||||||
),
|
),
|
||||||
|
if (controller.carColor.isNotEmpty) ...[
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
controller.carColor.tr,
|
||||||
|
style: AppStyle.title,
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:get/get.dart';
|
|||||||
import '../../constant/colors.dart';
|
import '../../constant/colors.dart';
|
||||||
import '../../constant/style.dart';
|
import '../../constant/style.dart';
|
||||||
import '../../controller/functions/tts.dart';
|
import '../../controller/functions/tts.dart';
|
||||||
|
import '../../controller/functions/translate_helper.dart';
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
// Config
|
// Config
|
||||||
@@ -417,6 +418,167 @@ class MyDialog extends GetxController {
|
|||||||
barrierColor: _DC.barrierColor,
|
barrierColor: _DC.barrierColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getChatDialog(
|
||||||
|
String title,
|
||||||
|
String messageContent,
|
||||||
|
VoidCallback onPressed, {
|
||||||
|
IconData? icon,
|
||||||
|
}) {
|
||||||
|
HapticFeedback.mediumImpact();
|
||||||
|
|
||||||
|
String displayedText = messageContent;
|
||||||
|
bool isTranslated = false;
|
||||||
|
bool isLoading = false;
|
||||||
|
|
||||||
|
Get.dialog(
|
||||||
|
StatefulBuilder(
|
||||||
|
builder: (dialogContext, setState) {
|
||||||
|
return _DialogShell(
|
||||||
|
child: _GlassCard(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// ── Body ──────────────────────────────────────────────
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(24, 28, 24, 20),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Icon badge
|
||||||
|
Container(
|
||||||
|
width: 56,
|
||||||
|
height: 56,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: AppColor.primaryColor.withOpacity(0.1),
|
||||||
|
border: Border.all(
|
||||||
|
color: AppColor.primaryColor.withOpacity(0.2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
icon ?? Icons.chat_bubble_outline_rounded,
|
||||||
|
color: AppColor.primaryColor,
|
||||||
|
size: 26,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Title
|
||||||
|
Text(
|
||||||
|
title.tr,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: AppStyle.title.copyWith(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
letterSpacing: -0.4,
|
||||||
|
color: AppColor.writeColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
if (isLoading)
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 20),
|
||||||
|
child: Center(
|
||||||
|
child: CupertinoActivityIndicator(radius: 12),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Text(
|
||||||
|
displayedText,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: AppStyle.subtitle.copyWith(
|
||||||
|
fontSize: 14.5,
|
||||||
|
height: 1.5,
|
||||||
|
color: Colors.grey[600],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// TTS button
|
||||||
|
_SpeakButton(
|
||||||
|
texts: [title.tr, displayedText],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// ── Actions ───────────────────────────────────────────
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(color: Colors.grey.withOpacity(0.15), width: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// Translate Toggle
|
||||||
|
Expanded(
|
||||||
|
child: _ActionButton(
|
||||||
|
label: isTranslated ? 'Original'.tr : 'Translate'.tr,
|
||||||
|
color: AppColor.blueColor,
|
||||||
|
backgroundColor: AppColor.blueColor.withOpacity(0.07),
|
||||||
|
onPressed: () async {
|
||||||
|
if (isLoading) return;
|
||||||
|
HapticFeedback.lightImpact();
|
||||||
|
if (isTranslated) {
|
||||||
|
setState(() {
|
||||||
|
displayedText = messageContent;
|
||||||
|
isTranslated = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
final targetLang = Get.locale?.languageCode ?? 'ar';
|
||||||
|
final translated = await TranslateHelper.translateText(messageContent, targetLang);
|
||||||
|
setState(() {
|
||||||
|
displayedText = translated;
|
||||||
|
isTranslated = true;
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isLeft: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(width: 1, height: 52, color: Colors.grey.withOpacity(0.15)),
|
||||||
|
// Confirm
|
||||||
|
Expanded(
|
||||||
|
child: _ActionButton(
|
||||||
|
label: 'OK'.tr,
|
||||||
|
color: AppColor.primaryColor,
|
||||||
|
backgroundColor: AppColor.primaryColor.withOpacity(0.07),
|
||||||
|
onPressed: () {
|
||||||
|
HapticFeedback.mediumImpact();
|
||||||
|
Navigator.of(dialogContext, rootNavigator: true).pop();
|
||||||
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
onPressed();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isLeft: false,
|
||||||
|
isBold: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
barrierDismissible: true,
|
||||||
|
barrierColor: _DC.barrierColor,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user