254 lines
9.5 KiB
Dart
Executable File
254 lines
9.5 KiB
Dart
Executable File
import 'package:sefer_driver/constant/style.dart';
|
|
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:sefer_driver/controller/home/captin/map_driver_controller.dart';
|
|
|
|
import '../../../constant/colors.dart';
|
|
import '../../../controller/functions/location_controller.dart';
|
|
import '../../Rate/rate_passenger.dart';
|
|
import '../../widgets/my_textField.dart';
|
|
import 'mapDriverWidgets/driver_end_ride_bar.dart';
|
|
import 'mapDriverWidgets/google_driver_map_page.dart';
|
|
import 'mapDriverWidgets/passenger_info_window.dart';
|
|
import 'mapDriverWidgets/sos_connect.dart';
|
|
|
|
// Changed: تم إعادة بناء الصفحة بالكامل لتكون أكثر تنظيمًا
|
|
class PassengerLocationMapPage extends StatelessWidget {
|
|
PassengerLocationMapPage({super.key});
|
|
final LocationController locationController = Get.put(LocationController());
|
|
final MapDriverController mapDriverController =
|
|
Get.put(MapDriverController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// New: استخدام addPostFrameCallback لضمان أن تحميل البيانات يتم بعد بناء الواجهة
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
if (Get.arguments != null && Get.arguments is Map<String, dynamic>) {
|
|
mapDriverController.argumentLoading();
|
|
mapDriverController.startTimerToShowPassengerInfoWindowFromDriver();
|
|
} else {
|
|
// في حال عدم وجود arguments، يتم التعامل مع هذا الخطأ
|
|
Get.snackbar("Error", "No order data found.");
|
|
Get.back();
|
|
}
|
|
});
|
|
|
|
return Scaffold(
|
|
body: SafeArea(
|
|
child: Stack(
|
|
children: [
|
|
// 1. الخريطة في الخلفية
|
|
GoogleDriverMap(locationController: locationController),
|
|
|
|
// 2. شريط تعليمات الطريق في الأعلى
|
|
const InstructionsOfRoads(),
|
|
|
|
// 3. زر إلغاء الرحلة في الأعلى يسارًا
|
|
CancelWidget(mapDriverController: mapDriverController),
|
|
|
|
// 4. نافذة معلومات الراكب في الأسفل (تظهر قبل بدء الرحلة)
|
|
const PassengerInfoWindow(),
|
|
|
|
// 5. شريط معلومات وإنهاء الرحلة (يظهر بعد بدء الرحلة)
|
|
driverEndRideBar(),
|
|
|
|
// 6. أزرار الطوارئ والاتصال
|
|
const SosConnect(),
|
|
|
|
// 7. دائرة عرض السرعة
|
|
speedCircle(),
|
|
|
|
// 8. نافذة عرض السعر النهائي (تظهر بعد انتهاء الرحلة)
|
|
const PricesWindow(),
|
|
],
|
|
),
|
|
));
|
|
}
|
|
}
|
|
|
|
// New: تصميم جديد لشريط تعليمات الطريق في أعلى الشاشة
|
|
class InstructionsOfRoads extends StatelessWidget {
|
|
const InstructionsOfRoads({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<MapDriverController>(
|
|
builder: (controller) =>
|
|
// يتم إظهار التعليمات فقط إذا كانت متوفرة
|
|
controller.currentInstruction.isNotEmpty
|
|
? Positioned(
|
|
bottom: 10,
|
|
left: MediaQuery.of(context).size.width * 0.15,
|
|
right: MediaQuery.of(context).size.width * 0.15,
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 300),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 16, vertical: 12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(30),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.2),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 4),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(Icons.directions,
|
|
color: AppColor.primaryColor),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: Text(
|
|
controller.currentInstruction,
|
|
style: AppStyle.title.copyWith(fontSize: 16),
|
|
textAlign: TextAlign.center,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox(), // في حالة عدم وجود تعليمات، لا يظهر شيء
|
|
);
|
|
}
|
|
}
|
|
|
|
// Changed: تم تعديل تصميم وموضع زر الإلغاء ليكون أيقونة بسيطة في الأعلى
|
|
class CancelWidget extends StatelessWidget {
|
|
const CancelWidget({
|
|
super.key,
|
|
required this.mapDriverController,
|
|
});
|
|
|
|
final MapDriverController mapDriverController;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Positioned(
|
|
top: 10,
|
|
left: 10,
|
|
child: GetBuilder<MapDriverController>(
|
|
builder: (controller) {
|
|
// يظهر زر الإلغاء فقط قبل انتهاء الرحلة
|
|
if (controller.isRideFinished) return const SizedBox.shrink();
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
Get.defaultDialog(
|
|
title: "Are you sure you want to cancel this trip?".tr,
|
|
titleStyle: AppStyle.title,
|
|
content: Column(
|
|
children: [
|
|
Text("Why do you want to cancel this trip?".tr),
|
|
Form(
|
|
key: mapDriverController.formKeyCancel,
|
|
child: MyTextForm(
|
|
controller: mapDriverController.cancelTripCotroller,
|
|
label: "Write the reason for canceling the trip".tr,
|
|
hint: "Write the reason for canceling the trip".tr,
|
|
type: TextInputType.name,
|
|
))
|
|
],
|
|
),
|
|
confirm: MyElevatedButton(
|
|
title: 'Ok'.tr,
|
|
kolor: AppColor.redColor,
|
|
onPressed: () async {
|
|
await mapDriverController
|
|
.cancelTripFromDriverAfterApplied();
|
|
Get.back();
|
|
}),
|
|
cancel: MyElevatedButton(
|
|
title: 'No'.tr,
|
|
onPressed: () {
|
|
Get.back();
|
|
}));
|
|
},
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.2),
|
|
blurRadius: 5,
|
|
),
|
|
],
|
|
),
|
|
child: const Padding(
|
|
padding: EdgeInsets.all(8.0),
|
|
child: Icon(
|
|
Icons.clear,
|
|
size: 30,
|
|
color: AppColor.redColor,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
// Changed: تم تعديل تصميم نافذة السعر لتكون أكثر وضوحًا
|
|
class PricesWindow extends StatelessWidget {
|
|
const PricesWindow({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<MapDriverController>(builder: (mapDriverController) {
|
|
return mapDriverController.isPriceWindow
|
|
? Container(
|
|
color: Colors.black.withOpacity(0.5),
|
|
child: Center(
|
|
child: Container(
|
|
width: Get.width * 0.8,
|
|
padding: const EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'Total Price is '.tr,
|
|
style: AppStyle.headTitle2,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
'${mapDriverController.totalPricePassenger} ${'\$'.tr}',
|
|
style: AppStyle.headTitle2.copyWith(
|
|
color: AppColor.primaryColor, fontSize: 36),
|
|
),
|
|
const SizedBox(
|
|
height: 20,
|
|
),
|
|
MyElevatedButton(
|
|
title: 'ok'.tr,
|
|
onPressed: () =>
|
|
Get.to(() => RatePassenger(), arguments: {
|
|
'rideId': mapDriverController.rideId,
|
|
'passengerId': mapDriverController.passengerId,
|
|
'driverId': mapDriverController.driverId
|
|
}))
|
|
],
|
|
),
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox();
|
|
});
|
|
}
|
|
}
|