Files
driver_tripz/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart
Hamza-Ayed 659f178737 9/29/1
2024-09-30 09:37:26 +03:00

607 lines
39 KiB
Dart

import 'package:SEFER/views/widgets/my_textField.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/info.dart';
import 'package:SEFER/controller/firebase/firbase_messge.dart';
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import '../../../../constant/style.dart';
import '../../../../controller/functions/launch.dart';
class PassengerInfoWindow extends StatelessWidget {
const PassengerInfoWindow({
super.key,
});
@override
Widget build(BuildContext context) {
Get.put(MapDriverController());
return GetBuilder<MapDriverController>(
builder: (controller) => controller.isPassengerInfoWindow == true
? Stack(
children: [
Positioned(
bottom: 5,
// left: 8,
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
height: Get.height * .4,
width: Get.width,
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DefaultTextStyle(
style: AppStyle.title,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'Go to passenger Location'.tr,
style: AppStyle.title
.copyWith(color: AppColor.greenColor),
),
controller.isRideBegin
? const SizedBox()
: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
GestureDetector(
onTap: () async {
controller.isSocialPressed =
true;
await controller
.driverCallPassenger(); // to check from scam
// Get.to(
// () => const CallPage());
makePhoneCall(controller
.passengerPhone
.toString());
// launchCommunication(
// 'phone',
// controller.passengerPhone
// ,
// '');
},
child: const Icon(
Icons.phone,
color: AppColor.blueColor,
)),
const SizedBox(
width: 25,
),
GestureDetector(
onTap: () async {
Get.defaultDialog(
title:
'Select one message'
.tr,
titleStyle:
AppStyle.title,
content: SizedBox(
height: Get.height * .5,
width: Get.width * .6,
child: ListView(
// mainAxisAlignment:
// MainAxisAlignment
// .spaceEvenly,
children: [
InkWell(
onTap: () {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'message From Driver',
"Where are you, sir?"
.tr,
controller
.tokenPassenger,
'ding.wav');
Get.back();
},
child: Container(
decoration: AppStyle
.boxDecoration1,
child: Padding(
padding:
const EdgeInsets
.all(
10),
child: Text(
"Where are you, sir?"
.tr,
style: AppStyle
.title,
),
),
),
),
const SizedBox(
height: 5,
),
InkWell(
onTap: () {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'message From Driver',
"I've been trying to reach you but your phone is off."
.tr,
controller
.tokenPassenger,
'ding.wav');
Get.back();
},
child: Container(
decoration: AppStyle
.boxDecoration1,
child: Padding(
padding:
const EdgeInsets
.all(
10),
child: Text(
"I've been trying to reach you but your phone is off."
.tr,
style: AppStyle
.title,
),
),
),
),
const SizedBox(
height: 5,
),
InkWell(
onTap: () {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'message From Driver',
"Please don't be late, I'm waiting for you at the specified location."
.tr,
controller
.tokenPassenger,
'ding.wav');
Get.back();
},
child: Container(
decoration: AppStyle
.boxDecoration1,
child: Padding(
padding:
const EdgeInsets
.all(
10),
child: Text(
"Please don't be late, I'm waiting for you at the specified location."
.tr,
style: AppStyle
.title,
),
),
),
),
const SizedBox(
height: 5,
),
InkWell(
onTap: () {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'message From Driver',
"Please don't be late"
.tr,
controller
.tokenPassenger,
'ding.wav');
Get.back();
},
child: Container(
decoration: AppStyle
.boxDecoration1,
child: Padding(
padding:
const EdgeInsets
.all(
10),
child: Text(
"Please don't be late"
.tr,
style: AppStyle
.title,
),
),
),
),
const SizedBox(
height: 5,
),
SizedBox(
width: 200,
child: Row(
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
Form(
key: controller
.formKey2,
child:
SizedBox(
width:
160,
child: MyTextForm(
controller:
controller.messageToPassenger,
label: 'Type Any thing'.tr,
hint: 'Type Any thing'.tr,
type: TextInputType.name),
)),
IconButton(
onPressed:
() {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'message From Driver'.tr,
controller.messageToPassenger.text,
controller.tokenPassenger,
'ding.wav');
controller
.messageToPassenger
.clear();
Get.back();
},
icon: const Icon(
Icons
.send))
],
),
)
],
),
));
},
child: const Icon(
Icons.message,
color: AppColor.redColor,
)),
const SizedBox(
width: 25,
),
Container(
decoration:
AppStyle.boxDecoration,
child: IconButton(
onPressed: () async {
await controller
.openGoogleMapFromDriverToPassenger();
},
icon: const Icon(
MaterialCommunityIcons
.map_marker_radius,
size: 35,
color: AppColor.blueColor,
),
)),
],
),
],
)),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: AppStyle.boxDecoration1,
width: Get.width * .22,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
controller.hours > 1
? '⌚️ ${controller.hours}h ${controller.minutes}m' // Ride Duration with emoji
: '⌚️ ${controller.minutes}m', // Short ride duration
style: AppStyle.number,
),
),
),
const SizedBox(
width: 10.0), // Add spacing between sections
Container(
decoration: AppStyle.boxDecoration1,
width: Get.width * .22,
child: Padding(
padding: const EdgeInsets.all(4),
child: Text(
' ${controller.distance} km', // Distance with emoji
style: AppStyle.number,
),
),
),
const SizedBox(
width: 16.0), // Add spacing between sections
Container(
decoration: AppStyle.boxDecoration1,
width: Get.width * .35,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
controller
.passengerName, // Passenger name with emoji
style: AppStyle.title,
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
decoration: AppStyle.boxDecoration1,
width: Get.width * .4,
child: Padding(
padding: const EdgeInsets.all(4),
child: Row(
children: [
Text("cost is ".tr,
style: AppStyle.title),
Text(
controller.totalPricePassenger
.toString(),
style: AppStyle.number,
),
],
),
),
),
Container(
decoration: AppStyle.boxDecoration1,
width: Get.width * .4,
child: Padding(
padding: const EdgeInsets.all(4),
child: Text(controller.carType.tr,
style: AppStyle.title),
),
),
],
),
controller.remainingTimeToPassenger != 0
? Stack(
children: [
LinearProgressIndicator(
backgroundColor: AppColor.accentColor,
color:
controller.remainingTimeToPassenger <
60
? AppColor.redColor
: AppColor.greenColor,
minHeight: 25,
borderRadius: BorderRadius.circular(15),
value: controller.progressToPassenger
.toDouble(),
),
Center(
child: Text(
controller
.stringRemainingTimeToPassenger,
style: AppStyle.title,
),
)
],
)
: controller.isRideBegin
? const SizedBox()
: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Start the Ride'.tr,
kolor: AppColor.greenColor,
onPressed: () {
Get.defaultDialog(
title:
'Is the Passenger in your Car ?'
.tr,
titleStyle:
AppStyle.title,
middleText:
"don't start trip if not"
.tr,
middleTextStyle:
AppStyle.title,
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor
.greenColor,
onPressed: () async {
await controller
.startRideFromDriver();
Get.back();
}),
cancel: MyElevatedButton(
title:
'No ,still Waiting.'
.tr,
kolor:
AppColor.redColor,
onPressed: () {
Get.back();
}));
}),
controller.isArrivedSend
? MyElevatedButton(
title: 'I arrive you'.tr,
kolor: AppColor.yellowColor,
onPressed: () async {
// Await the result of the distance calculation
double distanceToArrive =
await controller
.calculateDistanceBetweenDriverAndPassengerLocation();
if (distanceToArrive <
40) {
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Hi ,I Arrive your site',
'I Arrive your site'
.tr,
controller
.tokenPassenger,
[],
'start.wav');
controller
.startTimerToShowDriverWaitPassengerDuration();
controller
.isArrivedSend =
false;
} else {
Get.defaultDialog(
title:
'You are not in near to passenger location'
.tr,
middleText:
'please go to picker location exactly'
.tr,
confirm:
MyElevatedButton(
title:
'Ok'.tr,
onPressed:
() {
Get.back();
}));
}
})
: const SizedBox()
],
),
controller.remainingTimeInPassengerLocatioWait <
300 &&
controller
.remainingTimeInPassengerLocatioWait !=
0
? Stack(
children: [
LinearProgressIndicator(
backgroundColor:
AppColor.greyColor,
color: controller
.remainingTimeInPassengerLocatioWait <
60
? AppColor.redColor
: AppColor.greenColor,
minHeight: 25,
borderRadius:
BorderRadius.circular(
15),
value: controller
.progressInPassengerLocationFromDriver
.toDouble(),
),
Center(
child: Text(
controller
.stringRemainingTimeWaitingPassenger,
style: AppStyle.title,
),
)
],
)
: controller.isdriverWaitTimeEnd
? MyElevatedButton(
title: 'You Can Cancel Trip And get Cost of Trip From'
.tr +
' ${AppInformation.appName}'
.tr,
kolor: AppColor
.deepPurpleAccent,
onPressed: () {
Get.defaultDialog(
title:
'Are you sure to cancel?'
.tr,
titleStyle:
AppStyle.title,
middleText: '',
confirm:
MyElevatedButton(
title:
'Yes'.tr,
onPressed:
() async {
FirebaseMessagesController().sendNotificationToPassengerToken(
'Driver Cancel Your Trip',
'You will be pay the cost to driver or we will get it from you on next trip'
.tr,
controller
.tokenPassenger,
[],
'cancel.wav');
await controller
.addWaitingTimeCostFromPassengerToDriverWallet();
controller
.isdriverWaitTimeEnd =
false;
}));
})
: const SizedBox(),
],
),
],
),
),
),
),
],
)
// : controller.remainingTimeToShowPassengerInfoWindowFromDriver > 0 //
// ? Positioned(
// bottom: Get.height * .2,
// left: 15,
// child: Container(
// decoration: AppStyle.boxDecoration,
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: Row(
// children: [
// Stack(
// alignment: Alignment.center,
// children: [
// const CircularProgressIndicator(
// backgroundColor: AppColor.redColor,
// strokeWidth: 10,
// color: AppColor.redColor,
// value: 1,
// ),
// CircularProgressIndicator(
// value: controller.progress,
// // Set the color based on the "isNearEnd" condition
// color: AppColor.yellowColor,
// ),
// Text(
// '${controller.remainingTimeToShowPassengerInfoWindowFromDriver}',
// style: AppStyle.number,
// ),
// ],
// ),
// const SizedBox(
// width: 10,
// ),
// Text(
// 'Please Wait If passenger want To Cancel!'.tr,
// style: AppStyle.title,
// ),
// ],
// ),
// ),
// ),
// )
: const SizedBox(),
);
}
}