585 lines
36 KiB
Dart
585 lines
36 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:SEFER/views/widgets/my_textField.dart';
|
|
import 'package:SEFER/views/widgets/mydialoug.dart';
|
|
import 'package:bubble_head/bubble.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 {
|
|
if (Platform.isAndroid) {
|
|
Bubble().startBubbleHead(
|
|
sendAppToBackground:
|
|
true);
|
|
}
|
|
await controller
|
|
.openGoogleMapFromDriverToPassenger();
|
|
},
|
|
icon: const Icon(
|
|
MaterialCommunityIcons
|
|
.map_marker_radius,
|
|
size: 35,
|
|
color: AppColor.blueColor,
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
],
|
|
)),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// First Row: Trip Info (Duration, Distance, Passenger Name)
|
|
Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceAround,
|
|
children: [
|
|
// Ride Duration
|
|
Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
width: Get.width * .28,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(6.0),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.timer,
|
|
color: Colors
|
|
.grey[700]), // Duration Icon
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
controller.hours > 1
|
|
? '${controller.hours}h ${controller.minutes}${'m'.tr}'
|
|
: '${controller.minutes}${'m'.tr}',
|
|
style: AppStyle.number,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// Ride Distance
|
|
Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
width: Get.width * .28,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(6.0),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.map,
|
|
color: Colors
|
|
.grey[700]), // Distance Icon
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
'${controller.distance} km',
|
|
style: AppStyle.number,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// Passenger Name
|
|
Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
width: Get.width * .38,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(6.0),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.person,
|
|
color: Colors
|
|
.grey[700]), // Passenger Icon
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
controller.passengerName,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(
|
|
height: 16), // Spacing between rows
|
|
|
|
// Second Row: Cost & Car Type
|
|
Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceAround,
|
|
children: [
|
|
// Ride Cost
|
|
Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
width: Get.width * .45,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(6.0),
|
|
child: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(Icons.attach_money,
|
|
color: Colors
|
|
.grey[700]), // Cost Icon
|
|
const SizedBox(width: 6),
|
|
Text("cost is ".tr,
|
|
style: AppStyle.title),
|
|
],
|
|
),
|
|
Text(
|
|
controller.totalPricePassenger,
|
|
style: AppStyle.number,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// Car Type
|
|
Container(
|
|
decoration: AppStyle.boxDecoration1,
|
|
width: Get.width * .45,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(6.0),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.directions_car,
|
|
color:
|
|
Colors.grey[700]), // Car Icon
|
|
const SizedBox(width: 6),
|
|
Text(controller.carType.tr,
|
|
style: AppStyle.title),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
controller.isRideBegin
|
|
? const SizedBox()
|
|
: Column(
|
|
children: [
|
|
// First Row: Start Ride or Arrive at Location
|
|
Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceAround,
|
|
children: [
|
|
// Start Ride Button
|
|
MyElevatedButton(
|
|
title: 'Start the Ride'.tr,
|
|
kolor: AppColor.greenColor,
|
|
onPressed: () {
|
|
MyDialog().getDialog(
|
|
"Is the Passenger in your Car ?"
|
|
.tr,
|
|
"Don't start trip if not".tr,
|
|
() async {
|
|
await controller
|
|
.startRideFromDriver();
|
|
// Close dialog after confirmation
|
|
},
|
|
);
|
|
},
|
|
),
|
|
|
|
// Arrive Notification Button
|
|
controller.isArrivedSend
|
|
? MyElevatedButton(
|
|
title: 'I Arrive'.tr,
|
|
kolor: AppColor.yellowColor,
|
|
onPressed: () async {
|
|
if (await controller
|
|
.calculateDistanceBetweenDriverAndPassengerLocation() <
|
|
40) {
|
|
// Notify Passenger
|
|
FirebaseMessagesController()
|
|
.sendNotificationToPassengerToken(
|
|
'Hi, I Arrive at your site',
|
|
'I Arrive at your site'
|
|
.tr,
|
|
controller.tokenPassenger,
|
|
[],
|
|
'start.wav',
|
|
);
|
|
controller
|
|
.startTimerToShowDriverWaitPassengerDuration();
|
|
controller.isArrivedSend =
|
|
false;
|
|
} else {
|
|
MyDialog().getDialog(
|
|
'You are not near the passenger location'
|
|
.tr,
|
|
'Please go to the pickup location exactly'
|
|
.tr, () {
|
|
Get.back();
|
|
});
|
|
// Show error dialog if the driver is far from passenger
|
|
}
|
|
},
|
|
)
|
|
: const SizedBox(), // Hide if already sent
|
|
],
|
|
),
|
|
|
|
// const SizedBox(
|
|
// height: 16), // Space between rows
|
|
|
|
// Progress Bar for Waiting Time
|
|
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,
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: const SizedBox(),
|
|
|
|
const SizedBox(
|
|
height:
|
|
16), // Space between progress and next section
|
|
|
|
// Cancel Trip and Charge Passenger
|
|
controller.isdriverWaitTimeEnd
|
|
? MyElevatedButton(
|
|
title:
|
|
'You Can Cancel the Trip and get Cost From '
|
|
.tr +
|
|
AppInformation.appName.tr,
|
|
kolor: AppColor.deepPurpleAccent,
|
|
onPressed: () {
|
|
MyDialog().getDialog(
|
|
'Are you sure to cancel?'.tr,
|
|
'', () async {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToPassengerToken(
|
|
'Driver Cancelled Your Trip',
|
|
'You will need to pay the cost to the driver, or it will be deducted from your next trip'
|
|
.tr,
|
|
controller.tokenPassenger,
|
|
[],
|
|
'cancel.wav',
|
|
);
|
|
await controller
|
|
.addWaitingTimeCostFromPassengerToDriverWallet();
|
|
controller.isdriverWaitTimeEnd =
|
|
false;
|
|
Get.back();
|
|
});
|
|
},
|
|
)
|
|
: const SizedBox(),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: const SizedBox(),
|
|
);
|
|
}
|
|
}
|