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'; class PassengerLocationMapPage extends StatelessWidget { PassengerLocationMapPage({super.key}); final LocationController locationController = Get.put(LocationController()); final MapDriverController mapDriverController = Get.put(MapDriverController()); @override Widget build(BuildContext context) { if (Get.arguments != null && Get.arguments is Map) { // نستخدم addPostFrameCallback لضمان أن هذا الكود يعمل بعد اكتمال بناء الإطار الأول // هذا يعطي GetX وقته لتجهيز كل شيء WidgetsBinding.instance.addPostFrameCallback((_) { // نستدعي دالة التهيئة الجديدة ونمرر لها البيانات mapDriverController.argumentLoading(); }); } else { // في حال عدم وجود arguments، يجب التعامل مع هذا الخطأ WidgetsBinding.instance.addPostFrameCallback((_) { Get.snackbar("Error", "No order data found."); Get.back(); }); } mapDriverController.argumentLoading(); mapDriverController.startTimerToShowPassengerInfoWindowFromDriver(); return Scaffold( // backgroundColor: AppColor.blueColor, // title: 'Map Passenger'.tr, body: SafeArea( child: Stack( children: [ GoogleDriverMap(locationController: locationController), const PassengerInfoWindow(), CancelWidget(mapDriverController: mapDriverController), driverEndRideBar(), const SosConnect(), speedCircle(), // const GoogleMapApp(), const PricesWindow(), ], ), )); } } class CancelWidget extends StatelessWidget { const CancelWidget({ super.key, required this.mapDriverController, }); final MapDriverController mapDriverController; @override Widget build(BuildContext context) { return Positioned( top: 10, left: 5, child: 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 { // todo add cancel and inform passenger to get new driver await mapDriverController .cancelTripFromDriverAfterApplied(); Get.back(); }), cancel: MyElevatedButton( title: 'No'.tr, // kolor: AppColor.redColor, onPressed: () { Get.back(); })); }, child: Container( decoration: BoxDecoration( color: AppColor.redColor, borderRadius: BorderRadius.circular(15)), child: const Padding( padding: EdgeInsets.all(3), child: Icon( Icons.clear, size: 40, color: AppColor.secondaryColor, ), ), ), ), ); } } class PricesWindow extends StatelessWidget { const PricesWindow({ super.key, }); @override Widget build(BuildContext context) { return GetBuilder(builder: (mapDriverController) { return mapDriverController.isPriceWindow ? Positioned( bottom: Get.height * 1.2, // top: Get.height * 3, left: Get.height * 1, right: Get.height * 1, child: Container( height: Get.height * 3, decoration: AppStyle.boxDecoration1, child: Column( children: [ Container( decoration: AppStyle.boxDecoration1, child: Padding( padding: const EdgeInsets.all(3), child: Text( 'Total Price is '.tr, style: AppStyle.headTitle2, textAlign: TextAlign.center, ), )), const SizedBox( height: 20, ), MyElevatedButton( title: 'ok'.tr, onPressed: () => Get.to(() => RatePassenger(), arguments: { 'rideId': mapDriverController.rideId, 'passengerId': mapDriverController.passengerId, 'driverId': mapDriverController.driverId })) ], ), ), ) : const SizedBox(); }); } }