9/5/1
This commit is contained in:
@@ -6,12 +6,15 @@ 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:location/location.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/credential.dart';
|
||||
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/functions/toast.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
import '../../main.dart';
|
||||
import '../../models/model/locations.dart';
|
||||
@@ -36,6 +39,7 @@ class MapController extends GetxController {
|
||||
final location = Location();
|
||||
late LocationData currentLocation;
|
||||
double heightMenu = 0;
|
||||
double widthMenu = 0;
|
||||
double heightPickerContainer = 90;
|
||||
double mainBottomMenuMap = Get.height * .2;
|
||||
bool heightMenuBool = false;
|
||||
@@ -99,6 +103,7 @@ class MapController extends GetxController {
|
||||
void getDrawerMenu() {
|
||||
heightMenuBool = !heightMenuBool;
|
||||
heightMenu = heightMenuBool == true ? 100 : 0;
|
||||
widthMenu = heightMenuBool == true ? 110 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -197,6 +202,9 @@ class MapController extends GetxController {
|
||||
isMainBottomMenuMap = !isMainBottomMenuMap;
|
||||
mainBottomMenuMap =
|
||||
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .66;
|
||||
if (heightMenuBool == true) {
|
||||
getDrawerMenu();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -430,7 +438,7 @@ class MapController extends GetxController {
|
||||
|
||||
String duratioByPassenger = '';
|
||||
void getNearestDriverByPassengerLocation() async {
|
||||
if (polylines.isEmpty) {
|
||||
if (polylines.isEmpty || data.isEmpty) {
|
||||
double nearestDistance = double.infinity;
|
||||
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
@@ -536,16 +544,18 @@ class MapController extends GetxController {
|
||||
getDistanceFromText(data[0]['distance']['text']);
|
||||
|
||||
// Animate the camera to the adjusted bounds
|
||||
if (distanceOfDestnation <= 10) {
|
||||
if (distanceOfDestnation <= 5) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 14));
|
||||
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 13));
|
||||
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 12));
|
||||
} else if (distanceOfDestnation > 10 && distanceOfDestnation < 16) {
|
||||
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11));
|
||||
} else if (distanceOfDestnation > 16 && distanceOfDestnation < 30) {
|
||||
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10));
|
||||
} else if (distanceOfDestnation > 30 && distanceOfDestnation < 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 8));
|
||||
} else if (distanceOfDestnation > 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 6));
|
||||
} else if (distanceOfDestnation >= 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 7));
|
||||
}
|
||||
if (polylines.isNotEmpty) {
|
||||
clearpolyline();
|
||||
@@ -579,6 +589,17 @@ class MapController extends GetxController {
|
||||
CRUD().get(link: AppLink.getPassengersPromo, payload: {
|
||||
'promo_code': promo.text,
|
||||
}).then((value) {
|
||||
if (value == 'failure') {
|
||||
Get.defaultDialog(
|
||||
title: 'Promo End !'.tr,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back',
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
},
|
||||
));
|
||||
}
|
||||
var decod = jsonDecode(value);
|
||||
|
||||
if (decod["status"] == "success") {
|
||||
@@ -589,6 +610,7 @@ class MapController extends GetxController {
|
||||
promoTaken = true;
|
||||
update();
|
||||
print(totalPassenger);
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user