From 92b0713811c37c1d73933c1b38a9981e5b017cd2 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sat, 23 Sep 2023 16:39:05 +0300 Subject: [PATCH] 9/23/1 --- lib/controller/firebase/firbase_messge.dart | 7 +++++- lib/controller/home/map_page_controller.dart | 15 ++++++----- lib/views/home/map_page.dart | 25 +++++++++++++++++++ .../driver_time_arrive_passenger.dart | 12 ++++----- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 79b9829..678c1b5 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -112,7 +112,12 @@ class FirebasMessagesController extends GetxController { 'body': message.notification!.body }); } else if (message.notification!.title!.contains('Apply Ride')) { - // MapController().rideConfirm = true; + // MapController mapController = Get.put(MapController()); + // mapController.rideConfirm = false; + // print('-----------------------------rideConfirm===' + + // mapController.rideConfirm.toString()); + // update(); + var passengerList = message.data['passengerList']; print(passengerList); print('9999999999999my Apply Ride 999999999999999'); diff --git a/lib/controller/home/map_page_controller.dart b/lib/controller/home/map_page_controller.dart index 0f685da..b5cdc40 100644 --- a/lib/controller/home/map_page_controller.dart +++ b/lib/controller/home/map_page_controller.dart @@ -151,7 +151,7 @@ class MapController extends GetxController { "price": totalPassenger.toString(), "passenger_id": box.read(BoxName.pasengerID).toString(), "driver_id": dataCarsLocationByPassenger['message'][0]['id'].toString(), - "status": "active", + "status": "waiting", "price_for_driver": totalDriver.toString(), "price_for_passenger": totaME.toString(), "distance": distance.toString() @@ -194,25 +194,24 @@ class MapController extends GetxController { } void delayAndFetchRideStatus(String rideId) { - Timer(const Duration(seconds: 3), () async { + Timer(const Duration(seconds: 1), () async { if (shouldFetch) { // print('shouldFetch is =$shouldFetch'); var res = await CRUD() .get(link: AppLink.getRideStatus, payload: {'order_id': rideId}); var decod = jsonDecode(res); - // print(' 0000000000000000000000000000000000000000000000000'); - // print(decod['data']); + print(' 0000000000000000000000000000000000000000000000000'); + print(decod['data']); if (decod['data'].toString() == 'Apply' || decod['data'].toString() == 'Refused') { shouldFetch = false; // Stop further fetches rideConfirm = false; + update(); startTimer(); - update(); } else { - shouldFetch = true; + delayAndFetchRideStatus( + rideId); // Repeat the delay and fetch operation update(); - // delayAndFetchRideStatus( - // rideId); // Repeat the delay and fetch operation } } }); diff --git a/lib/views/home/map_page.dart b/lib/views/home/map_page.dart index 0f647a8..2153fbc 100644 --- a/lib/views/home/map_page.dart +++ b/lib/views/home/map_page.dart @@ -197,6 +197,13 @@ class MapPage extends StatelessWidget { position: carLocation, icon: controller.carIcon, markerId: MarkerId(carLocation.toString())), + for (var carLocation in controller + .driverCarsLocationToPassengerAfterApplied) + Marker( + // anchor: const Offset(4, 4), + position: carLocation, + icon: controller.carIcon, + markerId: MarkerId(carLocation.toString())), Marker( markerId: MarkerId('MyLocation'.tr), position: controller.mylocation, @@ -287,6 +294,24 @@ class MapPage extends StatelessWidget { const PaymentMethodPage(), timerForCancellTripFromPassenger(), const DriverTimeArrivePassengerPage(), + GetBuilder(builder: (controller) { + if (controller.remainingTime == 0 + //&& + // controller.newTime1.isBefore( + // controller.currentTime.add(const Duration(minutes: 2)), + // ) + ) { + return Center( + child: Container( + decoration: AppStyle.boxDecoration, + height: 100, + width: 100, + ), + ); + } else { + return const SizedBox(); + } + }), ], ), ), diff --git a/lib/views/home/map_widget.dart/driver_time_arrive_passenger.dart b/lib/views/home/map_widget.dart/driver_time_arrive_passenger.dart index 2520e46..6e94dc3 100644 --- a/lib/views/home/map_widget.dart/driver_time_arrive_passenger.dart +++ b/lib/views/home/map_widget.dart/driver_time_arrive_passenger.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:ride/views/home/map_widget.dart/hexegone_clipper.dart'; +import 'package:intl/intl.dart'; +// import 'package:intl/intl.dart'; import '../../../constant/style.dart'; import '../../../controller/home/map_page_controller.dart'; @@ -13,12 +14,9 @@ class DriverTimeArrivePassengerPage extends StatelessWidget { return GetBuilder( builder: (controller) { return controller.remainingTime == 0 - ? Positioned.directional( + ? Positioned( bottom: Get.height * .35, - end: Get.width * .05, - textDirection: Get.locale!.languageCode == 'ar' - ? TextDirection.rtl - : TextDirection.ltr, + right: Get.width * .05, child: Stack( alignment: Alignment.center, children: [ @@ -37,7 +35,7 @@ class DriverTimeArrivePassengerPage extends StatelessWidget { style: AppStyle.title, ), Text( - controller.newTime1.toString(), + " ${DateFormat('h:mm a').format(controller.newTime)}", style: AppStyle.title, ), ],