Files
tripz/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart
Hamza Aleghwairyeen 88b671c112 4/10/2
2024-04-10 02:42:17 +03:00

399 lines
23 KiB
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/box_name.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/main.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import '../../../../constant/style.dart';
import '../../../../controller/functions/launch.dart';
import '../home_captain/widget/call_page.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: controller.passengerInfoWindow,
width: Get.width * .99,
decoration: AppStyle.boxDecoration,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DefaultTextStyle(
style: AppStyle.title,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'Go to passenger Location now'.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());
// launchCommunication('phone',
// controller.phone.toString(), '');
},
child: const Icon(
Icons.phone,
color: AppColor.blueColor,
)),
const SizedBox(
width: 25,
),
GestureDetector(
onTap: () {
controller.isSocialPressed =
true;
launchCommunication(
'email',
controller.passengerPhone
.toString(),
'${'Hello this is Driver'.tr} ${box.read(BoxName.nameDriver)}');
},
child: const Icon(
Icons.email,
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,
),
)),
],
),
],
)
// AnimatedTextKit(
// animatedTexts: [
// ScaleAnimatedText(
// 'Go to passenger Location now'.tr,
// ),
// WavyAnimatedText(
// 'Go to passenger Location now'.tr),
// FlickerAnimatedText(
// 'Go to passenger Location now'.tr),
// WavyAnimatedText(
// 'Go to passenger Location now'.tr),
// ],
// isRepeatingAnimation: true,
// onTap: () {
// // print("Tap Event");
// },
// ),
),
Row(
children: [
Text(
controller.hours > 1
? '${'${'Your Ride Duration is '.tr}${controller.hours}${' H and'.tr}'} ${controller.minutes} m'
: '${'Your Ride Duration is '.tr} ${controller.minutes} ${'m'.tr}',
style: AppStyle.title),
],
),
Row(
children: [
Text('Distance of the Ride is '.tr,
style: AppStyle.title),
Text(
'${controller.distance} ${'KM'.tr}',
style: AppStyle.title,
),
],
),
Row(
children: [
Text('Name of the Passenger is '.tr,
style: AppStyle.title),
Text(
controller.passengerName.toString(),
style: AppStyle.title,
),
],
),
Card(
elevation: 5,
color: AppColor.greenColor,
child: Padding(
padding: const EdgeInsets.all(4),
child: Row(
children: [
Text('Total Cost is '.tr,
style: AppStyle.title),
Text(
controller.totalPassenger.toString(),
style: AppStyle.title,
),
],
),
),
),
controller.remainingTimeToPassenger != 0
? Stack(
children: [
LinearProgressIndicator(
backgroundColor: AppColor.accentColor,
color:
controller.remainingTimeToPassenger <
60
? AppColor.redColor
: AppColor.greenColor,
minHeight: 35,
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,
middleText:
'don\'t start trip if not '
.tr,
confirm: MyElevatedButton(
title: 'OK'.tr,
onPressed: () async {
await controller
.startRideFromDriver();
Get.back();
}),
cancel: MyElevatedButton(
title:
'No ,still Waiting.'
.tr,
onPressed: () {
Get.back();
}));
}),
controller.isArrivedSend
? MyElevatedButton(
title: 'I arrive you'.tr,
kolor: AppColor.yellowColor,
onPressed: () async {
if (controller
.calculateDistanceBetweenDriverAndPassengerLocation() <
40) {
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Hi ,I Arrive your site',
'I Arrive your site'
.tr,
controller
.tokenPassenger,
[]);
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.accentColor,
color: controller
.remainingTimeInPassengerLocatioWait <
60
? AppColor.redColor
: AppColor.greenColor,
minHeight: 50,
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,
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,
[]);
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(),
);
}
}