Update: 2026-06-14 05:48:58
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.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/views/widgets/elevated_btn.dart';
|
||||
import 'package:siro_driver/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:siro_driver/constant/currency.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../controller/functions/location_controller.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../Rate/rate_passenger.dart';
|
||||
import '../../widgets/my_textField.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/passenger_info_window.dart';
|
||||
import 'mapDriverWidgets/sos_connect.dart';
|
||||
import 'mapDriverWidgets/sped_circle.dart';
|
||||
|
||||
class PassengerLocationMapPage extends StatelessWidget {
|
||||
PassengerLocationMapPage({super.key});
|
||||
@@ -409,7 +407,7 @@ class PricesWindow extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
'${controller.totalCost} ${'\$'.tr}',
|
||||
'${controller.totalCost} ${CurrencyHelper.currency}',
|
||||
style: AppStyle.headTitle2.copyWith(
|
||||
color: Theme.of(context).textTheme.bodyLarge?.color,
|
||||
fontSize: 42,
|
||||
|
||||
@@ -21,6 +21,7 @@ import '../../../../controller/home/navigation/navigation_view.dart';
|
||||
import '../../../../controller/profile/setting_controller.dart';
|
||||
import '../../../../env/env.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../../print.dart';
|
||||
import '../../../notification/available_rides_page.dart';
|
||||
import '../driver_map_page.dart';
|
||||
import 'widget/connect.dart';
|
||||
@@ -603,11 +604,13 @@ class _FloatingControls extends StatelessWidget {
|
||||
),
|
||||
// Continue active ride
|
||||
if (box.read(BoxName.rideStatus) == 'Applied' ||
|
||||
box.read(BoxName.rideStatus) == 'Apply' ||
|
||||
box.read(BoxName.rideStatus) == 'Begin') ...[
|
||||
const SizedBox(height: 10),
|
||||
_Fab(
|
||||
onTap: () {
|
||||
if (box.read(BoxName.rideStatus) == 'Applied') {
|
||||
final status = box.read(BoxName.rideStatus);
|
||||
if (status == 'Applied' || status == 'Apply') {
|
||||
Get.to(() => PassengerLocationMapPage(),
|
||||
arguments: box.read(BoxName.rideArguments));
|
||||
Get.put(MapDriverController())
|
||||
@@ -669,5 +672,27 @@ class _Fab extends StatelessWidget {
|
||||
// Helper
|
||||
// ─────────────────────────────────────────────
|
||||
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)
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
bool _isCheckingPendingOrder = false;
|
||||
|
||||
Future<void> checkForPendingOrderFromServer() async {
|
||||
bool isProcessing = false;
|
||||
if (isProcessing) return;
|
||||
if (_isCheckingPendingOrder) return;
|
||||
if (Get.currentRoute == '/passenger-location-map') return;
|
||||
|
||||
final driverId = box.read(BoxName.driverID)?.toString();
|
||||
if (driverId == null) return;
|
||||
|
||||
isProcessing = true;
|
||||
_isCheckingPendingOrder = true;
|
||||
|
||||
try {
|
||||
var response = await CRUD().post(
|
||||
@@ -258,7 +260,7 @@ Future<void> checkForPendingOrderFromServer() async {
|
||||
} catch (_) {
|
||||
// silent
|
||||
} finally {
|
||||
isProcessing = false;
|
||||
_isCheckingPendingOrder = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import '../../../../controller/firebase/notification_service.dart';
|
||||
import '../../../../controller/functions/crud.dart';
|
||||
import '../../../../constant/links.dart';
|
||||
import '../../../widgets/my_textField.dart';
|
||||
import '../../../../views/widgets/elevated_btn.dart';
|
||||
|
||||
class PassengerInfoWindow extends StatelessWidget {
|
||||
const PassengerInfoWindow({super.key});
|
||||
@@ -251,7 +252,7 @@ class PassengerInfoWindow extends StatelessWidget {
|
||||
|
||||
// --- الأزرار الرئيسية (وصلت / ابدأ) ---
|
||||
if (!controller.isRideBegin)
|
||||
_buildActionButtons(controller),
|
||||
_buildActionButtons(context, controller),
|
||||
|
||||
// --- زر الإلغاء المدفوع (بعد انتهاء وقت الانتظار) ---
|
||||
if (controller.isdriverWaitTimeEnd &&
|
||||
@@ -372,7 +373,7 @@ class PassengerInfoWindow extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionButtons(MapDriverController controller) {
|
||||
Widget _buildActionButtons(BuildContext context, MapDriverController controller) {
|
||||
if (controller.isArrivedSend) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
@@ -413,33 +414,33 @@ class PassengerInfoWindow extends StatelessWidget {
|
||||
// وقد يُسبب Get.back() اللاحق إغلاق صفحة الماب بدلاً من الـ loading dialog
|
||||
Get.defaultDialog(
|
||||
title: "Start Trip?".tr,
|
||||
titleStyle: const TextStyle(
|
||||
titleStyle: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.writeColor,
|
||||
),
|
||||
middleText: "Ensure the passenger is in the car.".tr,
|
||||
middleTextStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColor.grayColor,
|
||||
),
|
||||
backgroundColor: Theme.of(context).cardColor,
|
||||
barrierDismissible: true,
|
||||
radius: 14,
|
||||
confirm: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF27AE60),
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
radius: 18,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Start'.tr,
|
||||
onPressed: () async {
|
||||
// نُغلق الديالوج بـ Get.back() لضمان أن GetX يعرف أنه أُغلق
|
||||
Get.back();
|
||||
// ثم نُنفذ startRideFromDriver الذي يستخدم Get.dialog و Get.back بأمان
|
||||
await controller.startRideFromDriver();
|
||||
},
|
||||
child: Text('Start'.tr,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: Text('Cancel'.tr,
|
||||
style: const TextStyle(color: Colors.grey)),
|
||||
child: Text(
|
||||
'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 '../../../../constant/box_name.dart';
|
||||
import '../../../../constant/links.dart';
|
||||
import '../../../../controller/firebase/firbase_messge.dart';
|
||||
import '../../../../controller/firebase/local_notification.dart';
|
||||
import '../../../../controller/firebase/notification_service.dart';
|
||||
import '../../../../controller/functions/crud.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../../models/model/order_data.dart';
|
||||
import '../../../../print.dart';
|
||||
import '../../../../constant/currency.dart';
|
||||
|
||||
// === Enhanced Colors for Better Readability ===
|
||||
class AppColors {
|
||||
@@ -510,7 +509,7 @@ class _OrderOverlayState extends State<OrderOverlay>
|
||||
flex: 3,
|
||||
child: _buildHighlightInfo(
|
||||
// FIX: Use the parsed priceValue here
|
||||
"${NumberFormat('#,##0').format(priceValue)} ل.س",
|
||||
"${NumberFormat('#,##0').format(priceValue)} ${CurrencyHelper.currency}",
|
||||
"السعر".tr,
|
||||
Icons.monetization_on_rounded,
|
||||
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/colors.dart';
|
||||
import 'package:siro_driver/controller/home/captin/order_request_controller.dart';
|
||||
import 'package:siro_driver/constant/currency.dart';
|
||||
|
||||
class OrderRequestPage extends StatelessWidget {
|
||||
const OrderRequestPage({super.key});
|
||||
@@ -43,10 +44,12 @@ class OrderRequestPage extends StatelessWidget {
|
||||
|
||||
final String passengerName =
|
||||
getValue(8).isEmpty ? "عميل" : getValue(8);
|
||||
final String startAddr =
|
||||
getValue(29).isEmpty ? "موقع الانطلاق" : getValue(29);
|
||||
final String endAddr =
|
||||
getValue(30).isEmpty ? "الوجهة" : getValue(30);
|
||||
final String startAddr = controller.apiStartName.isNotEmpty
|
||||
? controller.apiStartName
|
||||
: (getValue(29).isEmpty ? "موقع الانطلاق" : getValue(29));
|
||||
final String endAddr = controller.apiEndName.isNotEmpty
|
||||
? controller.apiEndName
|
||||
: (getValue(30).isEmpty ? "الوجهة" : getValue(30));
|
||||
final bool isVisa = (getValue(13) == 'true');
|
||||
|
||||
// منطق Speed = سعر ثابت
|
||||
@@ -194,7 +197,7 @@ class OrderRequestPage extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text("${controller.tripPrice} ل.س",
|
||||
Text("${controller.tripPrice} ${CurrencyHelper.currency}",
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -294,12 +297,12 @@ class OrderRequestPage extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.my_location,
|
||||
size: 18, color: Colors.green),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: 2,
|
||||
color: Colors.grey.shade300,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 2))),
|
||||
Container(
|
||||
width: 2,
|
||||
height: 38,
|
||||
color: Colors.grey.shade300,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 4)),
|
||||
const Icon(Icons.location_on,
|
||||
size: 18, color: Colors.red),
|
||||
],
|
||||
@@ -307,8 +310,6 @@ class OrderRequestPage extends StatelessWidget {
|
||||
const SizedBox(width: 15),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
@@ -319,15 +320,16 @@ class OrderRequestPage extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.grey)),
|
||||
const SizedBox(height: 2),
|
||||
Text(startAddr,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600),
|
||||
maxLines: 1,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
const SizedBox(height: 14),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
@@ -336,11 +338,12 @@ class OrderRequestPage extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.grey)),
|
||||
const SizedBox(height: 2),
|
||||
Text(endAddr,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600),
|
||||
maxLines: 1,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
],
|
||||
),
|
||||
@@ -373,7 +376,9 @@ class OrderRequestPage extends StatelessWidget {
|
||||
const SizedBox(width: 15),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () => controller.acceptOrder(),
|
||||
onPressed: controller.isAccepting
|
||||
? null
|
||||
: () => controller.acceptOrder(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
@@ -386,24 +391,35 @@ class OrderRequestPage extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text("قبول الرحلة",
|
||||
style: TextStyle(
|
||||
Text(
|
||||
controller.isAccepting
|
||||
? "جاري القبول...".tr
|
||||
: "قبول الرحلة".tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold)),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
value: controller.progress,
|
||||
color: Colors.white,
|
||||
strokeWidth: 2.5,
|
||||
backgroundColor: Colors.white24),
|
||||
child: controller.isAccepting
|
||||
? const CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2.5,
|
||||
)
|
||||
: CircularProgressIndicator(
|
||||
value: controller.progress,
|
||||
color: Colors.white,
|
||||
strokeWidth: 2.5,
|
||||
backgroundColor: Colors.white24),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text("${controller.remainingTime}",
|
||||
style: const TextStyle(
|
||||
fontSize: 14, color: Colors.white)),
|
||||
if (!controller.isAccepting) ...[
|
||||
const SizedBox(width: 8),
|
||||
Text("${controller.remainingTime}",
|
||||
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/style.dart';
|
||||
import 'package:siro_driver/controller/functions/tts.dart';
|
||||
import 'package:siro_driver/controller/functions/translate_helper.dart';
|
||||
|
||||
class DialogConfig {
|
||||
static const Duration animationDuration = Duration(milliseconds: 200);
|
||||
@@ -136,6 +137,158 @@ class MyDialog extends GetxController {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user