12/1/1
This commit is contained in:
@@ -89,7 +89,7 @@ class HomeCaptainController extends GetxController {
|
||||
|
||||
isActive = !isActive;
|
||||
if (isActive) {
|
||||
if (double.parse(totalPoints) > -3000) {
|
||||
if (double.parse(totalPoints) > -300) {
|
||||
locationController.startLocationUpdates();
|
||||
// locationBackController.startBackLocation();
|
||||
activeStartTime = DateTime.now();
|
||||
|
||||
@@ -173,19 +173,20 @@ class MapDriverController extends GetxController {
|
||||
|
||||
cancelTripFromDriverAfterApplied() async {
|
||||
if (formKeyCancel.currentState!.validate()) {
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
"Cancel Trip from driver",
|
||||
"Trip Cancelled from driver. We are looking for a new driver. Please wait."
|
||||
.tr,
|
||||
tokenPassenger,
|
||||
[],
|
||||
'cancel.wav',
|
||||
);
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD()
|
||||
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
}
|
||||
await CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferCairoServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
@@ -196,6 +197,11 @@ class MapDriverController extends GetxController {
|
||||
"notes": cancelTripCotroller.text.toString()
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD()
|
||||
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.endPoint}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
@@ -206,14 +212,6 @@ class MapDriverController extends GetxController {
|
||||
"notes": cancelTripCotroller.text.toString()
|
||||
});
|
||||
}
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
"Cancel Trip from driver".tr,
|
||||
"Trip Cancelled from driver. We are looking for a new driver. Please wait."
|
||||
.tr,
|
||||
tokenPassenger,
|
||||
[],
|
||||
'cancel.wav',
|
||||
);
|
||||
|
||||
sql.insertData({
|
||||
'order_id': rideId,
|
||||
@@ -221,7 +219,7 @@ class MapDriverController extends GetxController {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
Get.find<HomeCaptainController>().getRefusedOrderByCaptain();
|
||||
Get.offAll(HomeCaptain());
|
||||
Get.offAll(() => HomeCaptain());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,21 +548,21 @@ class MapDriverController extends GetxController {
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
MyDialog().getDialog('Are you sure to exit ride ?'.tr, '', () {
|
||||
if (distanceToDestination > 900 ||
|
||||
(double.parse(distance.toString()) < 1000 &&
|
||||
distanceToDestination > 150)) {
|
||||
Get.back();
|
||||
finishRideFromDriver1();
|
||||
} else {
|
||||
Get.back();
|
||||
if (distanceToDestination <= 150) {
|
||||
// todo add scam from start point and dont move
|
||||
// finishRideFromDriver1();
|
||||
}
|
||||
MyDialog().getDialog('you are not moved yet !'.tr, '', () {
|
||||
Get.back();
|
||||
});
|
||||
}
|
||||
// if (distanceToDestination > 900 ||
|
||||
// (double.parse(distance.toString()) < 1000 &&
|
||||
// distanceToDestination > 150)) {
|
||||
Get.back();
|
||||
finishRideFromDriver1();
|
||||
// } else {
|
||||
// Get.back();
|
||||
// if (distanceToDestination <= 150) {
|
||||
// // todo add scam from start point and dont move
|
||||
// // finishRideFromDriver1();
|
||||
// }
|
||||
// MyDialog().getDialog('you are not moved yet !'.tr, '', () {
|
||||
// Get.back();
|
||||
// });
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -598,7 +596,7 @@ class MapDriverController extends GetxController {
|
||||
box.write(BoxName.rideStatus, 'Finished');
|
||||
// Get.find<HomeCaptainController>().changeToAppliedRide('Finished');
|
||||
// Get.find<HomeCaptainController>().update();
|
||||
totalCost = price < 30
|
||||
totalCost = price < 20
|
||||
? carType != 'Comfort' && carType != 'Mishwar Vip' && carType != 'Lady'
|
||||
? '20'
|
||||
: '30'
|
||||
@@ -662,7 +660,8 @@ class MapDriverController extends GetxController {
|
||||
}
|
||||
|
||||
double pointsSubtraction = 0;
|
||||
pointsSubtraction = double.parse(paymentAmount) * (-1);
|
||||
pointsSubtraction =
|
||||
double.parse(paymentAmount) * (-1) * .08; //for 300 from 3000
|
||||
var paymentToken2 =
|
||||
await generateTokenDriver((pointsSubtraction).toStringAsFixed(0));
|
||||
var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'dart:math' as math;
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../print.dart';
|
||||
import '../../functions/audio_controller.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
@@ -15,7 +17,7 @@ import 'home_captain_controller.dart';
|
||||
class OrderRequestController extends GetxController {
|
||||
double progress = 0;
|
||||
double progressSpeed = 0;
|
||||
int duration = 11;
|
||||
int duration = 15;
|
||||
int durationSpeed = 20;
|
||||
int remainingTime = 0;
|
||||
int remainingTimeSpeed = 0;
|
||||
@@ -30,12 +32,17 @@ class OrderRequestController extends GetxController {
|
||||
late int minutes;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
Future<void> onInit() async {
|
||||
// AudioController audioController = Get.put(AudioController());
|
||||
|
||||
print('onInit called');
|
||||
await initilizeOrderPage();
|
||||
bool isOverlayActive = await FlutterOverlayWindow.isActive();
|
||||
if (isOverlayActive) {
|
||||
await FlutterOverlayWindow.closeOverlay();
|
||||
}
|
||||
// audioController.playAudio();
|
||||
// getRefusedOrderByCaptain();
|
||||
initilizeOrderPage();
|
||||
|
||||
addCustomStartIcon();
|
||||
addCustomEndIcon();
|
||||
|
||||
@@ -51,34 +58,41 @@ class OrderRequestController extends GetxController {
|
||||
late double lngPassengerLocation;
|
||||
late double lngPassengerDestination;
|
||||
late double latPassengerDestination;
|
||||
initilizeOrderPage() {
|
||||
final myListString = arguments['myListString'];
|
||||
// final myList = arguments['DriverList'];
|
||||
if (arguments['DriverList'] == null || arguments['DriverList'].isEmpty) {
|
||||
|
||||
Future<void> initilizeOrderPage() async {
|
||||
final myListString = Get.arguments['myListString'];
|
||||
|
||||
if (Get.arguments['DriverList'] == null ||
|
||||
Get.arguments['DriverList'].isEmpty) {
|
||||
myList = jsonDecode(myListString);
|
||||
Log.print('myList: ${myList}');
|
||||
} else {
|
||||
myList = arguments['DriverList'];
|
||||
myList = Get.arguments['DriverList'];
|
||||
Log.print('myList1: ${myList}');
|
||||
}
|
||||
|
||||
body = arguments['body'];
|
||||
Duration durationToAdd = Duration(seconds: int.parse(myList[4]));
|
||||
body = Get.arguments['body'];
|
||||
Duration durationToAdd =
|
||||
Duration(seconds: (double.tryParse(myList[4]) ?? 0).toInt());
|
||||
hours = durationToAdd.inHours;
|
||||
minutes = (durationToAdd.inMinutes % 60).round();
|
||||
startTimerSpeed(myList[6].toString(), body.toString());
|
||||
var coords = myList[0].split(',');
|
||||
var coordDestination = myList[1].split(',');
|
||||
|
||||
// Parse to double
|
||||
latPassengerLocation = double.parse(coords[0]);
|
||||
lngPassengerLocation = double.parse(coords[1]);
|
||||
latPassengerDestination = double.parse(coordDestination[0]);
|
||||
lngPassengerDestination = double.parse(coordDestination[1]);
|
||||
// Instead of splitting, directly use the values from the list
|
||||
// First coordinate pair is at index 0 and 1
|
||||
latPassengerLocation = double.tryParse(myList[0]) ?? 0.0;
|
||||
lngPassengerLocation = double.tryParse(myList[1]) ?? 0.0;
|
||||
|
||||
// Second coordinate pair is at index 2 and 3
|
||||
latPassengerDestination = double.tryParse(myList[2]) ?? 0.0;
|
||||
lngPassengerDestination = double.tryParse(myList[3]) ?? 0.0;
|
||||
|
||||
pointsDirection = [
|
||||
LatLng(latPassengerLocation, lngPassengerLocation),
|
||||
LatLng(latPassengerDestination, lngPassengerDestination)
|
||||
]; // Calculate the midpoint between the two points
|
||||
// Calculate the minimum and maximum latitude and longitude values
|
||||
];
|
||||
|
||||
// Calculate bounds
|
||||
double minLatitude =
|
||||
math.min(pointsDirection[0].latitude, pointsDirection[1].latitude);
|
||||
double maxLatitude =
|
||||
@@ -87,17 +101,18 @@ class OrderRequestController extends GetxController {
|
||||
math.min(pointsDirection[0].longitude, pointsDirection[1].longitude);
|
||||
double maxLongitude =
|
||||
math.max(pointsDirection[0].longitude, pointsDirection[1].longitude);
|
||||
// Create a bounding box using the calculated values
|
||||
|
||||
bounds = LatLngBounds(
|
||||
southwest: LatLng(minLatitude, minLongitude),
|
||||
northeast: LatLng(maxLatitude, maxLongitude),
|
||||
);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
getRideDEtailsForBackgroundOrder() async {
|
||||
getRideDEtailsForBackgroundOrder(String rideId) async {
|
||||
await CRUD().get(link: AppLink.getRidesDetails, payload: {
|
||||
'id': box.read(BoxName.myList)[2].toString(),
|
||||
'id': rideId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,20 +208,14 @@ class OrderRequestController extends GetxController {
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
CRUD().post(
|
||||
link: '${AppLink.seferAlexandriaServer}/rides/update.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
// 'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
CRUD().post(link: '${AppLink.seferGizaServer}/rides/update.php', payload: {
|
||||
'id': orderID,
|
||||
// 'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: '${AppLink.endPoint}/rides/update.php', payload: {
|
||||
'id': orderID,
|
||||
// 'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
}
|
||||
|
||||
// applied = true;
|
||||
// if (box.read(BoxName.gender).toString() != 'Female') {
|
||||
@@ -252,41 +261,24 @@ class OrderRequestController extends GetxController {
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
'${AppLink.seferAlexandriaServer}/notificationCaptain/addWaitingRide.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
'price_for_passenger': priceForPassenger,
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
'${AppLink.seferGizaServer}/notificationCaptain/addWaitingRide.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
'price_for_passenger': priceForPassenger,
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(
|
||||
link: '${AppLink.endPoint}/notificationCaptain/addWaitingRide.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
'price_for_passenger': priceForPassenger,
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user