// import 'package:flutter/material.dart'; // import 'package:flutter_font_icons/flutter_font_icons.dart'; // import 'package:get/get.dart'; // import 'package:Intaleq/constant/box_name.dart'; // import 'package:Intaleq/controller/profile/profile_controller.dart'; // import 'package:Intaleq/main.dart'; // import 'package:Intaleq/views/home/profile/complaint_page.dart'; // import '../../../constant/colors.dart'; // import '../../../constant/links.dart'; // import '../../../constant/style.dart'; // import '../../../controller/functions/audio_record1.dart'; // import '../../../controller/functions/launch.dart'; // import '../../../controller/functions/toast.dart'; // import '../../../controller/home/map_passenger_controller.dart'; // // --- الويدجت الرئيسية بالتصميم الجديد --- // class RideBeginPassenger extends StatelessWidget { // const RideBeginPassenger({super.key}); // @override // Widget build(BuildContext context) { // // --- نفس منطق استدعاء الكنترولرز --- // final ProfileController profileController = Get.put(ProfileController()); // final AudioRecorderController audioController = // Get.put(AudioRecorderController()); // return GetBuilder(builder: (controller) { // // --- نفس شرط الإظهار الخاص بك --- // if (controller.statusRide != 'Begin') { // return const SizedBox.shrink(); // } // return Positioned( // left: 0, // right: 0, // bottom: 0, // child: Container( // decoration: BoxDecoration( // color: AppColor.secondaryColor, // borderRadius: const BorderRadius.only( // topLeft: Radius.circular(24), // topRight: Radius.circular(24), // ), // boxShadow: [ // BoxShadow( // color: Colors.black.withOpacity(0.2), // blurRadius: 20, // offset: const Offset(0, -5), // ), // ], // ), // child: Padding( // padding: const EdgeInsets.fromLTRB(16, 12, 16, 16), // child: Column( // mainAxisSize: MainAxisSize.min, // children: [ // // مقبض السحب (Handle) // Container( // width: 40, // height: 5, // decoration: BoxDecoration( // color: AppColor.writeColor.withOpacity(0.3), // borderRadius: BorderRadius.circular(12), // ), // ), // const SizedBox(height: 12), // // --- 1. قسم معلومات السائق --- // _buildDriverInfo(controller), // const Divider(height: 24, thickness: 0.5), // // --- 2. قسم تقدم الرحلة --- // _buildTripProgress(controller), // const SizedBox(height: 16), // // --- 3. قسم الإجراءات والأمان --- // _buildActionButtons( // context, controller, profileController, audioController), // ], // ), // ), // ), // ); // }); // } // // --- ويدجت مساعدة لعرض معلومات السائق بشكل منظم --- // Widget _buildDriverInfo(MapPassengerController controller) { // return Row( // children: [ // CircleAvatar( // radius: 28, // backgroundImage: NetworkImage( // '${AppLink.server}/portrate_captain_image/${controller.driverId}.jpg'), // ), // const SizedBox(width: 12), // Expanded( // child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // Text(controller.driverName, // style: AppStyle.title.copyWith(fontWeight: FontWeight.bold)), // const SizedBox(height: 2), // Text( // '${controller.make} ${controller.model} • ${box.read(BoxName.carType)}', // style: AppStyle.subtitle // .copyWith(color: AppColor.writeColor.withOpacity(0.7)), // ), // ], // ), // ), // const SizedBox(width: 12), // Column( // crossAxisAlignment: CrossAxisAlignment.end, // children: [ // Container( // padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), // decoration: BoxDecoration( // color: AppColor.writeColor.withOpacity(0.1), // borderRadius: BorderRadius.circular(6), // ), // child: Text( // controller.licensePlate, // style: AppStyle.subtitle // .copyWith(fontWeight: FontWeight.bold, letterSpacing: 1.5), // ), // ), // const SizedBox(height: 4), // Row( // children: [ // Text(controller.driverRate, // style: AppStyle.subtitle // .copyWith(fontWeight: FontWeight.bold)), // const SizedBox(width: 2), // const Icon(Icons.star_rounded, // color: AppColor.yellowColor, size: 16), // ], // ), // ], // ) // ], // ); // } // // --- ويدجت مساعدة لعرض شريط التقدم --- // Widget _buildTripProgress(MapPassengerController controller) { // return Column( // children: [ // Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // Text('Time to Destination'.tr, style: AppStyle.subtitle), // Text(controller.stringRemainingTimeRideBegin, // style: AppStyle.subtitle.copyWith( // fontWeight: FontWeight.bold, color: AppColor.primaryColor)), // ], // ), // const SizedBox(height: 8), // ClipRRect( // borderRadius: BorderRadius.circular(10), // child: LinearProgressIndicator( // backgroundColor: AppColor.primaryColor.withOpacity(0.2), // color: controller.remainingTimeTimerRideBegin < 60 // ? AppColor.redColor // : AppColor.greenColor, // minHeight: 10, // value: controller.progressTimerRideBegin.toDouble(), // ), // ), // ], // ); // } // // --- ويدجت مساعدة لعرض أزرار الإجراءات --- // Widget _buildActionButtons( // BuildContext context, // MapPassengerController controller, // ProfileController profileController, // AudioRecorderController audioController) { // return Row( // mainAxisAlignment: MainAxisAlignment.spaceAround, // children: [ // _buildActionButton( // icon: Icons.sos_rounded, // label: 'SOS'.tr, // color: AppColor.redColor, // onTap: () async { // // --- نفس منطقك القديم --- // if (box.read(BoxName.sosPhonePassenger) == null) { // await profileController.updatField( // 'sosPhone', TextInputType.phone); // box.write(BoxName.sosPhonePassenger, // profileController.prfoileData['sosPhone']); // } else { // makePhoneCall('112'); // } // }), // _buildActionButton( // icon: FontAwesome.whatsapp, // label: 'WhatsApp'.tr, // color: AppColor.greenColor, // onTap: () async { // // --- نفس منطقك القديم --- // if (box.read(BoxName.sosPhonePassenger) == null || // box.read(BoxName.sosPhonePassenger) == 'sos') { // await profileController.updatField( // 'sosPhone', TextInputType.phone); // box.write(BoxName.sosPhonePassenger, // profileController.prfoileData['sosPhone']); // } else { // final phoneNumber = // box.read(BoxName.sosPhonePassenger).toString(); // final phone = controller.formatSyrianPhoneNumber(phoneNumber); // controller.sendWhatsapp(phone); // // } // }), // _buildActionButton( // icon: Icons.share_location_outlined, // أيقونة جديدة ومناسبة // label: 'Share'.tr, // اسم جديد وواضح // color: AppColor.blueColor, // onTap: () async { // // نفس الوظيفة السابقة التي كانت تحت اسم "Video Call" // await controller.getTokenForParent(); // }), // _buildActionButton( // icon: audioController.isRecording // ? Icons.mic_off_rounded // : Icons.mic_none_rounded, // label: audioController.isRecording ? 'Stop'.tr : 'Record'.tr, // color: AppColor.primaryColor, // onTap: () async { // // --- نفس منطقك القديم --- // if (audioController.isRecording == false) { // await audioController.startRecording(); // Toast.show(context, 'Start Record'.tr, AppColor.greenColor); // } else { // await audioController.stopRecording(); // Toast.show(context, 'Record saved'.tr, AppColor.greenColor); // } // }, // ), // _buildActionButton( // icon: Icons.note_add_outlined, // label: 'Complaint'.tr, // color: AppColor.yellowColor, // onTap: () { // // --- نفس منطقك القديم --- // Get.to(() => ComplaintPage(), transition: Transition.downToUp); // }), // ], // ); // } // // --- ويدجت مساعدة لبناء زر إجراء فردي --- // Widget _buildActionButton( // {required IconData icon, // required String label, // required Color color, // required VoidCallback onTap}) { // return InkWell( // onTap: onTap, // borderRadius: BorderRadius.circular(12), // child: Padding( // padding: const EdgeInsets.all(4.0), // child: Column( // mainAxisSize: MainAxisSize.min, // children: [ // Container( // padding: const EdgeInsets.all(12), // decoration: BoxDecoration( // color: color.withOpacity(0.1), // shape: BoxShape.circle, // ), // child: Icon(icon, color: color, size: 26), // ), // const SizedBox(height: 6), // Text(label, style: AppStyle.subtitle.copyWith(fontSize: 12)), // ], // ), // ), // ); // } // } import 'package:flutter/material.dart'; import 'package:flutter_font_icons/flutter_font_icons.dart'; import 'package:get/get.dart'; import 'package:Intaleq/constant/box_name.dart'; import 'package:Intaleq/controller/profile/profile_controller.dart'; import 'package:Intaleq/main.dart'; import 'package:Intaleq/views/home/profile/complaint_page.dart'; import 'package:intl/intl.dart'; import '../../../constant/colors.dart'; import '../../../constant/links.dart'; import '../../../constant/style.dart'; import '../../../controller/functions/audio_record1.dart'; import '../../../controller/functions/launch.dart'; import '../../../controller/functions/toast.dart'; import '../../../controller/home/map_passenger_controller.dart'; class RideBeginPassenger extends StatelessWidget { const RideBeginPassenger({super.key}); @override Widget build(BuildContext context) { final ProfileController profileController = Get.put(ProfileController()); final AudioRecorderController audioController = Get.put(AudioRecorderController()); return Obx(() { final controller = Get.find(); // شرط الإظهار: تظهر فقط عندما تكون الرحلة جارية final bool isVisible = controller.currentRideState.value == RideState.inProgress && controller.isStartAppHasRide == false; ; return AnimatedPositioned( duration: const Duration(milliseconds: 500), curve: Curves.easeOutBack, // حركة أكثر سلاسة bottom: isVisible ? 0 : -Get.height * 0.6, left: 0, right: 0, child: Container( decoration: BoxDecoration( color: Colors.white, // خلفية بيضاء لنظافة التصميم borderRadius: const BorderRadius.only( topLeft: Radius.circular(30), topRight: Radius.circular(30), ), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.15), blurRadius: 25, spreadRadius: 5, offset: const Offset(0, -5), ), ], ), child: Padding( padding: const EdgeInsets.fromLTRB(20, 12, 20, 20), child: Column( mainAxisSize: MainAxisSize.min, children: [ // مقبض السحب Container( width: 50, height: 5, decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.circular(10), ), ), const SizedBox(height: 20), // الصف العلوي: معلومات السائق + السعر المثبت _buildDriverAndPriceSection(controller), const SizedBox(height: 20), // الصف الأوسط: لوحة السيارة الواقعية + نوع السيارة _buildCarInfoSection(controller), const SizedBox(height: 20), // شريط التقدم والوقت _buildTripProgress(controller), const SizedBox(height: 20), const Divider(thickness: 1, color: Color(0xFFEEEEEE)), const SizedBox(height: 10), // الأزرار _buildActionButtons( context, controller, profileController, audioController), ], ), ), ), ); }); } // ويدجت معلومات السائق والسعر Widget _buildDriverAndPriceSection(MapPassengerController controller) { return Row( children: [ // صورة السائق Container( decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all(color: AppColor.primaryColor, width: 2), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.1), blurRadius: 10, offset: const Offset(0, 5), ), ], ), child: CircleAvatar( radius: 30, backgroundImage: NetworkImage( '${AppLink.server}/portrate_captain_image/${controller.driverId}.jpg'), ), ), const SizedBox(width: 15), // الاسم والتقييم Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( controller.driverName, style: AppStyle.title.copyWith( fontWeight: FontWeight.w800, fontSize: 18, color: Colors.black87, ), maxLines: 1, overflow: TextOverflow.ellipsis, ), const SizedBox(height: 4), Row( children: [ const Icon(Icons.star_rounded, color: AppColor.yellowColor, size: 18), const SizedBox(width: 4), Text( controller.driverRate, style: AppStyle.subtitle.copyWith( fontWeight: FontWeight.bold, color: Colors.grey[600]), ), ], ), ], ), ), // السعر المثبت (تصميم كارد للسعر) Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), decoration: BoxDecoration( color: AppColor.primaryColor.withOpacity(0.1), borderRadius: BorderRadius.circular(12), border: Border.all(color: AppColor.primaryColor.withOpacity(0.2)), ), child: Column( children: [ Text('Total'.tr, style: TextStyle(fontSize: 10, color: Colors.grey[600])), Text( '${NumberFormat('#,###').format(controller.totalPassenger)} 💰', style: const TextStyle( fontFamily: 'Roboto', fontWeight: FontWeight.w900, fontSize: 18, color: AppColor.primaryColor, ), ), ], ), ), ], ); } // ويدجت معلومات السيارة ولوحة الأرقام Widget _buildCarInfoSection(MapPassengerController controller) { return Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: const Color(0xFFF9F9F9), borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.grey[200]!), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // نوع السيارة وموديلها Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '${controller.make} ${controller.model}', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 16, color: Colors.black87), ), const SizedBox(height: 4), Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.circular(4), ), child: Text( box.read(BoxName.carType) == 'Speed' ? 'Fixed Price' .tr // سيظهر "سعر ثابت" (تأكد من إضافتها لملف الترجمة) : box.read(BoxName.carType) ?? 'Car', style: const TextStyle(fontSize: 12, color: Colors.black54), ), ), ], ), // ------------------------------------------- // تصميم لوحة السيارة الواقعي (Realistic Plate) // ------------------------------------------- Container( padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 2), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(6), border: Border.all(color: Colors.black, width: 2), // إطار أسود boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.1), blurRadius: 4, offset: const Offset(2, 2)), ], ), child: Row( mainAxisSize: MainAxisSize.min, children: [ // الشريط الأزرق الجانبي (مثل اللوحات الدولية) Container( width: 15, height: 35, // ارتفاع اللوحة decoration: const BoxDecoration( color: Color(0xFF003399), // أزرق غامق borderRadius: BorderRadius.only( topLeft: Radius.circular(2), bottomLeft: Radius.circular(2), ), ), child: const Center( child: Text( "SY", // رمز الدولة (مثال) style: TextStyle( color: Colors.white, fontSize: 8, fontWeight: FontWeight.bold), ), ), ), const SizedBox(width: 8), // رقم اللوحة Text( controller.licensePlate, // رقم اللوحة من الكونترولر style: const TextStyle( fontSize: 20, fontWeight: FontWeight.w900, letterSpacing: 2.0, // تباعد الأحرف لتبدو كأرقام محفورة fontFamily: 'monospace', // خط ثابت العرض ليشبه اللوحات color: Colors.black, ), ), const SizedBox(width: 8), ], ), ), ], ), ); } Widget _buildTripProgress(MapPassengerController controller) { return Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ const Icon(Icons.access_time_filled, size: 16, color: Colors.grey), const SizedBox(width: 5), Text('Arriving in'.tr, style: TextStyle(color: Colors.grey[600], fontSize: 13)), ], ), Text( controller.stringRemainingTimeRideBegin, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 16, color: AppColor.primaryColor, ), ), ], ), const SizedBox(height: 10), ClipRRect( borderRadius: BorderRadius.circular(10), child: LinearProgressIndicator( backgroundColor: Colors.grey[200], color: controller.remainingTimeTimerRideBegin < 60 ? AppColor.redColor : AppColor.primaryColor, minHeight: 8, value: controller.progressTimerRideBegin.toDouble(), ), ), ], ); } Widget _buildActionButtons( BuildContext context, MapPassengerController controller, ProfileController profileController, AudioRecorderController audioController) { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ // زر SOS بتصميم تحذيري _buildActionButton( icon: Icons.sos_rounded, label: 'SOS', iconColor: Colors.white, bgColor: AppColor.redColor, onTap: () async { if (box.read(BoxName.sosPhonePassenger) == null) { await profileController.updatField( 'sosPhone', TextInputType.phone); box.write(BoxName.sosPhonePassenger, profileController.prfoileData['sosPhone']); } else { makePhoneCall('112'); } }), // زر واتساب _buildActionButton( icon: FontAwesome.whatsapp, label: 'WhatsApp', iconColor: Colors.white, bgColor: const Color(0xFF25D366), onTap: () async { if (box.read(BoxName.sosPhonePassenger) == null || box.read(BoxName.sosPhonePassenger) == 'sos') { await profileController.updatField( 'sosPhone', TextInputType.phone); box.write(BoxName.sosPhonePassenger, profileController.prfoileData['sosPhone']); } else { final phoneNumber = box.read(BoxName.sosPhonePassenger).toString(); final phone = controller.formatSyrianPhoneNumber(phoneNumber); controller.sendWhatsapp(phone); } }), // زر المشاركة _buildActionButton( icon: Icons.share_location_rounded, label: 'Share', iconColor: AppColor.primaryColor, bgColor: AppColor.primaryColor.withOpacity(0.1), onTap: () async { await controller.shareTripWithFamily(); }), // زر التسجيل GetBuilder( init: audioController, builder: (audioCtx) { return _buildActionButton( icon: audioCtx.isRecording ? Icons.stop : Icons.mic, label: audioCtx.isRecording ? 'Stop' : 'Record', iconColor: audioCtx.isRecording ? Colors.white : AppColor.primaryColor, bgColor: audioCtx.isRecording ? AppColor.redColor : AppColor.primaryColor.withOpacity(0.1), isRecordingAnimation: audioCtx.isRecording, onTap: () async { if (audioCtx.isRecording == false) { await audioCtx.startRecording(); Toast.show(context, 'Start Record'.tr, AppColor.greenColor); } else { await audioCtx.stopRecording(); Toast.show(context, 'Record saved'.tr, AppColor.greenColor); } }, ); }, ), // زر الشكوى _buildActionButton( icon: Icons.report_gmailerrorred_rounded, label: 'Report'.tr, iconColor: Colors.grey[700]!, bgColor: Colors.grey[200]!, onTap: () { Get.to(() => ComplaintPage(), transition: Transition.downToUp); }), ], ); } Widget _buildActionButton({ required IconData icon, required String label, required Color iconColor, required Color bgColor, required VoidCallback onTap, bool isRecordingAnimation = false, }) { return Column( mainAxisSize: MainAxisSize.min, children: [ InkWell( onTap: onTap, borderRadius: BorderRadius.circular(15), child: AnimatedContainer( duration: const Duration(milliseconds: 300), width: 50, height: 50, decoration: BoxDecoration( color: bgColor, borderRadius: BorderRadius.circular(15), border: isRecordingAnimation ? Border.all(color: AppColor.redColor, width: 2) : null, boxShadow: [ BoxShadow( color: bgColor.withOpacity(0.3), blurRadius: 8, offset: const Offset(0, 3), ), ], ), child: Icon(icon, color: iconColor, size: 24), ), ), const SizedBox(height: 6), Text( label.tr, style: const TextStyle( fontSize: 11, fontWeight: FontWeight.w600, color: Colors.black54, ), ), ], ); } }