This commit is contained in:
Hamza-Ayed
2023-12-31 14:54:28 +03:00
parent ee41f87b69
commit 8475bdc831
7 changed files with 158 additions and 165 deletions

View File

@@ -13,11 +13,6 @@ import '../../constant/style.dart';
import '../../main.dart'; import '../../main.dart';
import '../../views/home/profile/promos_passenger_page.dart'; import '../../views/home/profile/promos_passenger_page.dart';
import '../../views/home/Captin/orderCaptin/order_request_page.dart'; import '../../views/home/Captin/orderCaptin/order_request_page.dart';
import '../../views/widgets/elevated_btn.dart';
import '../functions/crud.dart';
import '../functions/launch.dart';
import '../home/captin/map_driver_controller.dart';
import '../home/map_passenger_controller.dart';
class FirebaseMessagesController extends GetxController { class FirebaseMessagesController extends GetxController {
final fcmToken = FirebaseMessaging.instance; final fcmToken = FirebaseMessaging.instance;
@@ -203,19 +198,19 @@ class FirebaseMessagesController extends GetxController {
} }
// If the app is in the background or terminated, show a system tray message // If the app is in the background or terminated, show a system tray message
RemoteNotification? notification = message.notification; RemoteNotification? notification = message.notification;
AndroidNotification? android = message.notification?.android; AndroidNotification? android = notification?.android;
// if (notification != null && android != null) { // if (notification != null && android != null) {
if (notification != null && android != null) { if (notification != null && android != null) {
print('onMessageOpenedApp: ${notification.title} ${notification.body}'); // print('onMessageOpenedApp: ${notification.title} ${notification.body}');
if (message.data.isNotEmpty) { if (message.data.isNotEmpty) {
if (message.notification!.title!.contains('Order')) { if (message.notification!.title!.contains('Order')) {
var myListString = message.data['DriverList']; var myListString = message.data['DriverList'];
print(myListString); // print(myListString);
print('9999999999999myListString999999999999999'); // print('9999999999999myListString999999999999999');
var myList = jsonDecode(myListString) as List<dynamic>; var myList = jsonDecode(myListString) as List<dynamic>;
driverToken = myList[14].toString(); driverToken = myList[14].toString();
update(); update();
print('driverToken==============$driverToken'); // print('driverToken==============$driverToken');
Get.to(() => OrderRequestPage(), arguments: { Get.to(() => OrderRequestPage(), arguments: {
'myListString': myListString, 'myListString': myListString,
'DriverList': myList, 'DriverList': myList,
@@ -223,8 +218,8 @@ class FirebaseMessagesController extends GetxController {
}); });
} else if (message.notification!.title!.contains('Apply Ride')) { } else if (message.notification!.title!.contains('Apply Ride')) {
var passengerList = message.data['passengerList']; var passengerList = message.data['passengerList'];
print(passengerList); // print(passengerList);
print('9999999999999my Apply Ride 999999999999999'); // print('9999999999999my Apply Ride 999999999999999');
var myList = jsonDecode(passengerList) as List<dynamic>; var myList = jsonDecode(passengerList) as List<dynamic>;
driverID = myList[2].toString(); driverID = myList[2].toString();
@@ -313,18 +308,18 @@ class FirebaseMessagesController extends GetxController {
}); });
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print( // print(
'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}'); // 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
RemoteNotification? notification = message.notification; RemoteNotification? notification = message.notification;
if (message.data.isNotEmpty) { if (message.data.isNotEmpty) {
if (message.notification!.title!.contains('Order')) { if (notification!.title!.contains('Order')) {
var myListString = message.data['DriverList']; var myListString = message.data['DriverList'];
print(myListString); // print(myListString);
print('9999999999999myListString999999999999999'); // print('9999999999999myListString999999999999999');
var myList = jsonDecode(myListString) as List<dynamic>; var myList = jsonDecode(myListString) as List<dynamic>;
driverToken = myList[14].toString(); driverToken = myList[14].toString();
update(); update();
print('driverToken==============$driverToken'); // print('driverToken==============$driverToken');
Get.to(() => OrderRequestPage(), arguments: { Get.to(() => OrderRequestPage(), arguments: {
'myListString': myListString, 'myListString': myListString,
'DriverList': myList, 'DriverList': myList,
@@ -332,8 +327,8 @@ class FirebaseMessagesController extends GetxController {
}); });
} else if (message.notification!.title!.contains('Apply Ride')) { } else if (message.notification!.title!.contains('Apply Ride')) {
var passengerList = message.data['passengerList']; var passengerList = message.data['passengerList'];
print(passengerList); // print(passengerList);
print('9999999999999my Apply Ride 999999999999999'); // print('9999999999999my Apply Ride 999999999999999');
var myList = jsonDecode(passengerList) as List<dynamic>; var myList = jsonDecode(passengerList) as List<dynamic>;
driverID = myList[2].toString(); driverID = myList[2].toString();

View File

@@ -103,6 +103,18 @@ class MapPassengerController extends GetxController {
late String driverToken; late String driverToken;
int carsOrder = 0; int carsOrder = 0;
String? mapAPIKEY; String? mapAPIKEY;
late double totalME = 0;
late double tax = 0;
late double totalPassenger = 0;
late double totalDriver = 0;
late double averageDuration = 0;
late double costDuration = 0;
late double cost = 0;
late double distance = 0;
late double duration = 0;
late Duration durationToAdd;
late DateTime newTime = DateTime.now();
void onChangedPassengerCount(int newValue) { void onChangedPassengerCount(int newValue) {
selectedPassengerCount = newValue; selectedPassengerCount = newValue;
@@ -116,6 +128,7 @@ class MapPassengerController extends GetxController {
void getCurrentLocationFormString() async { void getCurrentLocationFormString() async {
currentLocationToFormPlaces = true; currentLocationToFormPlaces = true;
currentLocationString = 'Waiting for your location'.tr;
await getLocation(); await getLocation();
currentLocationString = myLocation.toString(); currentLocationString = myLocation.toString();
newStartPointLocation = myLocation; newStartPointLocation = myLocation;
@@ -401,7 +414,7 @@ class MapPassengerController extends GetxController {
update(); update();
} else { } else {
Get.defaultDialog( Get.defaultDialog(
title: 'No Car or Captain Found in your area.'.tr, title: 'No Car or Driver Found in your area.'.tr,
titleStyle: AppStyle.title, titleStyle: AppStyle.title,
middleText: 'Please Try anther time '.tr, middleText: 'Please Try anther time '.tr,
middleTextStyle: AppStyle.title.copyWith(color: AppColor.yellowColor), middleTextStyle: AppStyle.title.copyWith(color: AppColor.yellowColor),
@@ -436,7 +449,7 @@ class MapPassengerController extends GetxController {
changeConfirmRide(); changeConfirmRide();
} else { } else {
Get.defaultDialog( Get.defaultDialog(
title: 'There no Captain Aplly your order sorry for that '.tr, title: 'There no Driver Aplly your order sorry for that '.tr,
middleText: 'try next time .', middleText: 'try next time .',
confirm: MyElevatedButton( confirm: MyElevatedButton(
title: 'Back', title: 'Back',
@@ -503,30 +516,19 @@ class MapPassengerController extends GetxController {
var res = var res =
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: { await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
'southwestLat': southwest.latitude.toString(), 'southwestLat': bounds.southwest.latitude.toString(),
'southwestLon': southwest.longitude.toString(), 'southwestLon': bounds.southwest.longitude.toString(),
'northeastLat': northeast.latitude.toString(), 'northeastLat': bounds.northeast.latitude.toString(),
'northeastLon': northeast.longitude.toString(), 'northeastLon': bounds.northeast.longitude.toString(),
}); });
if (res == 'failure') { if (res == 'failure') {
noCarString = true; noCarString = true;
dataCarsLocationByPassenger = res; dataCarsLocationByPassenger = res;
update(); update();
// Get.snackbar('No Car in your site.Sorry!'.tr, '',
// backgroundColor: AppColor.redColor);
// Get.defaultDialog(
// title: 'No Car in your site.Sorry!'.tr,
// middleText: '',
// confirm: MyElevatedButton(
// title: 'Back',
// onPressed: () {
// Get.back();
// markerReloadingTimer.cancel();
// }));
} else { } else {
noCarString = false; noCarString = false;
dataCarsLocationByPassenger = jsonDecode(res); dataCarsLocationByPassenger = jsonDecode(res);
// print(dataCarsLocationByPassenger); print(dataCarsLocationByPassenger);
// if (dataCarsLocationByPassenger.length > carsOrder) { // if (dataCarsLocationByPassenger.length > carsOrder) {
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id'] driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
.toString(); .toString();
@@ -569,7 +571,7 @@ class MapPassengerController extends GetxController {
Future runEvery30SecondsUntilConditionMet() async { Future runEvery30SecondsUntilConditionMet() async {
// Calculate the duration of the trip in minutes. // Calculate the duration of the trip in minutes.
double tripDurationInMinutes = duration1 / 30; double tripDurationInMinutes = duration1 / 20;
int loopCount = tripDurationInMinutes.ceil(); int loopCount = tripDurationInMinutes.ceil();
// If the trip duration is less than or equal to 50 minutes, then break the loop. // If the trip duration is less than or equal to 50 minutes, then break the loop.
for (var i = 0; i < loopCount; i++) { for (var i = 0; i < loopCount; i++) {
@@ -769,7 +771,7 @@ class MapPassengerController extends GetxController {
ImageConfiguration config = ImageConfiguration( ImageConfiguration config = ImageConfiguration(
size: Size(Get.width * .6, Get.height * .6), size: Size(Get.width * .6, Get.height * .6),
); );
BitmapDescriptor.fromAssetImage(config, 'assets/images/picker.png') BitmapDescriptor.fromAssetImage(config, 'assets/images/brand.png')
.then((value) { .then((value) {
tripIcon = value; tripIcon = value;
update(); update();
@@ -1133,18 +1135,6 @@ class MapPassengerController extends GetxController {
return distance; return distance;
} }
late double totalME = 0;
late double tax = 0;
late double totalPassenger = 0;
late double totalDriver = 0;
late double averageDuration = 0;
late double costDuration = 0;
late double cost = 0;
late double distance = 0;
late double duration = 0;
late Duration durationToAdd;
late DateTime newTime = DateTime.now();
Future bottomSheet() async { Future bottomSheet() async {
if (data.isNotEmpty) { if (data.isNotEmpty) {
String distanceText = await data[0]['distance']['text']; String distanceText = await data[0]['distance']['text'];

View File

@@ -47,70 +47,85 @@ GetBuilder<MapPassengerController> buttomSheetMapPage() {
], ],
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
Radius.circular(15))), Radius.circular(15))),
child: Row( child: ListView.builder(
mainAxisAlignment: MainAxisAlignment.spaceBetween, itemCount:
children: [ controller.dataCarsLocationByPassenger.length,
SizedBox( itemBuilder: (BuildContext context, int index) {
width: Get.width * .15, return Row(
child: Padding( mainAxisAlignment:
padding: const EdgeInsets.all(8.0), MainAxisAlignment.spaceBetween,
child: Image.asset( children: [
'assets/images/jeep.png', SizedBox(
width: 50, width: Get.width * .15,
fit: BoxFit.fill, child: Padding(
repeat: ImageRepeat.repeatX, padding: const EdgeInsets.all(8.0),
), child: Column(
), children: [
), Text(controller
SizedBox( .dataCarsLocationByPassenger
width: Get.width * .55, .toString()),
child: Column( Image.asset(
crossAxisAlignment: 'assets/images/jeep.png',
CrossAxisAlignment.start, width: 50,
mainAxisAlignment: fit: BoxFit.fill,
MainAxisAlignment.spaceEvenly, repeat: ImageRepeat.repeatX,
children: [ ),
Text( ],
'${'Your Ride Duration is '.tr}${controller.duration} minutes',
style: AppStyle.subtitle,
),
Text(
'${'You will be thier in'.tr} ${DateFormat('h:mm a').format(controller.newTime)}',
style: AppStyle.subtitle,
),
Text(
'${'You trip distance is'.tr} ${controller.distance} KM',
style: AppStyle.subtitle,
)
],
),
),
SizedBox(
width: Get.width * .2,
child: Padding(
padding: const EdgeInsets.only(
right: 5, left: 5),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Text(
'${'Fee is'.tr} \n${controller.totalPassenger.toStringAsFixed(2)}',
style: AppStyle.subtitle,
), ),
controller.promoTaken ),
? const Icon(
Icons.filter_vintage_rounded,
color: AppColor.redColor,
)
: const SizedBox(
height: 0,
)
],
), ),
), SizedBox(
), width: Get.width * .55,
], child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'Your Ride Duration is '.tr}${controller.duration} minutes',
style: AppStyle.subtitle,
),
Text(
'${'You will be thier in'.tr} ${DateFormat('h:mm a').format(controller.newTime)}',
style: AppStyle.subtitle,
),
Text(
'${'You trip distance is'.tr} ${controller.distance} KM',
style: AppStyle.subtitle,
)
],
),
),
SizedBox(
width: Get.width * .2,
child: Padding(
padding: const EdgeInsets.only(
right: 5, left: 5),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Text(
'${'Fee is'.tr} \n${controller.totalPassenger.toStringAsFixed(2)}',
style: AppStyle.subtitle,
),
controller.promoTaken
? const Icon(
Icons
.filter_vintage_rounded,
color: AppColor.redColor,
)
: const SizedBox(
height: 0,
)
],
),
),
),
],
);
},
), ),
), ),
const SizedBox( const SizedBox(

View File

@@ -151,7 +151,7 @@ class GoogleMapPassengerWidget extends StatelessWidget {
markerId: MarkerId('MyLocation'.tr), markerId: MarkerId('MyLocation'.tr),
position: controller.newStartPointLocation, position: controller.newStartPointLocation,
draggable: true, draggable: true,
icon: controller.tripIcon, icon: controller.markerIcon,
infoWindow: const InfoWindow( infoWindow: const InfoWindow(
title: 'Time', title: 'Time',
// snippet: controller.durationFromDriverToPassenger // snippet: controller.durationFromDriverToPassenger
@@ -166,7 +166,7 @@ class GoogleMapPassengerWidget extends StatelessWidget {
markerId: MarkerId('Destination'.tr), markerId: MarkerId('Destination'.tr),
position: controller.newMyLocation, position: controller.newMyLocation,
draggable: true, draggable: true,
icon: controller.tripIcon, icon: controller.markerIcon,
infoWindow: const InfoWindow( infoWindow: const InfoWindow(
title: 'Time', title: 'Time',
// snippet: controller.durationFromDriverToPassenger // snippet: controller.durationFromDriverToPassenger

View File

@@ -82,15 +82,15 @@ class MainBottomMenuMap extends StatelessWidget {
controller.startLocationFromMap = controller.startLocationFromMap =
false; false;
controller.isPickerShown = false; controller.isPickerShown = false;
print(controller.myLocation); // print(controller.myLocation);
print(controller // print(controller
.newStartPointLocation); // .newStartPointLocation);
} else { } else {
controller.newMyLocation = controller.newMyLocation =
controller.newMyLocation; controller.newMyLocation;
controller.isPickerShown = false; controller.isPickerShown = false;
print(controller.myLocation); // print(controller.myLocation);
print(controller.newMyLocation); // print(controller.newMyLocation);
} }
// await controller.getMap( // await controller.getMap(

View File

@@ -203,39 +203,43 @@ class IconMainPageMap extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return FutureBuilder(
onTap: onTap, future: Future.delayed(const Duration(milliseconds: 400)),
child: Padding( builder: (context, snapshot) {
padding: const EdgeInsets.all(4), return GestureDetector(
child: Container( onTap: onTap,
width: double.maxFinite, child: Padding(
decoration: const BoxDecoration( padding: const EdgeInsets.all(4),
borderRadius: BorderRadius.all(Radius.circular(16)), child: Container(
color: AppColor.secondaryColor, width: double.maxFinite,
boxShadow: [ decoration: const BoxDecoration(
BoxShadow( borderRadius: BorderRadius.all(Radius.circular(16)),
color: AppColor.accentColor, color: AppColor.secondaryColor,
offset: Offset(3, 3), boxShadow: [
blurRadius: 0, BoxShadow(
spreadRadius: 0, color: AppColor.accentColor,
blurStyle: BlurStyle.outer, offset: Offset(3, 3),
), blurRadius: 0,
], spreadRadius: 0,
), blurStyle: BlurStyle.outer,
child: Padding( ),
padding: const EdgeInsets.all(8.0), ],
child: Column(
children: [
Icon(icon),
Text(
title.tr,
style: AppStyle.subtitle,
), ),
], child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Icon(icon),
Text(
title.tr,
style: AppStyle.subtitle,
),
],
),
),
),
), ),
), );
), });
),
);
} }
} }

View File

@@ -45,17 +45,6 @@ class MyScafolld extends StatelessWidget {
style: AppStyle.title.copyWith(fontSize: 30), style: AppStyle.title.copyWith(fontSize: 30),
), ),
), ),
body: SafeArea( body: SafeArea(child: Stack(children: body)));
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: Get.height,
width: Get.width,
child: Stack(children: body))
],
),
)));
} }
} }