10/14/1
This commit is contained in:
@@ -13,7 +13,6 @@ import 'package:ride/views/Rate/rate_passenger.dart';
|
||||
|
||||
import '../../../constant/credential.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../views/home/Captin/home_captin.dart';
|
||||
import '../../functions/crud.dart';
|
||||
|
||||
class MapDriverController extends GetxController {
|
||||
@@ -36,6 +35,7 @@ class MapDriverController extends GetxController {
|
||||
late String durationToPassenger;
|
||||
late String walletChecked;
|
||||
late String direction;
|
||||
late String status;
|
||||
bool isPassengerInfoWindow = false;
|
||||
bool isBtnRideBegin = false;
|
||||
bool isRideFinished = false;
|
||||
@@ -51,22 +51,39 @@ class MapDriverController extends GetxController {
|
||||
GoogleMapController? mapController;
|
||||
late LatLng myLocation;
|
||||
|
||||
late Timer timer;
|
||||
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
LocationController locationController = Get.find<LocationController>();
|
||||
myLocation = locationController.myLocation;
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(myLocation),
|
||||
CameraUpdate.newLatLngZoom(myLocation, 10),
|
||||
);
|
||||
update();
|
||||
|
||||
// Set up a timer or interval to trigger the marker update every 3 seconds.
|
||||
Timer.periodic(const Duration(seconds: 3), (_) {
|
||||
timer = Timer.periodic(const Duration(seconds: 3), (_) {
|
||||
updateMarker();
|
||||
});
|
||||
}
|
||||
|
||||
void changeStatusDriver() {
|
||||
status = 'On';
|
||||
update();
|
||||
}
|
||||
|
||||
takeSnapMap() {
|
||||
mapController!.takeSnapshot();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
mapController!.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void checkIsDriverNearPassenger() async {
|
||||
if (isDriverNearPassengerStart) {
|
||||
Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||
@@ -78,17 +95,6 @@ class MapDriverController extends GetxController {
|
||||
// Replace "passengerLat" and "passengerLng" with the actual passenger's location
|
||||
String passengerLat = passengerLocation; // Set the passenger's latitude
|
||||
String passengerLng = ""; // Set the passenger's longitude
|
||||
|
||||
// double distance = calculateDistance(
|
||||
// double.parse(driverLat),
|
||||
// double.parse(driverLng),
|
||||
// double.parse(passengerLat),
|
||||
// double.parse(passengerLng),
|
||||
// );
|
||||
|
||||
// if (distance < 50) {
|
||||
// print("Distance to passenger: $distance meters");
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -166,6 +172,7 @@ class MapDriverController extends GetxController {
|
||||
isPassengerInfoWindow = false;
|
||||
isRideStarted = true;
|
||||
isRideFinished = false;
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
update();
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': rideId,
|
||||
@@ -179,6 +186,7 @@ class MapDriverController extends GetxController {
|
||||
void finishRideFromDriver() async {
|
||||
isRideFinished = true;
|
||||
isRideStarted = false;
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
// changeRideToBeginToPassenger();
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': rideId,
|
||||
|
||||
Reference in New Issue
Block a user