import 'package:Tripz/constant/links.dart'; import 'package:Tripz/views/home/profile/complaint_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_font_icons/flutter_font_icons.dart'; import 'package:get/get.dart'; import 'package:Tripz/constant/box_name.dart'; import 'package:Tripz/controller/profile/profile_controller.dart'; import 'package:Tripz/main.dart'; import '../../../constant/colors.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) { ProfileController profileController = Get.put(ProfileController()); AudioRecorderController audioController = Get.put(AudioRecorderController()); return GetBuilder(builder: (controller) { if (controller.statusRide == 'Begin') { return Positioned( left: 10, right: 10, bottom: 10, child: Card( // Wrapped in a Card elevation: 5, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), child: Padding( padding: const EdgeInsets.all(15.0), child: Column( mainAxisSize: MainAxisSize.min, // Use minimum space children: [ Row( children: [ CircleAvatar( radius: 30, backgroundImage: NetworkImage( '${AppLink.server}/portrate_captain_image/${controller.driverId}.jpg', ), ), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(controller.driverName, style: AppStyle.title), Row( children: [ Text(controller.make, style: AppStyle.subtitle), const SizedBox(width: 5), Text(controller.model, style: AppStyle.subtitle), ], ), ], ), ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( controller.licensePlate, style: AppStyle.title.copyWith(fontSize: 16), ), Text( '${box.read(BoxName.carType)}', style: AppStyle.title.copyWith(fontSize: 16), ), Text( '${controller.driverRate} ⭐️', style: AppStyle.title .copyWith(color: AppColor.greenColor), ), ], ), ], ), const SizedBox(height: 15), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ SizedBox( width: Get.width * 0.18, child: InkWell( onTap: () => controller.getDialog( 'Arrival time'.tr, 'arrival time to reach your point'.tr, () {}, ), child: Column( children: [ const Icon(Icons.timer_outlined, size: 28), Text(controller.arrivalTime, style: AppStyle.title), ], ), ), ), SizedBox( width: Get.width * 0.18, child: InkWell( onTap: () => controller.getDialog( 'Price of trip'.tr, 'For Speed and Delivery trips, the price is calculated dynamically. For Comfort trips, the price is based on time and distance' .tr, () => Get.back(), ), child: Column( children: [ const Icon(Icons.monetization_on, size: 28), Text( '${controller.totalPassenger.toStringAsFixed(2)}', style: AppStyle.title), ], ), ), ), SizedBox( width: Get.width * 0.18, child: IconButton( onPressed: () => Get.to(() => ComplaintPage(), transition: Transition.downToUp), icon: const Icon(Icons.note_add, color: AppColor.redColor), tooltip: 'Add Note', ), ), SizedBox( width: Get.width * 0.18, child: IconButton( onPressed: () 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); } }, icon: Icon( audioController.isRecording == false ? Icons.mic_none : Icons.mic_off, color: AppColor.greenColor, ), tooltip: audioController.isRecording == false ? 'Start Recording' : 'Stop Recording', ), ), ], ), const SizedBox(height: 15), Stack( alignment: Alignment.center, children: [ LinearProgressIndicator( backgroundColor: AppColor.accentColor .withOpacity(0.3), // Added background color: controller.remainingTimeTimerRideBegin < 60 ? AppColor.redColor : AppColor.greenColor, minHeight: 20, borderRadius: BorderRadius.circular(10), value: controller.progressTimerRideBegin.toDouble(), ), Text( controller.stringRemainingTimeRideBegin, style: AppStyle.title.copyWith(fontSize: 14), ), ], ), const SizedBox(height: 15), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ SizedBox( width: Get.width * 0.18, child: Column( children: [ IconButton( onPressed: () async { if (box.read(BoxName.sosPhonePassenger) == null) { await profileController.updatField( 'sosPhone', TextInputType.phone); box.write( BoxName.sosPhonePassenger, profileController .prfoileData['sosPhone']); } else { makePhoneCall('122'); } }, icon: const Icon(Icons.sos_rounded, color: AppColor.redColor), ), Text('SOS', style: AppStyle.title), ], ), ), SizedBox( width: Get.width * 0.18, child: Column( children: [ IconButton( onPressed: () 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 = box.read(BoxName.countryCode) == 'Egypt' ? '+2$phoneNumber' : '+962$phoneNumber'; controller.sendWhatsapp(phone); } }, icon: const Icon(FontAwesome.whatsapp, color: AppColor.greenColor), ), Text('WhatsApp', style: AppStyle.title), ], ), ), SizedBox( width: Get.width * 0.18, child: Column( children: [ IconButton( onPressed: () async { await controller.getTokenForParent(); }, icon: const Icon(Foundation.video, color: AppColor.blueColor), ), Text('Video Call', style: AppStyle.title), ], ), ), ], ), ], ), ), ), ); } else { return const SizedBox(); } }); } } // Removed the StreamCounter widget as it's not directly part of the RideBeginPassenger UI. class StreamCounter extends StatelessWidget { const StreamCounter({Key? key}) : super(key: key); @override // Build the UI based on the timer value Widget build(BuildContext context) { Get.put(MapPassengerController()); return GetBuilder(builder: (controller) { return StreamBuilder( initialData: 0, stream: controller.timerController.stream, builder: (context, snapshot) { // Calculate the remaining time based on the current tick final remainingTime = controller.durationToRide - snapshot.data!; // Format the remaining time as a string final formattedRemainingTime = '${(remainingTime / 60).floor()}:${(remainingTime % 60).toString().padLeft(2, '0')}'; // Return the UI widgets based on the remaining time return Column( children: [ Text(formattedRemainingTime), // ElevatedButton( // onPressed: () { // // Handle button press here // }, // ), ], ); }, ); }); } }