This commit is contained in:
Hamza-Ayed
2024-07-06 19:24:10 +03:00
21 changed files with 262 additions and 275 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
import 'package:SEFER/views/widgets/mydialoug.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
@@ -221,6 +222,7 @@ class MapDriverController extends GetxController {
'driverGoToPassengerTime': DateTime.now().toString(),
'status': 'Applied'
});
box.write(BoxName.rideStatus, 'Applied');
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'DriverIsGoingToPassenger',
box.read(BoxName.name).toString(),
@@ -282,6 +284,7 @@ class MapDriverController extends GetxController {
remainingTimeInPassengerLocatioWait = 0;
timeWaitingPassenger = 0;
box.write(BoxName.statusDriverLocation, 'on');
box.write(BoxName.rideStatus, 'Begin'); //todo ride details
update();
await CRUD().post(link: AppLink.updateRides, payload: {
@@ -426,6 +429,12 @@ class MapDriverController extends GetxController {
}
void finishRideFromDriver() {
double distanceToDestination = Geolocator.distanceBetween(
latLngPassengerLocation.latitude,
latLngPassengerLocation.longitude,
Get.find<LocationController>().myLocation.latitude,
Get.find<LocationController>().myLocation.longitude,
);
Get.defaultDialog(
title: 'Are you sure to exit ride ?'.tr,
titleStyle: AppStyle.title,
@@ -434,8 +443,16 @@ class MapDriverController extends GetxController {
title: 'Ok'.tr,
kolor: AppColor.greenColor,
onPressed: () {
Get.back();
finishRideFromDriver1();
if (distanceToDestination > 1000) {
Get.back();
finishRideFromDriver1();
} else {
Get.back();
if (distanceToDestination < 150) {
// todo add scam from start point and dont move
}
MyDialog().getDialog('you are not moved yet !'.tr, '', () {});
}
}),
cancel: MyElevatedButton(
title: 'Cancel'.tr,
@@ -467,17 +484,12 @@ class MapDriverController extends GetxController {
}
void finishRideFromDriver1() async {
double distanceToDestination = Geolocator.distanceBetween(
latLngPassengerDestination.latitude,
latLngPassengerDestination.longitude,
Get.find<LocationController>().myLocation.latitude,
Get.find<LocationController>().myLocation.longitude,
);
// if (carType != 'Comfort' || carType != 'Free Ride') {
// if (distanceToDestination < 50) {
isRideFinished = true;
isRideStarted = false;
isPriceWindow = false;
box.write(BoxName.rideStatus, 'Finished');
totalCost = price < 30
? carType != 'Comfort' && carType != 'Mashwari' && carType != 'Lady'
? '20'
@@ -559,7 +571,6 @@ class MapDriverController extends GetxController {
'walletChecked': walletChecked
});
// Get.back();
// }
}
void cancelCheckRideFromPassenger() async {
@@ -599,7 +610,9 @@ class MapDriverController extends GetxController {
int durationOfRide = int.parse(durationOfRideValue);
update();
int infinity = 40000;
if (carType == 'Comfort' || carType == 'Mashwari') {
if (carType == 'Comfort' ||
carType == 'Mashwari' ||
carType == 'Rayeh Gai') {
durationOfRide = infinity;
update();
}
@@ -637,7 +650,7 @@ class MapDriverController extends GetxController {
remainingTimeTimerRideBegin = durationOfRide - i;
remainingTimeTimerRideBegin < 60 ? driverEndPage = 160 : 100;
updateMarker();
if (remainingTimeTimerRideBegin < 120) {
if (remainingTimeTimerRideBegin < 60) {
// to make driver available on last 2 minute in his trip
box.write(BoxName.statusDriverLocation, 'off');
}

View File

@@ -4,6 +4,7 @@ import 'package:SEFER/controller/auth/captin/login_captin_controller.dart';
import 'package:SEFER/views/home/on_boarding_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
@@ -16,10 +17,23 @@ class SplashScreenController extends GetxController
late Animation<double> zoomInAnimation;
late Animation<double> zoomOutAnimation;
String packageInfo = '';
late String version = '1.5.48';
Future<void> checkForUpdate() async {
final packageInfo = await PackageInfo.fromPlatform();
final currentVersion = packageInfo.buildNumber;
final version1 = packageInfo.version;
print('currentVersion is : $currentVersion');
// Fetch the latest version from your server
version = version1.toString();
print('version: ${version}');
update();
}
@override
void onInit() {
super.onInit();
checkForUpdate();
animationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 4),