Update: 2026-06-14 05:48:58
This commit is contained in:
@@ -21,6 +21,7 @@ import '../../../../controller/home/navigation/navigation_view.dart';
|
||||
import '../../../../controller/profile/setting_controller.dart';
|
||||
import '../../../../env/env.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../../print.dart';
|
||||
import '../../../notification/available_rides_page.dart';
|
||||
import '../driver_map_page.dart';
|
||||
import 'widget/connect.dart';
|
||||
@@ -603,11 +604,13 @@ class _FloatingControls extends StatelessWidget {
|
||||
),
|
||||
// Continue active ride
|
||||
if (box.read(BoxName.rideStatus) == 'Applied' ||
|
||||
box.read(BoxName.rideStatus) == 'Apply' ||
|
||||
box.read(BoxName.rideStatus) == 'Begin') ...[
|
||||
const SizedBox(height: 10),
|
||||
_Fab(
|
||||
onTap: () {
|
||||
if (box.read(BoxName.rideStatus) == 'Applied') {
|
||||
final status = box.read(BoxName.rideStatus);
|
||||
if (status == 'Applied' || status == 'Apply') {
|
||||
Get.to(() => PassengerLocationMapPage(),
|
||||
arguments: box.read(BoxName.rideArguments));
|
||||
Get.put(MapDriverController())
|
||||
@@ -669,5 +672,27 @@ class _Fab extends StatelessWidget {
|
||||
// Helper
|
||||
// ─────────────────────────────────────────────
|
||||
Future<void> checkForAppliedRide(BuildContext context) async {
|
||||
checkForPendingOrderFromServer();
|
||||
if (Get.currentRoute == '/passenger-location-map') return;
|
||||
|
||||
final localStatus = box.read(BoxName.rideStatus);
|
||||
final localArgs = box.read(BoxName.rideArguments) ??
|
||||
box.read(BoxName.rideArgumentsFromBackground);
|
||||
|
||||
if ((localStatus == 'Apply' ||
|
||||
localStatus == 'Applied' ||
|
||||
localStatus == 'Begin') &&
|
||||
localArgs != null &&
|
||||
localArgs != 'failure') {
|
||||
Log.print("🔄 Auto-recovering active ride: status=$localStatus");
|
||||
if (localStatus == 'Apply' || localStatus == 'Applied') {
|
||||
Get.to(() => PassengerLocationMapPage(), arguments: localArgs);
|
||||
Get.put(MapDriverController()).changeRideToBeginToPassenger();
|
||||
} else if (localStatus == 'Begin') {
|
||||
Get.to(() => PassengerLocationMapPage(), arguments: localArgs);
|
||||
Get.put(MapDriverController()).startRideFromStartApp();
|
||||
}
|
||||
} else {
|
||||
// If no local active ride, check the server
|
||||
await checkForPendingOrderFromServer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,14 +219,16 @@ class _Divider extends StatelessWidget {
|
||||
// Server Helpers (unchanged logic)
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
bool _isCheckingPendingOrder = false;
|
||||
|
||||
Future<void> checkForPendingOrderFromServer() async {
|
||||
bool isProcessing = false;
|
||||
if (isProcessing) return;
|
||||
if (_isCheckingPendingOrder) return;
|
||||
if (Get.currentRoute == '/passenger-location-map') return;
|
||||
|
||||
final driverId = box.read(BoxName.driverID)?.toString();
|
||||
if (driverId == null) return;
|
||||
|
||||
isProcessing = true;
|
||||
_isCheckingPendingOrder = true;
|
||||
|
||||
try {
|
||||
var response = await CRUD().post(
|
||||
@@ -258,7 +260,7 @@ Future<void> checkForPendingOrderFromServer() async {
|
||||
} catch (_) {
|
||||
// silent
|
||||
} finally {
|
||||
isProcessing = false;
|
||||
_isCheckingPendingOrder = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user