This commit is contained in:
Hamza-Ayed
2023-09-05 11:24:45 +03:00
parent ef6d3604cd
commit 4380826253
9 changed files with 418 additions and 158 deletions

View File

@@ -26,7 +26,7 @@ class CRUD {
if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
// print(jsonData);
print(jsonData);
return response.body;
}
return jsonData['status'];

View File

@@ -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();
}
});
}

View File

@@ -3,11 +3,13 @@ import 'package:get/get.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
import '../firebase/firbase_messge.dart';
import '../themes/themes.dart';
class LocaleController extends GetxController {
Locale? language;
void restartApp() {
runApp(const MyApp());
}
ThemeData appTheme = themeEnglish;
@@ -35,6 +37,7 @@ class LocaleController extends GetxController {
box.write(BoxName.lang, langcode);
Get.changeTheme(appTheme);
Get.updateLocale(locale);
restartApp();
update();
}

View File

@@ -26,8 +26,7 @@ class PaymentController extends GetxController {
box.write(BoxName.passengerWalletFound, isWalletFound);
// totalPassengerWalletDetails = box.read(BoxName.passengerWalletDetails);
if (totalPassengerWalletDetails == null ||
totalPassengerWalletDetails.isEmpty) {
if (totalPassengerWalletDetails.isEmpty) {
await CRUD().get(link: AppLink.getWalletByPassenger, payload: {
'passenger_id': box.read(BoxName.pasengerID)
}).then((value) {
@@ -75,9 +74,8 @@ class PaymentController extends GetxController {
}
@override
void onInit() async {
await getPassengerWallet();
void onInit() {
getPassengerWallet();
super.onInit();
}
}