import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:ride/constant/box_name.dart'; import 'package:ride/controller/firebase/firbase_messge.dart'; import 'package:ride/main.dart'; import 'package:ride/views/widgets/my_scafold.dart'; import '../../constant/colors.dart'; import '../../constant/links.dart'; import '../../constant/style.dart'; import '../../controller/functions/crud.dart'; import '../../controller/functions/launch.dart'; import '../../controller/home/captin/order_request_controller.dart'; import '../widgets/elevated_btn.dart'; class OrderRequestPage extends StatelessWidget { OrderRequestPage({super.key}); TimerController timerController = Get.put(TimerController()); @override Widget build(BuildContext context) { final arguments = Get.arguments; final myListString = arguments['myListString']; final myList = arguments['DriverList']; final body = arguments['body']; return MyScafolld( title: 'Order Request Page', body: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Text(message.notification!.body.toString()), Padding( padding: const EdgeInsets.all(8.0), child: TextButton.icon( onPressed: () { String mapUrl = 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/'; print(mapUrl); launchUrl1(mapUrl); }, icon: const Icon(Icons.map), label: Text('Rouats of Trip'.tr)), ), Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( text: 'Passenger Name is '.tr, style: AppStyle.title, children: [ TextSpan(text: myList[8], style: AppStyle.headtitle2), ], ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( text: 'Tatal From Passenger is '.tr, style: AppStyle.title, children: [ TextSpan( text: double.parse(myList[2]).toStringAsFixed(2), style: AppStyle.headtitle2), ], ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( text: 'Duration To Passenger is '.tr, style: AppStyle.title, children: [ TextSpan( text: myList[11].toString(), style: AppStyle.headtitle2), ], ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( text: 'Distance To Passenger is '.tr, style: AppStyle.title, children: [ TextSpan( text: myList[12].toString(), style: AppStyle.headtitle2), ], ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( text: 'Tatal For You is '.tr, style: AppStyle.title, children: [ TextSpan( text: double.parse(myList[3]).toStringAsFixed(2), style: AppStyle.headtitle2), ], ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( text: 'Distance is '.tr, style: AppStyle.title, children: [ TextSpan( text: myList[5].toString(), style: AppStyle.headtitle2), TextSpan(text: ' KM'.tr, style: AppStyle.title), ]), ), ), Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( text: 'Duration of Trip is '.tr, style: AppStyle.title, children: [ TextSpan( text: myList[4].toString(), style: AppStyle.headtitle2), TextSpan(text: ' Minutes'.tr, style: AppStyle.title), ]), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ MyElevatedButton( title: 'Apply Order'.tr, onPressed: () async { await CRUD().postFromDialogue( link: AppLink.addDriverOrder, payload: { 'driver_id': myList[6].toString(), // box.read(BoxName.driverID).toString(), 'order_id': body.toString(), 'status': 'Apply' }); // Get.back(); List bodyToPassenger = [ box.read(BoxName.driverID).toString(), box.read(BoxName.nameDriver).toString(), box.read(BoxName.tokenDriver).toString(), ]; print(bodyToPassenger); FirebasMessagesController() .sendNotificanToPassengerToken( 'Apply Ride', arguments['DriverList'][9].toString(), arguments['DriverList'][9].toString(), // box.read(BoxName.tokenDriver).toString(), bodyToPassenger, ); Get.back(); }, ), GetBuilder( builder: (timerController) { final isNearEnd = timerController.remainingTime <= 5; // Define a threshold for "near end" return Stack( alignment: Alignment.center, children: [ CircularProgressIndicator( value: timerController.progress, // Set the color based on the "isNearEnd" condition color: isNearEnd ? Colors.red : Colors.blue, ), Text( '${timerController.remainingTime}', style: AppStyle.number, ), ], ); }, ), MyElevatedButton( title: 'Refuse Order'.tr, onPressed: () async { timerController.refuseOrder( myList[6].toString(), body.toString()); }, kolor: AppColor.redColor, ), ], ), ) ], ) ], isleading: true); } }