This commit is contained in:
Hamza Aleghwairyeen
2024-03-30 01:08:06 +03:00
parent dbcff89cd1
commit c853d89037
3 changed files with 732 additions and 661 deletions

View File

@@ -53,6 +53,7 @@ class AppLink {
static String getRideStatusFromStartApp = static String getRideStatusFromStartApp =
"$ride/rides/getRideStatusFromStartApp.php"; "$ride/rides/getRideStatusFromStartApp.php";
static String updateRides = "$ride/rides/update.php"; static String updateRides = "$ride/rides/update.php";
static String updateStausFromSpeed = "$ride/rides/updateStausFromSpeed.php";
static String deleteRides = "$ride/rides/delete.php"; static String deleteRides = "$ride/rides/delete.php";
//-----------------DriverPayment------------------ //-----------------DriverPayment------------------
@@ -63,7 +64,6 @@ class AppLink {
static String getKazanPercent = "$ride/kazan/get.php"; static String getKazanPercent = "$ride/kazan/get.php";
static String addKazanPercent = "$ride/kazan/add.php"; static String addKazanPercent = "$ride/kazan/add.php";
////-----------------DriverPayment------------------ ////-----------------DriverPayment------------------
static String addDriverpayment = "$ride/payment/add.php"; static String addDriverpayment = "$ride/payment/add.php";
static String addDriverPaymentPoints = "$ride/driverPayment/add.php"; static String addDriverPaymentPoints = "$ride/driverPayment/add.php";

View File

@@ -83,388 +83,336 @@ class OrderRequestPage extends StatelessWidget {
return MyScafolld( return MyScafolld(
title: 'Order Details'.tr, title: 'Order Details'.tr,
body: [ body: [
ListView( Padding(
// crossAxisAlignment: CrossAxisAlignment.start, padding: const EdgeInsets.symmetric(horizontal: 16),
children: [ child: ListView(
// SizedBox(height: 200, child: Text(pointsList.toString())), // crossAxisAlignment: CrossAxisAlignment.start,
// Text(message.notification!.body.toString()), children: [
SizedBox( // SizedBox(height: 200, child: Text(pointsList.toString())),
height: Get.height * .2, // Text(message.notification!.body.toString()),
child: GoogleMap( SizedBox(
initialCameraPosition: CameraPosition( height: Get.height * .2,
zoom: 12, child: GoogleMap(
target: Get.find<HomeCaptainController>().myLocation), initialCameraPosition: CameraPosition(
cameraTargetBounds: CameraTargetBounds(bounds), zoom: 12,
myLocationButtonEnabled: true, target: Get.find<HomeCaptainController>().myLocation),
trafficEnabled: true, cameraTargetBounds: CameraTargetBounds(bounds),
buildingsEnabled: true, myLocationButtonEnabled: true,
mapToolbarEnabled: true, trafficEnabled: true,
myLocationEnabled: true, buildingsEnabled: true,
markers: { mapToolbarEnabled: true,
Marker( myLocationEnabled: true,
markerId: MarkerId('MyLocation'.tr), markers: {
position: Marker(
LatLng(latPassengerLocation, lngPassengerLocation), markerId: MarkerId('MyLocation'.tr),
draggable: true, position: LatLng(
icon: startIcon), latPassengerLocation, lngPassengerLocation),
Marker( draggable: true,
markerId: MarkerId('Destination'.tr), icon: startIcon),
position: LatLng( Marker(
latPassengerDestination, lngPassengerDestination), markerId: MarkerId('Destination'.tr),
draggable: true, position: LatLng(
icon: endIcon), latPassengerDestination, lngPassengerDestination),
}, draggable: true,
polylines: { icon: endIcon),
Polyline( },
zIndex: 1, polylines: {
consumeTapEvents: true, Polyline(
geodesic: true, zIndex: 1,
endCap: Cap.buttCap, consumeTapEvents: true,
startCap: Cap.buttCap, geodesic: true,
visible: true, endCap: Cap.buttCap,
polylineId: const PolylineId('routeOrder'), startCap: Cap.buttCap,
points: pointsDirection, visible: true,
color: AppColor.primaryColor, polylineId: const PolylineId('routeOrder'),
width: 2, points: pointsDirection,
), color: AppColor.primaryColor,
}, width: 2,
),
},
),
), ),
), Padding(
Padding( padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8.0), child: Card(
child: Card( elevation: 3,
elevation: 3, color: myList[20].toString() == 'haveSteps'
color: myList[20].toString() == 'haveSteps' ? AppColor.greenColor
? AppColor.greenColor : AppColor.secondaryColor,
: AppColor.secondaryColor, child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton.icon(
onPressed: () {
String mapUrl =
'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/';
print(mapUrl);
showInBrowser(mapUrl);
},
icon: const Icon(Icons.map),
label: myList[20].toString() == 'haveSteps'
? Text(
'Trip has Steps'.tr,
style: AppStyle.title,
)
: Text('Rouats of Trip'.tr,
style: AppStyle.title)),
Container(
color: myList[13].toString() == 'true'
? AppColor.deepPurpleAccent
: AppColor.greenColor,
child: myList[13].toString() ==
'true' //Visa or Cash Method from notify to driver
? Text(
'Visa',
style: AppStyle.title,
)
: Text('Cash', style: AppStyle.title),
)
],
),
),
),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
double.parse(myList[2]).toStringAsFixed(2),
style: AppStyle.headTitle2,
)
// RichText(
// text: TextSpan(
// text: 'Total From Passenger is '.tr,
// style: AppStyle.title,
// children: [
// TextSpan(
// text: double.parse(myList[2]).toStringAsFixed(2),
// style: AppStyle.headTitle2),
// ],
// ),
// ),
),
),
Container(
height: Get.height * .15,
width: Get.width * .9,
decoration: AppStyle.boxDecoration1,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(
Icons.arrow_circle_up,
color: AppColor.greenColor,
),
Text(
myList[12] + ' ' + ' (${myList[11]}) ',
style: AppStyle.title,
),
],
),
Text(
myList[29],
style: AppStyle.title,
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(
Icons.arrow_circle_up,
color: AppColor.greenColor,
),
Text(
myList[5] + ' ' + ' (${myList[4]}) ',
style: AppStyle.title,
),
],
),
Text(
myList[30],
style: AppStyle.title,
),
],
),
],
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: RichText(
text: TextSpan(
text: 'Passenger Name is '.tr,
style: AppStyle.subtitle,
children: [
TextSpan(text: myList[8], style: AppStyle.title),
],
),
),
),
Padding(
padding: const EdgeInsets.all(4),
child: Container(
color: AppColor.deepPurpleAccent,
child: RichText(
text: TextSpan(
text: 'Cost Of Trip IS '.tr,
style: AppStyle.title,
children: [
TextSpan(
text: double.parse(myList[26]).toStringAsFixed(2),
style: AppStyle.headTitle2),
],
),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
TextButton.icon( MyElevatedButton(
onPressed: () { kolor: AppColor.greenColor,
String mapUrl = title: 'Accept Order'.tr,
'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/'; onPressed: () async {
print(mapUrl); box.write(BoxName.statusDriverLocation, 'on');
showInBrowser(mapUrl);
}, orderRequestController.changeApplied();
icon: const Icon(Icons.map), await CRUD().postFromDialogue(
label: myList[20].toString() == 'haveSteps' link: AppLink.addDriverOrder,
? Text( payload: {
'Trip has Steps'.tr, 'driver_id': myList[6].toString(),
style: AppStyle.title, // box.read(BoxName.driverID).toString(),
) 'order_id': body.toString(),
: Text('Rouats of Trip'.tr, 'status': 'Apply'
style: AppStyle.title)), });
Container( await CRUD()
color: myList[13].toString() == 'true' .post(link: AppLink.updateRides, payload: {
? AppColor.deepPurpleAccent 'id': myList[16],
: AppColor.greenColor, 'rideTimeStart': DateTime.now().toString(),
child: myList[13].toString() == 'status': 'Apply',
'true' //Visa or Cash Method from notify to driver 'driver_id': box.read(BoxName.driverID),
? Text( });
'Visa', // Get.back();
style: AppStyle.title, List<String> bodyToPassenger = [
) box.read(BoxName.driverID).toString(),
: Text('Cash', style: AppStyle.title), box.read(BoxName.nameDriver).toString(),
) box.read(BoxName.tokenDriver).toString(),
];
// print(bodyToPassenger);
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Apply Ride', 'your ride is applied'.tr,
// arguments['DriverList'][9].toString(),
arguments['DriverList'][9].toString(),
// box.read(BoxName.tokenDriver).toString(),
bodyToPassenger,
);
Get.back();
Get.to(() => PassengerLocationMapPage(), arguments: {
'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(),
});
},
),
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 {
List<String> bodyToPassenger = [
box.read(BoxName.driverID).toString(),
box.read(BoxName.nameDriver).toString(),
box.read(BoxName.tokenDriver).toString(),
];
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Refused Ride',
'${box.read(BoxName.nameDriver)} ${'rejct your order.'.tr}',
arguments['DriverList'][9].toString(),
// box.read(BoxName.tokenDriver).toString(),
bodyToPassenger,
);
orderRequestController.refuseOrder(
myList[16].toString(),
);
},
kolor: AppColor.redColor,
),
], ],
), ),
), )
), ],
),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
double.parse(myList[2]).toStringAsFixed(2),
style: AppStyle.headTitle2,
)
// RichText(
// text: TextSpan(
// text: 'Total From Passenger is '.tr,
// style: AppStyle.title,
// children: [
// TextSpan(
// text: double.parse(myList[2]).toStringAsFixed(2),
// style: AppStyle.headTitle2),
// ],
// ),
// ),
),
),
Container(
height: Get.height * .15,
width: Get.width * .9,
decoration: AppStyle.boxDecoration1,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(
Icons.arrow_circle_up,
color: AppColor.greenColor,
),
Text(
myList[12] + ' ' + ' (${myList[11]}) ',
style: AppStyle.title,
),
],
),
Text(
myList[29],
style: AppStyle.title,
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(
Icons.arrow_circle_up,
color: AppColor.greenColor,
),
Text(
myList[5] + ' ' + ' (${myList[4]}) ',
style: AppStyle.title,
),
],
),
Text(
myList[30],
style: AppStyle.title,
),
],
),
],
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: RichText(
text: TextSpan(
text: 'Passenger Name is '.tr,
style: AppStyle.subtitle,
children: [
TextSpan(text: myList[8], style: AppStyle.title),
],
),
),
),
// 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(4),
child: Container(
color: AppColor.deepPurpleAccent,
child: RichText(
text: TextSpan(
text: 'Cost Of Trip IS '.tr,
style: AppStyle.title,
children: [
TextSpan(
text: double.parse(myList[26]).toStringAsFixed(2),
style: AppStyle.headTitle2),
],
),
),
),
),
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: RichText(
// text: TextSpan(
// text: 'Distance from Passenger to destination 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: hours > 1
// ? '${'Your Ride Duration is '.tr}$hours${' H and'.tr} $minutes m'
// : '${'Your Ride Duration is '.tr} $minutes m',
// style: AppStyle.title),
// TextSpan(text: ' Minutes'.tr, style: AppStyle.title),
// ]),
// ),
// ),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MyElevatedButton(
kolor: AppColor.greenColor,
title: 'Accept Order'.tr,
onPressed: () async {
box.write(BoxName.statusDriverLocation, 'on');
orderRequestController.changeApplied();
await CRUD().postFromDialogue(
link: AppLink.addDriverOrder,
payload: {
'driver_id': myList[6].toString(),
// box.read(BoxName.driverID).toString(),
'order_id': body.toString(),
'status': 'Apply'
});
await CRUD().post(link: AppLink.updateRides, payload: {
'id': myList[16],
'rideTimeStart': DateTime.now().toString(),
'status': 'Apply',
'driver_id': box.read(BoxName.driverID),
});
// Get.back();
List<String> bodyToPassenger = [
box.read(BoxName.driverID).toString(),
box.read(BoxName.nameDriver).toString(),
box.read(BoxName.tokenDriver).toString(),
];
// print(bodyToPassenger);
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Apply Ride', 'your ride is applied'.tr,
// arguments['DriverList'][9].toString(),
arguments['DriverList'][9].toString(),
// box.read(BoxName.tokenDriver).toString(),
bodyToPassenger,
);
Get.back();
Get.to(() => PassengerLocationMapPage(), arguments: {
'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(),
});
},
),
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 {
List<String> bodyToPassenger = [
box.read(BoxName.driverID).toString(),
box.read(BoxName.nameDriver).toString(),
box.read(BoxName.tokenDriver).toString(),
];
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Refused Ride',
'${box.read(BoxName.nameDriver)} ${'rejct your order.'.tr}',
arguments['DriverList'][9].toString(),
// box.read(BoxName.tokenDriver).toString(),
bodyToPassenger,
);
orderRequestController.refuseOrder(
myList[16].toString(),
);
},
kolor: AppColor.redColor,
),
],
),
)
],
) )
], ],
isleading: true); isleading: true);

View File

@@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:SEFER/controller/home/captin/home_captain_controller.dart'; import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -33,6 +35,8 @@ class OrderSpeedRequest extends StatelessWidget {
orderRequestController.startTimer(myList[6].toString(), body.toString()); orderRequestController.startTimer(myList[6].toString(), body.toString());
var coords = myList[0].split(','); var coords = myList[0].split(',');
var coordDestination = myList[1].split(','); var coordDestination = myList[1].split(',');
BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker;
// Parse to double // Parse to double
double latPassengerLocation = double.parse(coords[0]); double latPassengerLocation = double.parse(coords[0]);
@@ -58,307 +62,426 @@ class OrderSpeedRequest extends StatelessWidget {
southwest: LatLng(minLatitude, minLongitude), southwest: LatLng(minLatitude, minLongitude),
northeast: LatLng(maxLatitude, maxLongitude), northeast: LatLng(maxLatitude, maxLongitude),
); );
// void addCustomStartIcon() async {
// Create the marker with the resized image
ImageConfiguration config = ImageConfiguration(
size: const Size(25, 25), devicePixelRatio: Get.pixelRatio);
BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png',
mipmaps: false)
.then((value) {
startIcon = value;
});
ImageConfiguration config1 = ImageConfiguration(
size: const Size(25, 25), devicePixelRatio: Get.pixelRatio);
BitmapDescriptor.fromAssetImage(config1, 'assets/images/b.png',
mipmaps: false)
.then((value) {
endIcon = value;
});
// }
return MyScafolld( return MyScafolld(
title: 'Order Details Speed'.tr, title: 'Order Details'.tr,
body: [ body: [
Container( ListView(
color: AppColor.accentColor, // crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, // SizedBox(height: 200, child: Text(pointsList.toString())),
children: [ // Text(message.notification!.body.toString()),
// SizedBox(height: 200, child: Text(pointsList.toString())), SizedBox(
// Text(message.notification!.body.toString()), height: Get.height * .2,
SizedBox( child: GoogleMap(
height: 200, initialCameraPosition: CameraPosition(
child: GoogleMap( zoom: 12,
initialCameraPosition: CameraPosition( target: Get.find<HomeCaptainController>().myLocation),
zoom: 12, cameraTargetBounds: CameraTargetBounds(bounds),
target: Get.find<HomeCaptainController>().myLocation), myLocationButtonEnabled: true,
cameraTargetBounds: CameraTargetBounds(bounds), trafficEnabled: true,
myLocationButtonEnabled: true, buildingsEnabled: true,
trafficEnabled: true, mapToolbarEnabled: true,
buildingsEnabled: true, myLocationEnabled: true,
mapToolbarEnabled: true, markers: {
myLocationEnabled: true, Marker(
markers: {
Marker(
markerId: MarkerId('MyLocation'.tr), markerId: MarkerId('MyLocation'.tr),
position: position:
LatLng(latPassengerLocation, lngPassengerLocation), LatLng(latPassengerLocation, lngPassengerLocation),
draggable: true, draggable: true,
icon: BitmapDescriptor.defaultMarkerWithHue( icon: startIcon),
BitmapDescriptor.hueGreen), Marker(
),
Marker(
markerId: MarkerId('Destination'.tr), markerId: MarkerId('Destination'.tr),
position: LatLng( position: LatLng(
latPassengerDestination, lngPassengerDestination), latPassengerDestination, lngPassengerDestination),
draggable: true, draggable: true,
icon: BitmapDescriptor.defaultMarkerWithHue( icon: endIcon),
BitmapDescriptor.hueBlue), },
), polylines: {
}, Polyline(
polylines: { zIndex: 1,
Polyline( consumeTapEvents: true,
zIndex: 1, geodesic: true,
consumeTapEvents: true, endCap: Cap.buttCap,
geodesic: true, startCap: Cap.buttCap,
endCap: Cap.buttCap, visible: true,
startCap: Cap.buttCap, polylineId: const PolylineId('routeOrder'),
visible: true, points: pointsDirection,
polylineId: const PolylineId('routeOrder'), color: AppColor.primaryColor,
points: pointsDirection, width: 2,
color: AppColor.primaryColor,
width: 2,
),
},
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
elevation: 3,
color: myList[20].toString() == 'haveSteps'
? AppColor.greenColor
: AppColor.secondaryColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton.icon(
onPressed: () {
String mapUrl =
'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/';
print(mapUrl);
showInBrowser(mapUrl);
},
icon: const Icon(Icons.map),
label: myList[20].toString() == 'haveSteps'
? Text(
'Trip has Steps'.tr,
style: AppStyle.title,
)
: Text('Rouats of Trip'.tr,
style: AppStyle.title)),
Container(
color: myList[13].toString() == 'true'
? AppColor.deepPurpleAccent
: AppColor.greenColor,
child: myList[13].toString() ==
'true' //Visa or Cash Method from notify to driver
? Text(
'Visa',
style: AppStyle.title,
)
: Text('Cash', style: AppStyle.title),
)
],
), ),
), },
), ),
),
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: RichText( child: Card(
text: TextSpan( elevation: 3,
text: 'Passenger Name is '.tr, color: myList[20].toString() == 'haveSteps'
style: AppStyle.title, ? AppColor.greenColor
children: [ : AppColor.secondaryColor,
TextSpan(text: myList[8], style: AppStyle.headTitle2),
],
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: RichText(
text: TextSpan(
text: 'Total 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: Container(
color: AppColor.deepPurpleAccent,
child: RichText(
text: TextSpan(
text: 'Cost Of Trip IS '.tr,
style: AppStyle.title,
children: [
TextSpan(
text: double.parse(myList[26]).toStringAsFixed(2),
style: AppStyle.headTitle2),
],
),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: RichText(
text: TextSpan(
text: 'Distance from Passenger to destination 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: hours > 1
? '${'Your Ride Duration is '.tr}$hours${' H and'.tr} $minutes m'
: '${'Your Ride Duration is '.tr} $minutes m',
style: AppStyle.title),
TextSpan(text: ' Minutes'.tr, style: AppStyle.title),
]),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
MyElevatedButton( TextButton.icon(
kolor: AppColor.greenColor, onPressed: () {
title: 'Accept Order'.tr, String mapUrl =
onPressed: () async { 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/';
box.write(BoxName.statusDriverLocation, 'on'); print(mapUrl);
showInBrowser(mapUrl);
orderRequestController.changeApplied(); },
await CRUD().postFromDialogue( icon: const Icon(Icons.map),
link: AppLink.addDriverOrder, label: myList[20].toString() == 'haveSteps'
payload: { ? Text(
'driver_id': box.read( 'Trip has Steps'.tr,
BoxName.driverID), //myList[6].toString(), style: AppStyle.title,
// box.read(BoxName.driverID).toString(), )
'order_id': : Text('Rouats of Trip'.tr,
myList[16].toString(), //body.toString(), style: AppStyle.title)),
'status': 'Apply' Container(
}); color: myList[13].toString() == 'true'
await CRUD() ? AppColor.deepPurpleAccent
.post(link: AppLink.updateRides, payload: { : AppColor.greenColor,
'id': myList[16], child: myList[13].toString() ==
'rideTimeStart': DateTime.now().toString(), 'true' //Visa or Cash Method from notify to driver
'status': 'Apply', ? Text(
'driver_id': box.read(BoxName.driverID), 'Visa',
}); style: AppStyle.title,
// Get.back(); )
List<String> bodyToPassenger = [ : Text('Cash', style: AppStyle.title),
box.read(BoxName.driverID).toString(), )
box.read(BoxName.nameDriver).toString(),
box.read(BoxName.tokenDriver).toString(),
];
// print(bodyToPassenger);
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Apply Ride',
'The ${box.read(BoxName.nameDriver)} ${'accepted your order'.tr}',
arguments['DriverList'][9].toString(),
// box.read(BoxName.tokenDriver).toString(),
bodyToPassenger,
);
Get.back();
Get.to(() => PassengerLocationMapPage(), arguments: {
'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(),
});
},
),
GetBuilder<OrderRequestController>(
builder: (timerController) {
return Stack(
alignment: Alignment.center,
children: [
CircularProgressIndicator(
value: timerController.progressSpeed,
// Set the color based on the "isNearEnd" condition
color: Colors.blue,
),
Text(
'${timerController.remainingTimeSpeed}',
style: AppStyle.number,
),
],
);
},
),
], ],
), ),
) ),
], ),
),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
double.parse(myList[2]).toStringAsFixed(2),
style: AppStyle.headTitle2,
)
// RichText(
// text: TextSpan(
// text: 'Total From Passenger is '.tr,
// style: AppStyle.title,
// children: [
// TextSpan(
// text: double.parse(myList[2]).toStringAsFixed(2),
// style: AppStyle.headTitle2),
// ],
// ),
// ),
),
),
Container(
height: Get.height * .15,
width: Get.width * .9,
decoration: AppStyle.boxDecoration1,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(
Icons.arrow_circle_up,
color: AppColor.greenColor,
),
Text(
myList[12] + ' ' + ' (${myList[11]}) ',
style: AppStyle.title,
),
],
),
Text(
myList[29],
style: AppStyle.title,
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(
Icons.arrow_circle_up,
color: AppColor.greenColor,
),
Text(
myList[5] + ' ' + ' (${myList[4]}) ',
style: AppStyle.title,
),
],
),
Text(
myList[30],
style: AppStyle.title,
),
],
),
],
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: RichText(
text: TextSpan(
text: 'Passenger Name is '.tr,
style: AppStyle.subtitle,
children: [
TextSpan(text: myList[8], style: AppStyle.title),
],
),
),
),
// 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(4),
child: Container(
color: AppColor.deepPurpleAccent,
child: RichText(
text: TextSpan(
text: 'Cost Of Trip IS '.tr,
style: AppStyle.title,
children: [
TextSpan(
text: double.parse(myList[26]).toStringAsFixed(2),
style: AppStyle.headTitle2),
],
),
),
),
),
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: RichText(
// text: TextSpan(
// text: 'Distance from Passenger to destination 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: hours > 1
// ? '${'Your Ride Duration is '.tr}$hours${' H and'.tr} $minutes m'
// : '${'Your Ride Duration is '.tr} $minutes m',
// style: AppStyle.title),
// TextSpan(text: ' Minutes'.tr, style: AppStyle.title),
// ]),
// ),
// ),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MyElevatedButton(
kolor: AppColor.greenColor,
title: 'Accept Order'.tr,
onPressed: () async {
box.write(BoxName.statusDriverLocation, 'on');
orderRequestController.changeApplied();
await CRUD().postFromDialogue(
link: AppLink.addDriverOrder,
payload: {
'driver_id': myList[6].toString(),
// box.read(BoxName.driverID).toString(),
'order_id': body.toString(),
'status': 'Apply'
});
await CRUD()
.post(link: AppLink.updateStausFromSpeed, payload: {
'id': myList[16],
'rideTimeStart': DateTime.now().toString(),
'status': 'Apply',
'driver_id': box.read(BoxName.driverID),
}).then((value) {
var json = jsonDecode(value);
if (json['message'] ==
"This ride is already taken by another driver.") {
Get.defaultDialog(
title:
"This ride is already taken by another driver."
.tr,
middleText: '',
titleStyle: AppStyle.title,
middleTextStyle: AppStyle.title,
confirm: MyElevatedButton(
title: 'Ok'.tr,
onPressed: () => Get.back()));
} else if (json['message'] ==
"Ride data updated successfully") {
List<String> bodyToPassenger = [
box.read(BoxName.driverID).toString(),
box.read(BoxName.nameDriver).toString(),
box.read(BoxName.tokenDriver).toString(),
];
// print(bodyToPassenger);
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Apply Ride', 'your ride is applied'.tr,
// arguments['DriverList'][9].toString(),
arguments['DriverList'][9].toString(),
// box.read(BoxName.tokenDriver).toString(),
bodyToPassenger,
);
Get.back();
Get.to(() => PassengerLocationMapPage(),
arguments: {
'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(),
});
}
});
// Get.back();
},
),
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 {
Get.defaultDialog(
title: 'Reject Order'.tr,
titleStyle: AppStyle.title,
middleText:
'You can decline a request without any cost'.tr,
middleTextStyle: AppStyle.title,
confirm: MyElevatedButton(
title: 'Ok'.tr,
onPressed: () {
Get.back();
}));
},
kolor: AppColor.redColor,
),
],
),
)
],
) )
], ],
isleading: true); isleading: true);