24-12/27/1
This commit is contained in:
@@ -19,7 +19,7 @@ import '../../../../controller/home/captin/order_request_controller.dart';
|
||||
import '../../../widgets/elevated_btn.dart';
|
||||
|
||||
class OrderRequestPage extends StatefulWidget {
|
||||
OrderRequestPage({super.key});
|
||||
const OrderRequestPage({super.key});
|
||||
|
||||
@override
|
||||
State<OrderRequestPage> createState() => _OrderRequestPageState();
|
||||
@@ -31,579 +31,398 @@ class _OrderRequestPageState extends State<OrderRequestPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final arguments = Get.arguments;
|
||||
final myListString = arguments['myListString'];
|
||||
var myList;
|
||||
|
||||
// Determine the list to use
|
||||
myList = arguments['DriverList'] == null || arguments['DriverList'].isEmpty
|
||||
? jsonDecode(myListString)
|
||||
: arguments['DriverList'];
|
||||
|
||||
// Parse coordinates
|
||||
var cords = myList[0].split(',');
|
||||
var cordDestination = myList[1].split(',');
|
||||
|
||||
double? parseDouble(String value) {
|
||||
try {
|
||||
return double.parse(value);
|
||||
} catch (e) {
|
||||
print("Error parsing value: $value");
|
||||
return null; // or handle the error appropriately
|
||||
}
|
||||
}
|
||||
|
||||
double? latPassengerLocation = parseDouble(cords[0]);
|
||||
double? lngPassengerLocation = parseDouble(cords[1]);
|
||||
double? latPassengerDestination = parseDouble(cordDestination[0]);
|
||||
double? lngPassengerDestination = parseDouble(cordDestination[1]);
|
||||
|
||||
if (latPassengerLocation == null ||
|
||||
lngPassengerLocation == null ||
|
||||
latPassengerDestination == null ||
|
||||
lngPassengerDestination == null) {
|
||||
// Handle invalid coordinates gracefully
|
||||
print("Invalid coordinates found.");
|
||||
return Container(); // or any fallback UI
|
||||
}
|
||||
|
||||
// double latPassengerLocation = double.parse(cords[0]);
|
||||
// double lngPassengerLocation = double.parse(cords[1]);
|
||||
// double latPassengerDestination = double.parse(cordDestination[0]);
|
||||
// double lngPassengerDestination = double.parse(cordDestination[1]);
|
||||
|
||||
// Create points for route
|
||||
List<LatLng> pointsDirection = [
|
||||
LatLng(latPassengerLocation, lngPassengerLocation),
|
||||
LatLng(latPassengerDestination, lngPassengerDestination)
|
||||
];
|
||||
|
||||
// Calculate bounding box
|
||||
double minLatitude =
|
||||
math.min(pointsDirection[0].latitude, pointsDirection[1].latitude);
|
||||
double maxLatitude =
|
||||
math.max(pointsDirection[0].latitude, pointsDirection[1].latitude);
|
||||
double minLongitude =
|
||||
math.min(pointsDirection[0].longitude, pointsDirection[1].longitude);
|
||||
double maxLongitude =
|
||||
math.max(pointsDirection[0].longitude, pointsDirection[1].longitude);
|
||||
|
||||
LatLngBounds bounds = LatLngBounds(
|
||||
southwest: LatLng(minLatitude, minLongitude),
|
||||
northeast: LatLng(maxLatitude, maxLongitude),
|
||||
);
|
||||
|
||||
// Start timer and calculate fuel consumption
|
||||
orderRequestController.startTimer(
|
||||
myList[6].toString(),
|
||||
myList[16].toString(),
|
||||
);
|
||||
orderRequestController.calculateConsumptionFuel();
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: Container(
|
||||
color: const Color.fromARGB(255, 241, 238, 238),
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: Get.height * .33,
|
||||
child: GoogleMap(
|
||||
initialCameraPosition: CameraPosition(
|
||||
zoom: 12,
|
||||
target: Get.find<HomeCaptainController>().myLocation,
|
||||
),
|
||||
cameraTargetBounds: CameraTargetBounds(bounds),
|
||||
myLocationButtonEnabled: true,
|
||||
trafficEnabled: false,
|
||||
buildingsEnabled: false,
|
||||
mapToolbarEnabled: true,
|
||||
myLocationEnabled: true,
|
||||
markers: {
|
||||
Marker(
|
||||
markerId: MarkerId('MyLocation'.tr),
|
||||
position:
|
||||
LatLng(latPassengerLocation, lngPassengerLocation),
|
||||
draggable: true,
|
||||
icon: orderRequestController.startIcon,
|
||||
),
|
||||
Marker(
|
||||
markerId: MarkerId('Destination'.tr),
|
||||
position: LatLng(
|
||||
latPassengerDestination, lngPassengerDestination),
|
||||
draggable: true,
|
||||
icon: orderRequestController.endIcon,
|
||||
),
|
||||
},
|
||||
polylines: {
|
||||
Polyline(
|
||||
zIndex: 1,
|
||||
consumeTapEvents: true,
|
||||
geodesic: true,
|
||||
endCap: Cap.buttCap,
|
||||
startCap: Cap.buttCap,
|
||||
visible: true,
|
||||
polylineId: const PolylineId('routeOrder'),
|
||||
points: pointsDirection,
|
||||
color: AppColor.primaryColor,
|
||||
width: 2,
|
||||
),
|
||||
},
|
||||
appBar: AppBar(
|
||||
title: Text('Order Request'.tr),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: GetBuilder<OrderRequestController>(
|
||||
builder: (controller) {
|
||||
if (controller.myList == null) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: Get.height * 0.3,
|
||||
child: GoogleMap(
|
||||
mapType: MapType.normal,
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: LatLng(controller.latPassengerLocation,
|
||||
controller.lngPassengerLocation),
|
||||
zoom: 14.0,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Card(
|
||||
elevation: 3,
|
||||
color: myList[20].toString() == 'haveSteps'
|
||||
? AppColor.greenColor
|
||||
: AppColor.secondaryColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
String mapUrl =
|
||||
'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/';
|
||||
showInBrowser(mapUrl);
|
||||
},
|
||||
icon: const Icon(Icons.map),
|
||||
label: myList[20].toString() == 'haveSteps'
|
||||
? Text(
|
||||
'Trip has Steps'.tr,
|
||||
style: AppStyle.title,
|
||||
)
|
||||
: Text('Payment Method'.tr,
|
||||
style: AppStyle.title)),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 12),
|
||||
decoration: AppStyle.boxDecoration.copyWith(
|
||||
color: myList[13].toString() == 'true'
|
||||
? AppColor.deepPurpleAccent
|
||||
: AppColor.greenColor,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
color: Colors.black12,
|
||||
blurRadius: 4,
|
||||
offset: Offset(2, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
myList[13].toString() == 'true'
|
||||
? Icons.credit_card
|
||||
: Icons.money,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
myList[13].toString() == 'true'
|
||||
? 'Visa'
|
||||
: 'Cash',
|
||||
style: AppStyle.title
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
myLocationButtonEnabled: true,
|
||||
onMapCreated: controller.onMapCreated,
|
||||
myLocationEnabled: true,
|
||||
markers: {
|
||||
Marker(
|
||||
markerId: const MarkerId('startLocation'),
|
||||
position: LatLng(controller.latPassengerLocation,
|
||||
controller.lngPassengerLocation),
|
||||
icon: controller.startIcon,
|
||||
),
|
||||
),
|
||||
Marker(
|
||||
markerId: const MarkerId('destinationLocation'),
|
||||
position: LatLng(controller.latPassengerDestination,
|
||||
controller.lngPassengerDestination),
|
||||
icon: controller.endIcon,
|
||||
),
|
||||
},
|
||||
polylines: {
|
||||
Polyline(
|
||||
polylineId: const PolylineId('route'),
|
||||
color: AppColor.primaryColor,
|
||||
width: 5,
|
||||
points: controller.pointsDirection,
|
||||
),
|
||||
},
|
||||
),
|
||||
Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
double.parse(myList[2]).toStringAsFixed(2),
|
||||
style: AppStyle.headTitle2,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(seconds: 5),
|
||||
curve: Curves.easeInOut,
|
||||
child: AnimatedSize(
|
||||
duration: const Duration(seconds: 5),
|
||||
curve: Curves.easeInOut,
|
||||
child: myList[31].toString() == 'Comfort'
|
||||
? Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.ac_unit,
|
||||
color: AppColor.blueColor,
|
||||
size: 50,
|
||||
),
|
||||
Text(
|
||||
'Air condition Trip'.tr,
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
myList[31].toString().tr,
|
||||
style: AppStyle.title
|
||||
.copyWith(color: AppColor.greenColor),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Container(
|
||||
height: Get.height * .25,
|
||||
width: Get.width * .9,
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Card(
|
||||
elevation: 4,
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
controller.myList[13].toString() == 'true'
|
||||
? Icons.credit_card
|
||||
: Icons.money,
|
||||
color: controller.myList[13].toString() == 'true'
|
||||
? AppColor.deepPurpleAccent
|
||||
: AppColor.greenColor,
|
||||
),
|
||||
title: Text(
|
||||
'Payment Method'.tr,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
trailing: Text(
|
||||
controller.myList[13].toString() == 'true'
|
||||
? 'Visa'
|
||||
: 'Cash',
|
||||
style:
|
||||
Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
elevation: 4,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.account_circle,
|
||||
color: AppColor.secondaryColor),
|
||||
title: Text(
|
||||
controller.myList[8],
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.arrow_circle_up,
|
||||
color: AppColor.greenColor,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.access_time,
|
||||
color: Colors.grey, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${(double.parse(myList[12]) / 60).toStringAsFixed(0)} ${'minute'.tr}',
|
||||
style: AppStyle.title.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.directions_car,
|
||||
color: Colors.grey, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${(double.parse(myList[11]) / 1000).toStringAsFixed(1)} ${'kilometer'.tr}',
|
||||
style: AppStyle.title.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const Icon(Icons.star,
|
||||
size: 16, color: Colors.amber),
|
||||
Text(
|
||||
myList[29],
|
||||
style: AppStyle.title,
|
||||
controller.myList[33].toString(),
|
||||
style: const TextStyle(color: Colors.amber),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
elevation: 4,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.arrow_circle_down,
|
||||
color: AppColor.redColor,
|
||||
const Icon(Icons.location_on,
|
||||
color: AppColor.greenColor),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
// Keep Expanded here for layout
|
||||
child: Text(
|
||||
controller.myList[29],
|
||||
style:
|
||||
Theme.of(context).textTheme.titleSmall,
|
||||
maxLines: 2, // Allow up to 2 lines
|
||||
overflow: TextOverflow
|
||||
.ellipsis, // Handle overflow
|
||||
),
|
||||
),
|
||||
// Text(
|
||||
// '${(double.parse(myList[4]) / 60).toStringAsFixed(1)} min (${(double.parse(myList[5])).toStringAsFixed(1)} km)',
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.access_time,
|
||||
color: Colors.grey, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${(double.parse(myList[4]) / 60).toStringAsFixed(0)} ${'minute'.tr}',
|
||||
style: AppStyle.title.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.directions_car,
|
||||
color: Colors.grey, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${(double.parse(myList[5])).toStringAsFixed(1)} ${'kilometer'.tr}',
|
||||
style: AppStyle.title.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
Text(
|
||||
myList[30],
|
||||
style: AppStyle.title,
|
||||
const Divider(),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.flag,
|
||||
color: AppColor.redColor),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
// Keep Expanded here for layout
|
||||
child: Text(
|
||||
controller.myList[30],
|
||||
style:
|
||||
Theme.of(context).textTheme.titleSmall,
|
||||
maxLines: 2, // Allow up to 2 lines
|
||||
overflow: TextOverflow
|
||||
.ellipsis, // Handle overflow
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.person, size: 20, color: Colors.grey),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: "${'Passenger name: '.tr} ",
|
||||
style: AppStyle.subtitle,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: myList[8],
|
||||
style: AppStyle.title
|
||||
.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
TextSpan(
|
||||
text: ' (',
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
TextSpan(
|
||||
text: myList[33].toString(),
|
||||
style: AppStyle.title
|
||||
.copyWith(color: Colors.amber),
|
||||
),
|
||||
const WidgetSpan(
|
||||
child: Icon(
|
||||
Icons.star,
|
||||
size: 16,
|
||||
color: Colors.amber,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: ')',
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
elevation: 4,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_InfoTile(
|
||||
icon: Icons.timer,
|
||||
label:
|
||||
'${(double.parse(controller.myList[12]) / 60).toStringAsFixed(0)} ${'min'.tr}',
|
||||
),
|
||||
_InfoTile(
|
||||
icon: Icons.directions_car,
|
||||
label:
|
||||
'${(double.parse(controller.myList[11]) / 1000).toStringAsFixed(1)} ${'km'.tr}',
|
||||
),
|
||||
_InfoTile(
|
||||
icon: Icons.monetization_on,
|
||||
label: '${controller.myList[2]}',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyElevatedButton(
|
||||
kolor: AppColor.greenColor,
|
||||
title: 'Accept Order'.tr,
|
||||
onPressed: () async {
|
||||
Get.put(HomeCaptainController()).changeRideId();
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
orderRequestController.endTimer();
|
||||
orderRequestController.changeApplied();
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
MyElevatedButton(
|
||||
kolor: AppColor.greenColor,
|
||||
title: 'Accept Order'.tr,
|
||||
onPressed: () async {
|
||||
Get.put(HomeCaptainController()).changeRideId();
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
controller.endTimer();
|
||||
controller.changeApplied();
|
||||
|
||||
///
|
||||
var res = await CRUD().post(
|
||||
link: AppLink.updateStausFromSpeed,
|
||||
payload: {
|
||||
'id': orderRequestController.myList[16],
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Apply',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.endPoint}/ride/rides/updateStausFromSpeed.php",
|
||||
var res = await CRUD().post(
|
||||
link: AppLink.updateStausFromSpeed,
|
||||
payload: {
|
||||
'id': orderRequestController.myList[16],
|
||||
'id': controller.myList[16],
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Apply',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
}
|
||||
if (res == 'failure') {
|
||||
MyDialog().getDialog(
|
||||
"This ride is already applied by another driver."
|
||||
.tr,
|
||||
'', () {
|
||||
Get.back();
|
||||
});
|
||||
} else {
|
||||
await CRUD().postFromDialogue(
|
||||
link: AppLink.addDriverOrder,
|
||||
payload: {
|
||||
'driver_id': myList[6].toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': myList[16].toString(),
|
||||
'status': 'Apply'
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().postFromDialogue(
|
||||
CRUD().post(
|
||||
link:
|
||||
'${AppLink.endPoint}/rides/driver_order/add.php',
|
||||
"${AppLink.endPoint}/ride/rides/updateStausFromSpeed.php",
|
||||
payload: {
|
||||
'driver_id': myList[6].toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': myList[16].toString(),
|
||||
'status': 'Apply'
|
||||
'id': controller.myList[16],
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Apply',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
}
|
||||
if (res == 'failure') {
|
||||
MyDialog().getDialog(
|
||||
"This ride is already applied by another driver."
|
||||
.tr,
|
||||
'', () {
|
||||
Get.back();
|
||||
});
|
||||
} else {
|
||||
await CRUD().postFromDialogue(
|
||||
link: AppLink.addDriverOrder,
|
||||
payload: {
|
||||
'driver_id':
|
||||
controller.myList[6].toString(),
|
||||
'order_id':
|
||||
controller.myList[16].toString(),
|
||||
'status': 'Apply'
|
||||
});
|
||||
if (AppLink.endPoint !=
|
||||
AppLink.seferCairoServer) {
|
||||
CRUD().postFromDialogue(
|
||||
link:
|
||||
'${AppLink.endPoint}/rides/driver_order/add.php',
|
||||
payload: {
|
||||
'driver_id':
|
||||
controller.myList[6].toString(),
|
||||
'order_id':
|
||||
controller.myList[16].toString(),
|
||||
'status': 'Apply'
|
||||
});
|
||||
}
|
||||
List<String> bodyToPassenger = [
|
||||
controller.myList[6].toString(),
|
||||
controller.myList[8].toString(),
|
||||
controller.myList[9].toString(),
|
||||
];
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToPassengerToken(
|
||||
"Accepted Ride".tr,
|
||||
'your ride is Accepted'.tr,
|
||||
controller.myList[9].toString(),
|
||||
bodyToPassenger,
|
||||
'start.wav');
|
||||
Get.back();
|
||||
box.write(BoxName.rideArguments, {
|
||||
'passengerLocation':
|
||||
controller.myList[0].toString(),
|
||||
'passengerDestination':
|
||||
controller.myList[1].toString(),
|
||||
'Duration': controller.myList[4].toString(),
|
||||
'totalCost': controller.myList[26].toString(),
|
||||
'Distance': controller.myList[5].toString(),
|
||||
'name': controller.myList[8].toString(),
|
||||
'phone': controller.myList[10].toString(),
|
||||
'email': controller.myList[28].toString(),
|
||||
'WalletChecked':
|
||||
controller.myList[13].toString(),
|
||||
'tokenPassenger':
|
||||
controller.myList[9].toString(),
|
||||
'direction':
|
||||
'https://www.google.com/maps/dir/${controller.myList[0]}/${controller.myList[1]}/',
|
||||
'DurationToPassenger':
|
||||
controller.myList[15].toString(),
|
||||
'rideId': controller.myList[16].toString(),
|
||||
'passengerId': controller.myList[7].toString(),
|
||||
'driverId': controller.myList[18].toString(),
|
||||
'durationOfRideValue':
|
||||
controller.myList[19].toString(),
|
||||
'paymentAmount':
|
||||
controller.myList[2].toString(),
|
||||
'paymentMethod':
|
||||
controller.myList[13].toString() == 'true'
|
||||
? 'visa'
|
||||
: 'cash',
|
||||
'isHaveSteps': controller.myList[20].toString(),
|
||||
'step0': controller.myList[21].toString(),
|
||||
'step1': controller.myList[22].toString(),
|
||||
'step2': controller.myList[23].toString(),
|
||||
'step3': controller.myList[24].toString(),
|
||||
'step4': controller.myList[25].toString(),
|
||||
'passengerWalletBurc':
|
||||
controller.myList[26].toString(),
|
||||
'timeOfOrder': DateTime.now().toString(),
|
||||
'totalPassenger':
|
||||
controller.myList[2].toString(),
|
||||
'carType': controller.myList[31].toString(),
|
||||
'kazan': controller.myList[32].toString(),
|
||||
'startNameLocation':
|
||||
controller.myList[29].toString(),
|
||||
'endNameLocation':
|
||||
controller.myList[30].toString(),
|
||||
});
|
||||
Get.to(() => PassengerLocationMapPage(),
|
||||
arguments: box.read(BoxName.rideArguments));
|
||||
}
|
||||
},
|
||||
),
|
||||
GetBuilder<OrderRequestController>(
|
||||
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 {
|
||||
controller.endTimer();
|
||||
List<String> bodyToPassenger = [
|
||||
myList[6].toString(), //driver id
|
||||
myList[8].toString(), // driver name
|
||||
myList[9].toString(), //token driver
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.nameDriver).toString(),
|
||||
box.read(BoxName.tokenDriver).toString(),
|
||||
];
|
||||
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToPassengerToken(
|
||||
'Apply Ride'.tr,
|
||||
'your ride is applied'.tr,
|
||||
// arguments['DriverList'][9].toString(),
|
||||
myList[9].toString(),
|
||||
// box.read(BoxName.tokenDriver).toString(),
|
||||
'Order Under Review'.tr,
|
||||
'${box.read(BoxName.nameDriver)} ${'is reviewing your order. They may need more information or a higher price.'.tr}',
|
||||
controller.myList[9].toString(),
|
||||
bodyToPassenger,
|
||||
'start.wav');
|
||||
Get.back();
|
||||
box.write(BoxName.rideArguments, {
|
||||
'passengerLocation': myList[0].toString(),
|
||||
'passengerDestination': myList[1].toString(),
|
||||
'Duration': myList[4].toString(),
|
||||
'totalCost': myList[26].toString(),
|
||||
'Distance': myList[5].toString(),
|
||||
'name': myList[8].toString(),
|
||||
'phone': myList[10].toString(),
|
||||
'email': myList[28].toString(),
|
||||
'WalletChecked': myList[13].toString(),
|
||||
'tokenPassenger': myList[9].toString(),
|
||||
'direction':
|
||||
'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/',
|
||||
'DurationToPassenger': myList[15].toString(),
|
||||
'rideId': myList[16].toString(),
|
||||
'passengerId': myList[7].toString(),
|
||||
'driverId': myList[18].toString(),
|
||||
'durationOfRideValue': myList[19].toString(),
|
||||
'paymentAmount': myList[2].toString(),
|
||||
'paymentMethod': myList[13].toString() == 'true'
|
||||
? 'visa'
|
||||
: 'cash',
|
||||
'isHaveSteps': myList[20].toString(),
|
||||
'step0': myList[21].toString(),
|
||||
'step1': myList[22].toString(),
|
||||
'step2': myList[23].toString(),
|
||||
'step3': myList[24].toString(),
|
||||
'step4': myList[25].toString(),
|
||||
'passengerWalletBurc': myList[26].toString(),
|
||||
'timeOfOrder': DateTime.now().toString(),
|
||||
'totalPassenger': myList[2].toString(),
|
||||
'carType': myList[31].toString(),
|
||||
'kazan': myList[32].toString(),
|
||||
'startNameLocation': myList[29].toString(),
|
||||
'endNameLocation': myList[30].toString(),
|
||||
});
|
||||
'passengerID =${box.read(BoxName.rideArguments)}';
|
||||
Get.to(() => PassengerLocationMapPage(),
|
||||
arguments: box.read(BoxName.rideArguments));
|
||||
}
|
||||
// Get.back();
|
||||
},
|
||||
),
|
||||
GetBuilder<OrderRequestController>(
|
||||
builder: (timerController) {
|
||||
final isNearEnd = timerController.remainingTime <=
|
||||
5; // Define a threshold for "near end"
|
||||
'notification.wav');
|
||||
|
||||
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 {
|
||||
orderRequestController.endTimer();
|
||||
List<String> bodyToPassenger = [
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.nameDriver).toString(),
|
||||
box.read(BoxName.tokenDriver).toString(),
|
||||
];
|
||||
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToPassengerToken(
|
||||
'Order Under Review'.tr,
|
||||
'${box.read(BoxName.nameDriver)} ${'is reviewing your order. They may need more information or a higher price.'.tr}',
|
||||
myList[9].toString(),
|
||||
bodyToPassenger,
|
||||
'notification.wav');
|
||||
|
||||
orderRequestController.refuseOrder(
|
||||
myList[16].toString(),
|
||||
);
|
||||
orderRequestController.addRideToNotificationDriverString(
|
||||
myList[16].toString(),
|
||||
myList[29].toString(),
|
||||
myList[30].toString(),
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day}',
|
||||
'${DateTime.now().hour}:${DateTime.now().minute}',
|
||||
myList[2].toString(),
|
||||
myList[7].toString(),
|
||||
'wait',
|
||||
myList[31].toString(),
|
||||
myList[33].toString(),
|
||||
myList[2].toString(),
|
||||
myList[5].toString(),
|
||||
myList[4].toString()); //duration
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
));
|
||||
controller.refuseOrder(
|
||||
controller.myList[16].toString(),
|
||||
);
|
||||
controller.addRideToNotificationDriverString(
|
||||
controller.myList[16].toString(),
|
||||
controller.myList[29].toString(),
|
||||
controller.myList[30].toString(),
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day}',
|
||||
'${DateTime.now().hour}:${DateTime.now().minute}',
|
||||
controller.myList[2].toString(),
|
||||
controller.myList[7].toString(),
|
||||
'wait',
|
||||
controller.myList[31].toString(),
|
||||
controller.myList[33].toString(),
|
||||
controller.myList[2].toString(),
|
||||
controller.myList[5].toString(),
|
||||
controller.myList[4].toString());
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InfoTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
|
||||
const _InfoTile({required this.icon, required this.label});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Icon(icon, color: AppColor.primaryColor),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
label,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void checkRideStatus() async {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user