This commit is contained in:
Hamza-Ayed
2024-03-21 02:09:52 +03:00
parent ad062d9ad7
commit 045f7e20f0
46 changed files with 2767 additions and 877 deletions

View File

@@ -12,8 +12,11 @@ import '../../functions/location_controller.dart';
class OrderRequestController extends GetxController {
double progress = 0;
int duration = 20;
double progressSpeed = 0;
int duration = 10;
int durationSpeed = 20;
int remainingTime = 0;
int remainingTimeSpeed = 0;
String countRefuse = '0';
bool applied = false;
final locationController = Get.put(LocationController());
@@ -81,19 +84,43 @@ class OrderRequestController extends GetxController {
if (applied == false) {
print('applied=========================');
print(applied);
refuseOrder(driverID, orderID);
refuseOrder(orderID);
}
}
}
void refuseOrder(String driverID, orderID) async {
void startTimerSpeed(String driverID, orderID) async {
for (int i = 0; i <= durationSpeed; i++) {
await Future.delayed(const Duration(seconds: 1));
progressSpeed = i / durationSpeed;
remainingTimeSpeed = durationSpeed - i;
update();
}
if (remainingTimeSpeed == 0) {
if (applied == false) {
print('applied=========================');
print(applied);
Get.back();
// refuseOrder(box.read(BoxName.driverID), orderID);
}
}
}
void refuseOrder(orderID) async {
await CRUD().postFromDialogue(link: AppLink.addDriverOrder, payload: {
//TODO need review
'driver_id': box.read(BoxName.driverID).toString(),
'driver_id': box.read(BoxName.driverID),
// box.read(BoxName.driverID).toString(),
'order_id': orderID,
'status': 'Refused'
});
await CRUD().post(link: AppLink.updateRides, payload: {
'id': orderID,
'rideTimeStart': DateTime.now().toString(),
'status': 'Refused',
'driver_id': box.read(BoxName.driverID),
});
Get.back();
// applied = true;
sql.insertData({