This commit is contained in:
Hamza-Ayed
2023-08-21 23:34:15 +03:00
parent b340316e11
commit c1869d2725
18 changed files with 418 additions and 116 deletions

View File

@@ -9,9 +9,7 @@ import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/credential.dart';
import 'package:ride/constant/links.dart';
import 'package:ride/controller/functions/crud.dart';
import 'package:ride/views/home/map_widget.dart/buttom_sheet_map_show.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import 'package:http/http.dart' as http;
import '../../main.dart';
import '../../models/model/locations.dart';
import '../firebase/firbase_messge.dart';
@@ -46,7 +44,7 @@ class MapController extends GetxController {
bool isCashConfirmPageShown = false;
bool isPaymentMethodPageShown = false;
bool isMainBottomMenuMap = true;
double heightButtomSheetShown = 300;
double heightButtomSheetShown = 0;
double cashConfirmPageShown = 250;
double paymentPageShown = Get.height * .6;
late final LatLng southwest;
@@ -98,14 +96,32 @@ class MapController extends GetxController {
}
int selectedReason = -1;
void selectReason(int index) {
String? cancelNote;
void selectReason(int index, String note) {
selectedReason = index;
cancelNote = note;
update();
}
bool rideConfirm = false;
void cancelRide() async {
changeConfirmRide() {
rideConfirm = true;
//TODO add ride and get ride id and details
update();
}
Future cancelRide() async {
var payload = {
"driverID": "1", // Convert to String
"passengerID":
box.read(BoxName.pasengerID).toString(), // Convert to String
"rideID": "222", // Convert to String
"note": cancelNote
};
print(rideConfirm);
print(payload);
if (rideConfirm == false) {
clearPlaces();
clearpolyline();
@@ -117,12 +133,9 @@ class MapController extends GetxController {
clearpolyline();
data = [];
changeCancelRidePageShow();
await CRUD().post(link: AppLink.addCancelRide, payload: {
"driverID": 1,
"passengerID": box.read(BoxName.pasengerID).toString(),
"rideID": 222,
"note": "zxcz"
});
await CRUD().post(link: AppLink.addCancelRide, payload: payload);
update();
}
}
@@ -385,19 +398,25 @@ class MapController extends GetxController {
late double costDuration = 0;
late double cost = 0;
late double distance = 0;
late double duration = 2;
late double duration = 0;
DateTime currentTime = DateTime.now();
late Duration durationToAdd;
late DateTime newTime = DateTime.now();
void bottomSheet() {
Future bottomSheet() async {
if (data.isNotEmpty) {
String distanceText = data[0]['distance']['text'];
String durationText = data[0]['duration']['text'];
String distanceText = await data[0]['distance']['text'];
String durationText = await data[0]['duration']['text'];
distance = getDistanceFromText(distanceText);
duration = getDistanceFromText(durationText);
durationToAdd = Duration(minutes: duration.toInt());
DateTime currentTime = DateTime.now();
newTime = currentTime.add(durationToAdd);
averageDuration = duration / distance;
costDuration = duration * averageDuration * 0.016;
totalDriver = cost + costDuration;
totalPassenger = totalDriver + (totalDriver * .16);
tax = totalPassenger * .04;
totaME = totalPassenger - totalDriver - tax;
update();
if (currentTime.hour >= 21) {
if (distanceText.contains('km')) {
@@ -407,6 +426,32 @@ class MapController extends GetxController {
cost = distance * 0.23 / 1000;
update();
}
} else if (currentTime.hour < 5) {
if (distanceText.contains('km')) {
cost = distance * 0.25;
update();
} else {
cost = distance * 0.25 / 1000;
update();
}
} else if (currentTime.hour >= 13 && currentTime.hour <= 16) {
if (averageDuration > 2.5) {
if (distanceText.contains('km')) {
cost = distance * 0.23;
update();
} else {
cost = distance * 0.25 / 1000;
update();
}
} else {
if (distanceText.contains('km')) {
cost = distance * 0.21;
update();
} else {
cost = distance * 0.21 / 1000;
update();
}
}
} else {
if (distanceText.contains('km')) {
cost = distance * 0.21;
@@ -416,12 +461,7 @@ class MapController extends GetxController {
update();
}
}
averageDuration = duration / distance;
costDuration = duration * averageDuration * 0.016;
totalDriver = cost + costDuration;
totalPassenger = totalDriver + (totalDriver * .16);
tax = totalPassenger * .04;
totaME = totalPassenger - totalDriver - tax;
if (totalPassenger < 1) {
totalPassenger = 1;
update();
@@ -435,8 +475,11 @@ class MapController extends GetxController {
update();
}
}
// buttomSheetMapPage();
changeButtomSheetShown();
}
buttomSheetMapPage();
// Get.bottomSheet(
// Container(
// height: 130,