diff --git a/lib/controller/functions/location_controller.dart b/lib/controller/functions/location_controller.dart index 4bf7ec7..df57ebd 100644 --- a/lib/controller/functions/location_controller.dart +++ b/lib/controller/functions/location_controller.dart @@ -34,17 +34,17 @@ class LocationController extends GetxController { totalPoints = Get.find().totalPoints; // if (isActive) { - // if (double.parse(totalPoints) > -100) { - print('total point is ll$totalPoints'); - await getLocation(); + if (double.parse(totalPoints) > -100) { + print('total point is ll$totalPoints'); + await getLocation(); - await CRUD().post(link: AppLink.addCarsLocationByPassenger, payload: { - 'driver_id': box.read(BoxName.driverID).toString(), - 'latitude': myLocation.latitude.toString(), - 'longitude': myLocation.longitude.toString(), - 'status': box.read(BoxName.statusDriverLocation).toString() - }); - // } + await CRUD().post(link: AppLink.addCarsLocationByPassenger, payload: { + 'driver_id': box.read(BoxName.driverID).toString(), + 'latitude': myLocation.latitude.toString(), + 'longitude': myLocation.longitude.toString(), + 'status': box.read(BoxName.statusDriverLocation).toString() + }); + } // } } catch (e) { diff --git a/lib/controller/home/captin/home_captain_controller.dart b/lib/controller/home/captin/home_captain_controller.dart index ede12ec..c6de1c4 100644 --- a/lib/controller/home/captin/home_captain_controller.dart +++ b/lib/controller/home/captin/home_captain_controller.dart @@ -49,11 +49,8 @@ class HomeCaptainController extends GetxController { String stringActiveDuration = ''; void onButtonSelected() { - totalPoints = Get.find().totalPoints; - // if (double.parse(totalPoints) > -100) { - // isActive = false; - // update(); - // } else { + // totalPoints = Get.find().totalPoints; + isActive = !isActive; if (isActive) { if (double.parse(totalPoints) > -100) { @@ -64,6 +61,14 @@ class HomeCaptainController extends GetxController { stringActiveDuration = formatDuration(activeDuration); update(); }); + } else { + locationController.stopLocationUpdates(); + + activeStartTime = null; + activeTimer?.cancel(); + savePeriod(activeDuration); + activeDuration = Duration.zero; + update(); } } else { locationController.stopLocationUpdates(); diff --git a/lib/controller/home/payment/captain_wallet_controller.dart b/lib/controller/home/payment/captain_wallet_controller.dart index b48d1b3..7568cd7 100644 --- a/lib/controller/home/payment/captain_wallet_controller.dart +++ b/lib/controller/home/payment/captain_wallet_controller.dart @@ -7,8 +7,6 @@ import 'package:ride/constant/links.dart'; import 'package:ride/controller/functions/crud.dart'; import 'package:ride/main.dart'; -import '../../../views/home/my_wallet/walet_captain.dart'; - class CaptainWalletController extends GetxController { bool isLoading = false; Map walletDate = {}; diff --git a/lib/views/home/my_wallet/walet_captain.dart b/lib/views/home/my_wallet/walet_captain.dart index afebed2..a17256b 100644 --- a/lib/views/home/my_wallet/walet_captain.dart +++ b/lib/views/home/my_wallet/walet_captain.dart @@ -147,6 +147,11 @@ class WaletCaptain extends StatelessWidget { )) ], isleading: true, + action: InkWell( + onTap: () { + captainWalletController.getCaptainWalletFromBuyPoints(); + }, + child: const Icon(Icons.refresh)), ); } }