5/21/1
This commit is contained in:
@@ -10,8 +10,6 @@ import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/home/payment/captain_wallet_controller.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
|
||||
import '../home/captin/map_driver_controller.dart';
|
||||
|
||||
// LocationController.dart
|
||||
class LocationController extends GetxController {
|
||||
LocationData? _currentLocation;
|
||||
@@ -41,6 +39,7 @@ class LocationController extends GetxController {
|
||||
// startLocationUpdates();
|
||||
|
||||
totalPoints = Get.put(CaptainWalletController()).totalPoints;
|
||||
// isActive = Get.put(HomeCaptainController()).isActive;
|
||||
}
|
||||
|
||||
Future<void> startLocationUpdates() async {
|
||||
@@ -49,37 +48,39 @@ class LocationController extends GetxController {
|
||||
Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
try {
|
||||
totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
isActive = Get.find<HomeCaptainController>().isActive;
|
||||
print('isActive $isActive');
|
||||
print(totalPoints);
|
||||
if (isActive) {
|
||||
if (double.parse(totalPoints) > -300) {
|
||||
print('total point is $totalPoints');
|
||||
|
||||
// if (isActive) {
|
||||
if (double.parse(totalPoints) > -300) {
|
||||
print('total point is $totalPoints');
|
||||
await getLocation();
|
||||
|
||||
await getLocation();
|
||||
|
||||
// if (box.read(BoxName.driverID) != null) {
|
||||
await CRUD()
|
||||
.post(link: AppLink.addCarsLocationByPassenger, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'latitude': myLocation.latitude.toString(),
|
||||
'longitude': myLocation.longitude.toString(),
|
||||
'heading': heading.toString(),
|
||||
'speed': (speed * 3.6).toStringAsFixed(1),
|
||||
'distance': totalDistance == 0
|
||||
? '0'
|
||||
: totalDistance < 1
|
||||
? totalDistance.toStringAsFixed(3)
|
||||
: totalDistance.toStringAsFixed(1),
|
||||
'status': box.read(BoxName.statusDriverLocation).toString()
|
||||
});
|
||||
// Animate camera to user location (optional)
|
||||
// if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// Get.find<MapDriverController>()
|
||||
// .mapController!
|
||||
// .animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
// Get.find<LocationController>().myLocation.latitude,
|
||||
// Get.find<LocationController>().myLocation.longitude,
|
||||
// )));
|
||||
// }
|
||||
// if (box.read(BoxName.driverID) != null) {
|
||||
await CRUD()
|
||||
.post(link: AppLink.addCarsLocationByPassenger, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'latitude': myLocation.latitude.toString(),
|
||||
'longitude': myLocation.longitude.toString(),
|
||||
'heading': heading.toString(),
|
||||
'speed': (speed * 3.6).toStringAsFixed(1),
|
||||
'distance': totalDistance == 0
|
||||
? '0'
|
||||
: totalDistance < 1
|
||||
? totalDistance.toStringAsFixed(3)
|
||||
: totalDistance.toStringAsFixed(1),
|
||||
'status': box.read(BoxName.statusDriverLocation).toString()
|
||||
});
|
||||
// Animate camera to user location (optional)
|
||||
// if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// Get.find<MapDriverController>()
|
||||
// .mapController!
|
||||
// .animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
// Get.find<LocationController>().myLocation.latitude,
|
||||
// Get.find<LocationController>().myLocation.longitude,
|
||||
// )));
|
||||
}
|
||||
Get.find<HomeCaptainController>()
|
||||
.mapHomeCaptainController!
|
||||
.animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
|
||||
Reference in New Issue
Block a user