524 lines
26 KiB
Dart
524 lines
26 KiB
Dart
import 'package:SEFER/constant/colors.dart';
|
|
import 'package:SEFER/constant/links.dart';
|
|
import 'package:SEFER/constant/style.dart';
|
|
import 'package:SEFER/controller/firebase/firbase_messge.dart';
|
|
import 'package:SEFER/controller/home/map_passenger_controller.dart';
|
|
import 'package:SEFER/main.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../constant/box_name.dart';
|
|
import '../../../controller/functions/launch.dart';
|
|
import '../../widgets/my_textField.dart';
|
|
|
|
class ApplyOrderWidget extends StatelessWidget {
|
|
const ApplyOrderWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<MapPassengerController>(builder: (controller) {
|
|
if (controller.statusRide == 'Apply' &&
|
|
controller.isSearchingWindow == false) {
|
|
// double _height = Get.height * .2;
|
|
return Positioned(
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
height: Get.height * .35,
|
|
child: ListView(
|
|
children: [
|
|
InkWell(
|
|
onTap: () {
|
|
if (box.read(BoxName.carType) == 'Speed' ||
|
|
box.read(BoxName.carType) == 'Delivery') {
|
|
Get.snackbar(
|
|
'This price is'.tr +
|
|
' ${controller.totalPassenger.toStringAsFixed(2)}'
|
|
.tr,
|
|
'This ride type does not allow changes to the destination or additional stops'
|
|
.tr,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
duration: const Duration(seconds: 2),
|
|
backgroundColor: AppColor.yellowColor,
|
|
);
|
|
} else {
|
|
Get.snackbar(
|
|
'This price may be changed'.tr,
|
|
'This ride type allows changes, but the price may increase'
|
|
.tr,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
duration: const Duration(seconds: 2),
|
|
backgroundColor: AppColor.yellowColor,
|
|
);
|
|
}
|
|
},
|
|
child: Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: '${'The driver accept your order for'.tr} ',
|
|
style: AppStyle.title,
|
|
),
|
|
TextSpan(
|
|
text: controller.totalPassenger.toStringAsFixed(2),
|
|
style: AppStyle.title.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
// fontSize: 22,
|
|
color: AppColor.redColor,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: ' ${'LE'.tr}',
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Container(
|
|
height: Get.height * .3,
|
|
width: Get.width * .9,
|
|
decoration: AppStyle.boxDecoration1,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
// 'Comfort',
|
|
box.read(BoxName.carType
|
|
.toString()), //car type fro box after selected
|
|
style: AppStyle.title,
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Image.asset(
|
|
box.read(BoxName.carType) == 'Comfort'
|
|
? 'assets/images/blob.png'
|
|
: box.read(BoxName.carType) == 'Lady'
|
|
? 'assets/images/lady.png' // Assuming there's an image for Lady
|
|
: box.read(BoxName.carType) == 'Speed'
|
|
? 'assets/images/carspeed.png'
|
|
: box.read(BoxName.carType) ==
|
|
'Delivery'
|
|
? 'assets/images/moto.png'
|
|
: box.read(BoxName.carType) ==
|
|
'Mashwari'
|
|
? 'assets/images/freeRide.png'
|
|
: box.read(BoxName
|
|
.carType) ==
|
|
'Rayeh Gai'
|
|
? 'assets/images/roundtrip.png'
|
|
: 'assets/images/carspeed.png', // Default image if none of the above
|
|
width: 80,
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(
|
|
// 'Toyota Camry',
|
|
controller.model.toString(),
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
// 'ر ل 2323',
|
|
controller.licensePlate.toString(),
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
Text(
|
|
// 'Black',
|
|
controller.carColor,
|
|
style: AppStyle.title,
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
],
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
CircleAvatar(
|
|
radius: 30,
|
|
backgroundImage: NetworkImage(
|
|
// '',
|
|
// ),
|
|
'${AppLink.server}/portrate_captain_image/${controller.driverId}.jpg'),
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(
|
|
// 'fadi ahmad',
|
|
controller.firstName,
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
// '⭐ 4.8',
|
|
'⭐ ${controller.driverRate}',
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
IconButton(
|
|
onPressed: () async {
|
|
Get.defaultDialog(
|
|
title: 'Select one message'.tr,
|
|
titleStyle: AppStyle.title,
|
|
content: SizedBox(
|
|
width: Get.width * .6,
|
|
height: Get.height * .5,
|
|
child: ListView(
|
|
children: [
|
|
InkWell(
|
|
onTap: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger',
|
|
'Hello, I\'m at the agreed-upon location'
|
|
.tr,
|
|
controller.driverToken,
|
|
'ding.wav',
|
|
);
|
|
Get.back();
|
|
},
|
|
child: Container(
|
|
decoration:
|
|
AppStyle.boxDecoration1,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.all(
|
|
10),
|
|
child: Text(
|
|
'Hello, I\'m at the agreed-upon location'
|
|
.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger'.tr,
|
|
'My location is correct. You can search for me using the navigation app'
|
|
.tr,
|
|
controller.driverToken,
|
|
'ding.wav',
|
|
);
|
|
Get.back();
|
|
},
|
|
child: Container(
|
|
decoration:
|
|
AppStyle.boxDecoration1,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.all(
|
|
10),
|
|
child: Text(
|
|
'My location is correct. You can search for me using the navigation app'
|
|
.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger',
|
|
'My location is correct. You can search for me using the navigation app'
|
|
.tr,
|
|
controller.driverToken,
|
|
'ding.wav',
|
|
);
|
|
Get.back();
|
|
},
|
|
child: Container(
|
|
decoration:
|
|
AppStyle.boxDecoration1,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.all(
|
|
10),
|
|
child: Text(
|
|
'I\'m waiting for you'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger',
|
|
"How much longer will you be?"
|
|
.tr,
|
|
controller.driverToken,
|
|
'ding.wav',
|
|
);
|
|
Get.back();
|
|
},
|
|
child: Container(
|
|
decoration:
|
|
AppStyle.boxDecoration1,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.all(
|
|
10),
|
|
child: Text(
|
|
"How much longer will you be?"
|
|
.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
SizedBox(
|
|
width: Get.width * .5,
|
|
child: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.center,
|
|
children: [
|
|
Form(
|
|
key: controller
|
|
.messagesFormKey,
|
|
child: SizedBox(
|
|
width: Get.width * .4,
|
|
child: MyTextForm(
|
|
controller: controller
|
|
.messageToDriver,
|
|
label:
|
|
'Type Any thing'
|
|
.tr,
|
|
hint:
|
|
'Type Any thing'
|
|
.tr,
|
|
type:
|
|
TextInputType
|
|
.name),
|
|
)),
|
|
IconButton(
|
|
onPressed: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger',
|
|
controller
|
|
.messageToDriver
|
|
.text,
|
|
controller
|
|
.driverToken,
|
|
'ding.wav');
|
|
controller
|
|
.messageToDriver
|
|
.clear();
|
|
Get.back();
|
|
},
|
|
icon: const Icon(
|
|
Icons.send))
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
));
|
|
},
|
|
icon: const Icon(
|
|
Icons.message,
|
|
color: AppColor.blueColor,
|
|
size: 35,
|
|
),
|
|
),
|
|
IconButton(
|
|
onPressed: () async {
|
|
HapticFeedback.heavyImpact();
|
|
// Get.to(() => const CallPage());
|
|
// Get.to(() => PassengerCallPage());
|
|
makePhoneCall(controller.driverPhone);
|
|
},
|
|
icon: const Icon(
|
|
Icons.call,
|
|
color: AppColor.greenColor,
|
|
size: 35,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
controller.isDriverArrivePassenger
|
|
? const DriverArrivePassengerAndWaitMinute()
|
|
: const TimeDriverToPassenger()
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return const SizedBox();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
class DriverArrivePassengerAndWaitMinute extends StatelessWidget {
|
|
const DriverArrivePassengerAndWaitMinute({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<MapPassengerController>(builder: (controller) {
|
|
return Stack(
|
|
children: [
|
|
LinearProgressIndicator(
|
|
backgroundColor: AppColor.accentColor,
|
|
color: controller.remainingTimeDriverWaitPassenger5Minute < 60
|
|
? AppColor.redColor
|
|
: AppColor.greenColor,
|
|
minHeight: 25,
|
|
borderRadius: BorderRadius.circular(15),
|
|
value:
|
|
controller.progressTimerDriverWaitPassenger5Minute.toDouble(),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'The driver waiting you in picked location .'.tr,
|
|
style: AppStyle.subtitle,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(
|
|
width: 20,
|
|
),
|
|
Text(
|
|
controller.stringRemainingTimeDriverWaitPassenger5Minute,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
)
|
|
],
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
class TimeDriverToPassenger extends StatelessWidget {
|
|
const TimeDriverToPassenger({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<MapPassengerController>(builder: (controller) {
|
|
return controller.isDriverInPassengerWay == false ||
|
|
controller.timeToPassengerFromDriverAfterApplied > 0
|
|
? Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
|
|
child: Stack(
|
|
children: [
|
|
Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
width: Get.width * .7,
|
|
height: 35,
|
|
// color: AppColor.yellowColor,
|
|
),
|
|
Stack(
|
|
children: [
|
|
LinearProgressIndicator(
|
|
backgroundColor: AppColor.accentColor,
|
|
color: controller
|
|
.remainingTimeToPassengerFromDriverAfterApplied <
|
|
60
|
|
? AppColor.redColor
|
|
: AppColor.greenColor,
|
|
minHeight: 25,
|
|
borderRadius: BorderRadius.circular(15),
|
|
value: () {
|
|
// Ensure valid value between 0.0 and 1.0
|
|
double progress = controller
|
|
.progressTimerToPassengerFromDriverAfterApplied
|
|
.toDouble();
|
|
if (progress.isNaN || progress.isInfinite) {
|
|
// Handle invalid progress (e.g., set to 0.0)
|
|
return 0.0;
|
|
} else {
|
|
return progress.clamp(
|
|
0.0, 1.0); // Clamp to valid range
|
|
}
|
|
}(),
|
|
),
|
|
Center(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'The driver on your way'.tr,
|
|
style: AppStyle.title
|
|
.copyWith(color: AppColor.yellowColor),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(
|
|
width: 20,
|
|
),
|
|
Text(
|
|
controller.stringRemainingTimeToPassenger,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox();
|
|
});
|
|
}
|
|
}
|