368 lines
16 KiB
Dart
368 lines
16 KiB
Dart
import 'package:SEFER/constant/colors.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:SEFER/views/home/Captin/home_captain/widget/call_page.dart';
|
|
import 'package:SEFER/views/home/map_widget.dart/call_passenger_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../constant/box_name.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 * .2,
|
|
child: ListView(
|
|
children: [
|
|
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: 200,
|
|
width: Get.width * .9,
|
|
decoration: AppStyle.boxDecoration1,
|
|
child: Column(
|
|
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(
|
|
'assets/images/blob.png',
|
|
width: 100,
|
|
),
|
|
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(
|
|
// '',
|
|
// ),
|
|
'https://ride.mobile-app.store/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: Column(
|
|
children: [
|
|
InkWell(
|
|
onTap: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger',
|
|
'Hello, I\'m at the agreed-upon location'
|
|
.tr,
|
|
controller.driverToken);
|
|
Get.back();
|
|
},
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.all(4),
|
|
child: Text(
|
|
'Hello, I\'m at the agreed-upon location'
|
|
.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger',
|
|
'My location is correct. You can search for me using the navigation app'
|
|
.tr,
|
|
controller.driverToken);
|
|
Get.back();
|
|
},
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.all(4),
|
|
child: Text(
|
|
'My location is correct. You can search for me using the navigation app'
|
|
.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
FirebaseMessagesController()
|
|
.sendNotificationToAnyWithoutData(
|
|
'message From passenger',
|
|
'I\'m waiting for you'
|
|
.tr,
|
|
controller.driverToken);
|
|
Get.back();
|
|
},
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.all(4),
|
|
child: Text(
|
|
'I\'m waiting for you'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
));
|
|
},
|
|
icon: const Icon(
|
|
Icons.message,
|
|
color: AppColor.blueColor,
|
|
size: 35,
|
|
),
|
|
),
|
|
IconButton(
|
|
onPressed: () {
|
|
HapticFeedback.heavyImpact();
|
|
Get.to(() => const CallPage());
|
|
// Get.to(() => PassengerCallPage());
|
|
},
|
|
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: 30,
|
|
borderRadius: BorderRadius.circular(15),
|
|
value:
|
|
controller.progressTimerDriverWaitPassenger5Minute.toDouble(),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'The driver waiting you in picked location .'.tr,
|
|
style: AppStyle.title,
|
|
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,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(
|
|
width: 20,
|
|
),
|
|
Text(
|
|
controller.stringRemainingTimeToPassenger,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox();
|
|
});
|
|
}
|
|
}
|