This commit is contained in:
Hamza-Ayed
2023-10-01 21:54:03 +03:00
parent 5ca5d91cc9
commit 0368a141d7
13 changed files with 216 additions and 39 deletions

View File

@@ -0,0 +1,56 @@
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
import 'package:ride/constant/colors.dart';
import '../../../constant/credential.dart';
import '../../../constant/links.dart';
import '../../functions/crud.dart';
class MapDirction extends GetxController {
bool isLoading = true;
List data = [];
LatLngBounds? boundsdata;
final List<LatLng> polylineCoordinates = [];
List<Polyline> polyLines = [];
getMap(LatLng origin, destination) async {
isLoading = false;
update();
var url =
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AppCredintials.mapAPIKEY}');
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
print(data);
final points =
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
for (int i = 0; i < points.length; i++) {
double lat = points[i][0].toDouble();
double lng = points[i][1].toDouble();
polylineCoordinates.add(LatLng(lat, lng));
}
if (polyLines.isNotEmpty) {
// clearPolyline();
} else {
var polyline = Polyline(
polylineId: PolylineId(response["routes"][0]["summary"]),
points: polylineCoordinates,
width: 10,
color: AppColor.blueColor,
);
// polyLines.add(polyline);
// rideConfirm = false;
update();
}
}
@override
void onInit() {
super.onInit();
}
}

View File

@@ -12,6 +12,7 @@ import 'package:ride/constant/links.dart';
import 'package:ride/controller/firebase/firbase_messge.dart';
import 'package:ride/controller/functions/crud.dart';
import 'package:ride/controller/functions/secure_storage.dart';
import 'package:ride/controller/payment/payment_controller.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import '../../main.dart';
import '../../models/model/locations.dart';
@@ -49,10 +50,12 @@ class MapController extends GetxController {
bool isCancelRidePageShown = false;
bool isCashConfirmPageShown = false;
bool isPaymentMethodPageShown = false;
bool isPassengerInfoWindow = false;
bool rideConfirm = false;
bool isMainBottomMenuMap = true;
double heightBottomSheetShown = 0;
double cashConfirmPageShown = 250;
double passengerInfoWindow = 250;
double widthMapTypeAndTraffic = 50;
double paymentPageShown = Get.height * .6;
late LatLng southwest;
@@ -89,6 +92,12 @@ class MapController extends GetxController {
update();
}
void changePassengerInfoWindow() {
isPassengerInfoWindow = !isPassengerInfoWindow;
passengerInfoWindow = isPassengerInfoWindow == true ? 200 : 0;
update();
}
void changePaymentMethodPageShown() {
isPaymentMethodPageShown = !isPaymentMethodPageShown;
paymentPageShown = isPaymentMethodPageShown == true ? Get.height * .6 : 0;
@@ -161,8 +170,10 @@ class MapController extends GetxController {
var rideId;
int carsOrder = 0;
changeConfirmRide() async {
PaymentController paymentController = Get.find<PaymentController>();
rideConfirm = true;
shouldFetch = true;
isBottomSheetShown = false;
timeToPassengerFromDriverAfterApplied = 60;
update();
// print('rideConfirm= $rideConfirm');
@@ -203,6 +214,7 @@ class MapController extends GetxController {
box.read(BoxName.phone).toString(),
durationByPassenger.toString(),
distanceByPassenger.toString(),
paymentController.isWalletChecked.toString() //todo if it is work
];
FirebasMessagesController().sendNotificationToDriverMAP(
'Order',
@@ -255,6 +267,7 @@ class MapController extends GetxController {
remainingTime = durationTimer - i;
if (remainingTime == 0) {
rideConfirm = false;
// print(timeToPassengerFromDriverAfterApplied);
timeToPassengerFromDriverAfterApplied += duration1;
// print(duration1);