This commit is contained in:
Hamza-Ayed
2023-09-17 18:42:51 +03:00
parent 2be93e8267
commit 5f402a0b65
17 changed files with 359 additions and 146 deletions

View File

@@ -282,9 +282,75 @@ class FirebasMessagesController extends GetxController {
)
],
));
} else if (message.notification!.title!.contains('Promo')) {
Get.to(const PromosPassengerPage());
}
} else if (message.notification!.title!.contains('Apply Ride')) {
// MapController().rideConfirm = true;
var passengerList = message.data['passengerList'];
print(passengerList);
print('9999999999999my Apply Ride 999999999999999');
var myList = jsonDecode(passengerList) as List<dynamic>;
driverID = myList[2].toString();
Get.snackbar(
'Captin Applied the Ride for You'.tr,
'message',
colorText: AppColor.greenColor,
duration: const Duration(seconds: 11),
instantInit: true,
snackPosition: SnackPosition.TOP,
titleText: Text(
'Applied'.tr,
style: const TextStyle(color: AppColor.redColor),
),
messageText: Text(
'Captin Applied the Ride for You'.tr,
style: AppStyle.title,
),
icon: const Icon(Icons.approval),
shouldIconPulse: true,
maxWidth: double.infinity,
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.all(16),
borderRadius: 8,
borderColor: AppColor.primaryColor,
borderWidth: 2,
backgroundColor: AppColor.secondaryColor,
leftBarIndicatorColor: AppColor.greenColor,
boxShadows: [
BoxShadow(
color: Colors.black.withOpacity(0.25),
blurRadius: 4,
spreadRadius: 2,
offset: const Offset(0, 4),
),
],
backgroundGradient: const LinearGradient(
colors: [AppColor.greenColor, AppColor.accentColor],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
onTap: (GetSnackBar snackBar) {
// Do something when the snackbar is tapped.
// MapController().rideConfirm = false;
// update();
},
isDismissible: true,
showProgressIndicator: false,
dismissDirection: DismissDirection.up,
progressIndicatorController: null,
progressIndicatorBackgroundColor: Colors.transparent,
progressIndicatorValueColor: null,
snackStyle: SnackStyle.GROUNDED,
forwardAnimationCurve: Curves.easeInToLinear,
reverseAnimationCurve: Curves.easeInOut,
animationDuration: const Duration(milliseconds: 4000),
barBlur: 8,
overlayBlur: 0,
snackbarStatus: null,
overlayColor: AppColor.primaryColor.withOpacity(0.5),
userInputForm: null,
);
} else if (message.notification!.title!.contains('Promo')) {
Get.to(const PromosPassengerPage());
}
});
}

View File

@@ -26,7 +26,7 @@ class CRUD {
if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
// print(jsonData);
print(jsonData);
return response.body;
}
return jsonData['status'];

View File

@@ -30,6 +30,7 @@ class MapController extends GetxController {
LatLng mydestination = const LatLng(32.115295, 36.064773);
final List<LatLng> polylineCoordinates = [];
List<LatLng> carsLocationByPassenger = [];
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
double height = 150;
@@ -57,6 +58,7 @@ class MapController extends GetxController {
late LatLng northeast;
List<CarLocationModel> carLocations = <CarLocationModel>[];
var dataCarsLocationByPassenger;
var datadriverCarsLocationToPassengerAfterApplied;
CarLocation? nearestCar;
late Timer markerReloadingTimer;
bool shouldFetch = true; // Flag to determine if fetch should be executed
@@ -226,7 +228,7 @@ class MapController extends GetxController {
void timerEnded() async {
print('Timer ended');
// refuseOrder();
runEvery50SecondsUntilConditionMet();
isCancelRidePageShown = false;
update();
}
@@ -437,6 +439,59 @@ class MapController extends GetxController {
}
}
Future getDriverCarsLocationToPassengerAfterApplied() async {
driverCarsLocationToPassengerAfterApplied = [];
var res = await CRUD().get(
link: AppLink.getDriverCarsLocationToPassengerAfterApplied,
payload: {
'driver_id': dataCarsLocationByPassenger['message'][0]['driver_id']
});
datadriverCarsLocationToPassengerAfterApplied = jsonDecode(res);
driverCarsLocationToPassengerAfterApplied.add(LatLng(
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
['latitude']),
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
['longitude'])));
update();
}
Future runEvery50SecondsUntilConditionMet() async {
// Calculate the duration of the trip in minutes.
double tripDurationInMinutes = duration1 / 60;
int loopCount = tripDurationInMinutes.ceil();
// If the trip duration is less than or equal to 50 minutes, then break the loop.
for (var i = 0; i < loopCount; i++) {
// Wait for 50 seconds.
await Future.delayed(const Duration(
seconds:
50)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
await getDriverCarsLocationToPassengerAfterApplied();
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
}
}
void reloadMarkerDriverCarsLocationToPassengerAfterApplied() {
// Clear existing markers
markers.clear();
for (var item in driverCarsLocationToPassengerAfterApplied) {
final marker = Marker(
infoWindow: InfoWindow(title: '${item.latitude} minutes'),
markerId: MarkerId(item.toString()),
position: LatLng(item.latitude, item.longitude),
);
markers.add(marker);
update();
mapController?.animateCamera(
CameraUpdate.newLatLng(LatLng(item.latitude, item.longitude)));
update();
} // Update the map with the new markers
}
LatLngBounds calculateBounds(
double centerLat, double centerLng, double radius) {
// double radius = 4000; // 10 km in meters

View File

@@ -18,7 +18,7 @@ class PaymentController extends GetxController {
final formKey = GlobalKey<FormState>();
final promo = TextEditingController();
double totalPassenger = MapController().totalPassenger;
int? selectedAmount;
int? selectedAmount = 0;
List<dynamic> totalPassengerWalletDetails = [];
String passengerTotalWalletAmount = '';
void updateSelectedAmount(int value) {