Update: 2026-06-23 17:57:07
This commit is contained in:
@@ -58,6 +58,7 @@ import 'package:flutter_confetti/flutter_confetti.dart' hide Circle;
|
|||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
|
|
||||||
class RideLifecycleController extends GetxController {
|
class RideLifecycleController extends GetxController {
|
||||||
|
bool isDataInitializedAfterLogin = false;
|
||||||
// --- Missing variables from monolithic controller ---
|
// --- Missing variables from monolithic controller ---
|
||||||
String currentRideId = '';
|
String currentRideId = '';
|
||||||
bool isDrawingRoute = false;
|
bool isDrawingRoute = false;
|
||||||
@@ -4049,10 +4050,32 @@ class RideLifecycleController extends GetxController {
|
|||||||
await _checkAndRefreshMapStyle();
|
await _checkAndRefreshMapStyle();
|
||||||
Get.put(DeepLinkController(), permanent: true);
|
Get.put(DeepLinkController(), permanent: true);
|
||||||
await initilizeGetStorage();
|
await initilizeGetStorage();
|
||||||
|
|
||||||
|
final bool isLoggedIn = box.read(BoxName.isVerified) == '1' &&
|
||||||
|
box.read(BoxName.passengerID) != null;
|
||||||
|
|
||||||
|
if (isLoggedIn) {
|
||||||
|
isDataInitializedAfterLogin = true;
|
||||||
getLocationArea(passengerLocation.latitude, passengerLocation.longitude);
|
getLocationArea(passengerLocation.latitude, passengerLocation.longitude);
|
||||||
unawaited(_stagePricingAndState());
|
unawaited(_stagePricingAndState());
|
||||||
unawaited(_stageNiceToHave());
|
unawaited(_stageNiceToHave());
|
||||||
startMasterTimer();
|
startMasterTimer();
|
||||||
|
} else {
|
||||||
|
Log.print("RideLifecycleController.onInit: User not logged in, skipping startup API calls.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> initializeDataAfterLogin() async {
|
||||||
|
if (isDataInitializedAfterLogin) {
|
||||||
|
Log.print("RideLifecycleController: Already initialized, skipping duplicate initializeDataAfterLogin.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isDataInitializedAfterLogin = true;
|
||||||
|
Log.print("RideLifecycleController: Initializing data after successful login...");
|
||||||
|
getLocationArea(passengerLocation.latitude, passengerLocation.longitude);
|
||||||
|
await _stagePricingAndState();
|
||||||
|
await _stageNiceToHave();
|
||||||
|
startMasterTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -39,10 +39,18 @@ class MapPagePassenger extends StatelessWidget {
|
|||||||
Get.find<MapEngineController>();
|
Get.find<MapEngineController>();
|
||||||
Get.find<LocationSearchController>();
|
Get.find<LocationSearchController>();
|
||||||
Get.find<NearbyDriversController>();
|
Get.find<NearbyDriversController>();
|
||||||
Get.find<RideLifecycleController>();
|
final rideLifecycle = Get.find<RideLifecycleController>();
|
||||||
Get.find<UiInteractionsController>();
|
Get.find<UiInteractionsController>();
|
||||||
Get.find<MyMenuController>();
|
Get.find<MyMenuController>();
|
||||||
Get.find<CRUD>();
|
Get.find<CRUD>();
|
||||||
|
|
||||||
|
// ✅ تهيئة البيانات بعد تسجيل الدخول إن لم تكن قد تهيأت بالفعل
|
||||||
|
final bool isLoggedIn = box.read(BoxName.isVerified) == '1' &&
|
||||||
|
box.read(BoxName.passengerID) != null;
|
||||||
|
if (isLoggedIn && !rideLifecycle.isDataInitializedAfterLogin) {
|
||||||
|
rideLifecycle.initializeDataAfterLogin();
|
||||||
|
}
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
checkForUpdate(context);
|
checkForUpdate(context);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ class _SnackContentState extends State<_SnackContent>
|
|||||||
// ─────────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
SnackbarController? _show(_SnackVariant variant, String message) {
|
SnackbarController? _show(_SnackVariant variant, String message) {
|
||||||
// Prevent crash if Navigator or Overlay context is not yet initialized at early startup
|
// Prevent crash if Navigator or Overlay context is not yet initialized at early startup
|
||||||
if (Get.context == null || Get.overlayContext == null) {
|
if (Get.context == null || Get.overlayContext == null || Get.key.currentState?.overlay == null) {
|
||||||
debugPrint("⚠️ Cannot show snackbar: Overlay/Navigator is not ready yet. Message: $message");
|
debugPrint("⚠️ Cannot show snackbar: Overlay/Navigator is not ready yet. Message: $message");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user