24-12/27/1

This commit is contained in:
Hamza-Ayed
2024-12-27 21:25:40 +03:00
parent d0dd09dc6c
commit f9f19c33ef
8 changed files with 423 additions and 683 deletions

View File

@@ -65,6 +65,7 @@ class AK {
static final String payMobOutPassword =
X.r(X.r(X.r(Env.payMobOutPassword, cn), cC), cs);
static final String privateKeyFCM = Env.privateKeyFCM;
static final String payMobOutUserName =
X.r(X.r(X.r(Env.payMobOutUserName, cn), cC), cs);

View File

@@ -1,5 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'package:sefer_driver/constant/api_key.dart';
import 'package:sefer_driver/controller/home/captin/home_captain_controller.dart';
import 'package:sefer_driver/views/widgets/error_snakbar.dart';
import 'package:sefer_driver/views/widgets/mydialoug.dart';
@@ -95,7 +96,7 @@ class FirebaseMessagesController extends GetxController {
}
Future<void> fireBaseTitles(RemoteMessage message) async {
if (message.notification!.title! == 'OrderSpeed'.tr) {
if (message.notification!.title! == 'Order'.tr) {
if (Platform.isAndroid) {
notificationController.showNotification(
message.notification!.title.toString(),
@@ -398,61 +399,6 @@ class FirebaseMessagesController extends GetxController {
}));
}
// Future<dynamic> driverFinishTripDialoge(List<dynamic> driverList) {
// return Get.defaultDialog(
// title: 'Driver Finish Trip'.tr,
// content: const DriverTipWidget(),
// confirm: MyElevatedButton(
// title: 'Yes'.tr,
// onPressed: () async {
// var tip = (Get.find<MapPassengerController>().totalPassenger) *
// (double.parse(box.read(BoxName.tipPercentage.toString())));
// var res = await CRUD().post(link: AppLink.addTips, payload: {
// 'passengerID': box.read(BoxName.passengerID),
// 'driverID': driverList[0].toString(),
// 'rideID': driverList[1].toString(),
// 'tipAmount': tip.toString(),
// });
// await CRUD().post(link: AppLink.addPassengersWallet, payload: {
// 'passenger_id': box.read(BoxName.passengerID).toString(),
// 'balance': ((-1) * tip).toString()
// });
// await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
// 'driverID': driverList[0].toString(),
// 'paymentID': '${Get.find<MapPassengerController>().rideId}tip',
// 'amount': (tip * 100).toString(),
// 'paymentMethod': 'visa-tip',
// });
// if (res != 'failure') {
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
// 'You Have Tips',
// '${'${tip.toString()}\$${' tips\nTotal is'.tr}'} ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
// driverList[2].toString(),
// );
// }
// Get.to(() => RateDriverFromPassenger(), arguments: {
// 'driverId': driverList[0].toString(),
// 'rideId': driverList[1].toString(),
// 'price': driverList[3].toString()
// });
// },
// kolor: AppColor.greenColor,
// ),
// cancel: MyElevatedButton(
// title: 'No,I want'.tr,
// onPressed: () {
// Get.to(() => RateDriverFromPassenger(), arguments: {
// 'driverId': driverList[0].toString(),
// 'rideId': driverList[1].toString(),
// 'price': driverList[3].toString()
// });
// },
// kolor: AppColor.redColor,
// ));
// }
void sendNotificationAll(String title, body, tone) async {
// Get the token you want to subtract.
String token = box.read(BoxName.tokenFCM);
@@ -528,33 +474,6 @@ class FirebaseMessagesController extends GetxController {
}
}
// for (var i = 0; i < tokens.length; i++) {
// http
// .post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
// headers: <String, String>{
// 'Content-Type': 'application/json',
// 'Authorization': 'key=${storage.read(key: BoxName.serverAPI}'
// },
// body: jsonEncode({
// 'notification': <String, dynamic>{
// 'title': title,
// 'body': body,
// 'sound': 'true'
// },
// 'priority': 'high',
// 'data': <String, dynamic>{
// 'click_action': 'FLUTTER_NOTIFICATION_CLICK',
// 'id': '1',
// 'status': 'done'
// },
// 'to': tokens[i],
// }))
// .whenComplete(() {})
// .catchError((e) {
// });
// }
// }
//android/app/src/main/res/raw/iphone_ringtone.wav
void sendNotificationToPassengerToken(
String title, body, token, List<String> map, String tone,
{int retryCount = 2}) async {

View File

@@ -30,23 +30,22 @@ class OrderRequestController extends GetxController {
var myList;
late int hours;
late int minutes;
GoogleMapController? mapController; // Make it nullable
@override
Future<void> onInit() async {
// AudioController audioController = Get.put(AudioController());
print('onInit called');
await initilizeOrderPage();
print('OrderRequestController onInit called');
await initializeOrderPage();
bool isOverlayActive = await FlutterOverlayWindow.isActive();
if (isOverlayActive) {
await FlutterOverlayWindow.closeOverlay();
}
// audioController.playAudio();
// getRefusedOrderByCaptain();
addCustomStartIcon();
addCustomEndIcon();
// calculateConsumptionFuel();
startTimer(
myList[6].toString(),
myList[16].toString(),
);
update();
super.onInit();
}
@@ -59,16 +58,16 @@ class OrderRequestController extends GetxController {
late double lngPassengerDestination;
late double latPassengerDestination;
Future<void> initilizeOrderPage() async {
Future<void> initializeOrderPage() async {
final myListString = Get.arguments['myListString'];
if (Get.arguments['DriverList'] == null ||
Get.arguments['DriverList'].isEmpty) {
myList = jsonDecode(myListString);
Log.print('myList: ${myList}');
Log.print('myList from myListString: ${myList}');
} else {
myList = Get.arguments['DriverList'];
Log.print('myList1: ${myList}');
Log.print('myList from DriverList: ${myList}');
}
body = Get.arguments['body'];
@@ -78,36 +77,58 @@ class OrderRequestController extends GetxController {
minutes = (durationToAdd.inMinutes % 60).round();
startTimerSpeed(myList[6].toString(), body.toString());
// Instead of splitting, directly use the values from the list
// First coordinate pair is at index 0 and 1
latPassengerLocation = double.tryParse(myList[0]) ?? 0.0;
lngPassengerLocation = double.tryParse(myList[1]) ?? 0.0;
// --- Using the provided logic for initialization ---
var cords = myList[0].toString().split(',');
var cordDestination = myList[1].toString().split(',');
// Second coordinate pair is at index 2 and 3
latPassengerDestination = double.tryParse(myList[2]) ?? 0.0;
lngPassengerDestination = double.tryParse(myList[3]) ?? 0.0;
double? parseDouble(String value) {
try {
return double.parse(value);
} catch (e) {
Log.print("Error parsing value: $value");
return null; // or handle the error appropriately
}
}
latPassengerLocation = parseDouble(cords[0]) ?? 0.0;
lngPassengerLocation = parseDouble(cords[1]) ?? 0.0;
latPassengerDestination = parseDouble(cordDestination[0]) ?? 0.0;
lngPassengerDestination = parseDouble(cordDestination[1]) ?? 0.0;
pointsDirection = [
LatLng(latPassengerLocation, lngPassengerLocation),
LatLng(latPassengerDestination, lngPassengerDestination)
];
Log.print('pointsDirection: $pointsDirection');
// Calculate bounds
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);
calculateBounds();
update();
}
void onMapCreated(GoogleMapController controller) {
mapController = controller;
animateCameraToBounds();
}
void calculateBounds() {
double minLat = math.min(latPassengerLocation, latPassengerDestination);
double maxLat = math.max(latPassengerLocation, latPassengerDestination);
double minLng = math.min(lngPassengerLocation, lngPassengerDestination);
double maxLng = math.max(lngPassengerLocation, lngPassengerDestination);
bounds = LatLngBounds(
southwest: LatLng(minLatitude, minLongitude),
northeast: LatLng(maxLatitude, maxLongitude),
southwest: LatLng(minLat, minLng),
northeast: LatLng(maxLat, maxLng),
);
Log.print('Calculated Bounds: $bounds');
}
update();
void animateCameraToBounds() {
if (mapController != null) {
mapController!.animateCamera(CameraUpdate.newLatLngBounds(bounds, 80.0));
} else {
Log.print('mapController is null, cannot animate camera.');
}
}
getRideDEtailsForBackgroundOrder(String rideId) async {
@@ -117,10 +138,7 @@ class OrderRequestController extends GetxController {
}
void addCustomStartIcon() async {
// Create the marker with the resized image
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
ImageConfiguration config = const ImageConfiguration(size: Size(30, 30));
BitmapDescriptor.asset(
config,
'assets/images/A.png',
@@ -131,8 +149,7 @@ class OrderRequestController extends GetxController {
}
void addCustomEndIcon() {
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
ImageConfiguration config = const ImageConfiguration(size: Size(30, 30));
BitmapDescriptor.asset(
config,
'assets/images/b.png',
@@ -149,8 +166,7 @@ class OrderRequestController extends GetxController {
double mpg = 0;
calculateConsumptionFuel() {
mpg = Get.find<HomeCaptainController>().fuelPrice /
12; //todo in register car add mpg in box
mpg = Get.find<HomeCaptainController>().fuelPrice / 12;
}
bool _timerActive = false;
@@ -161,7 +177,6 @@ class OrderRequestController extends GetxController {
await Future.delayed(const Duration(seconds: 1));
progress = i / duration;
remainingTime = duration - i;
update();
}
if (remainingTime == 0 && _timerActive) {
@@ -181,13 +196,11 @@ class OrderRequestController extends GetxController {
await Future.delayed(const Duration(seconds: 1));
progressSpeed = i / durationSpeed;
remainingTimeSpeed = durationSpeed - i;
update();
}
if (remainingTimeSpeed == 0) {
if (applied == false) {
Get.back();
// refuseOrder(box.read(BoxName.driverID), orderID);
}
}
}
@@ -196,39 +209,23 @@ class OrderRequestController extends GetxController {
orderID,
) async {
await CRUD().postFromDialogue(link: AppLink.addDriverOrder, payload: {
//TODO need review
'driver_id': box.read(BoxName.driverID),
// box.read(BoxName.driverID).toString(),
'order_id': orderID,
'status': 'Refused'
});
await CRUD().post(link: AppLink.updateRides, payload: {
'id': orderID,
// 'rideTimeStart': DateTime.now().toString(),
'status': 'Refused',
'driver_id': box.read(BoxName.driverID),
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(link: '${AppLink.endPoint}/rides/update.php', payload: {
'id': orderID,
// 'rideTimeStart': DateTime.now().toString(),
'status': 'Refused',
'driver_id': box.read(BoxName.driverID),
});
}
// applied = true;
// if (box.read(BoxName.gender).toString() != 'Female') {
// sql.insertData({
// 'order_id': orderID,
// 'created_at': DateTime.now().toString(),
// 'driver_id': box.read(BoxName.driverID).toString(),
// }, TableName.driverOrdersRefuse);
// getRefusedOrderByCaptain();
// }
update();
// Get.back();
// Get.offAll(HomeCaptain());
}
addRideToNotificationDriverString(

View File

@@ -10,12 +10,14 @@ class MyTranslation extends Translations {
"Duration": "المدة",
"Distance": "المسافة",
"Passenger": "الراكب",
"Cost": "التكلفة",
"Cost": "التكلفة", "Order": "طلب",
"Car Type": "نوع ‏الطلب",
"Start the Ride": "ابدأ الرحلة",
"Start the Ride": "ابدأ الرحلة", "Accepted Ride": "تم قبول الرحلة",
"Is the Passenger in your Car?": "هل الراكب في سيارتك؟",
"Don't start trip if passenger not in your car":
"لا تبدأ الرحلة إذا لم يكن الراكب في سيارتك",
"your ride is Accepted": "تم قبول رحلتك",
'Driver Accepted the Ride for You': 'السائق قبل الرحلة لك',
"I Arrive": "لقد وصلت", "Trip is Begin": "بدأت الرحلة",
"You are not near the passenger location":
"أنت لست بالقرب من موقع الراكب",

View File

@@ -46,7 +46,7 @@ Future<void> backgroundMessageHandler(RemoteMessage message) async {
if (Platform.isAndroid) {
if (message.notification != null && message.notification!.title != null) {
if (message.notification?.title == 'Order' ||
if (message.notification?.title == 'Order'.tr ||
message.notification?.title == 'OrderSpeed') {
var myListString = message.data['DriverList'] ?? '[]';
Log.print('myListString: $myListString');

View File

@@ -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 {}
}

View File

@@ -306,8 +306,8 @@ class RideAvailableCard extends StatelessWidget {
}
FirebaseMessagesController().sendNotificationToPassengerToken(
'Apply Ride',
'your ride is applied'.tr,
"Accepted Ride".tr,
'your ride is Accepted'.tr,
// arguments['DriverList'][9].toString(),
rideInfo['passengerToken'].toString(),
// box.read(BoxName.tokenDriver).toString(),