import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:mc_common_app/models/general_models/post_params_model.dart'; import 'package:mc_common_app/models/subscriptions_models/provider_subscription_model.dart'; import 'package:mc_common_app/models/subscriptions_models/subscription_model.dart'; import 'package:mc_common_app/models/user_models/user.dart'; import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; class AppState { static final AppState _instance = AppState._internal(); AppState._internal(); factory AppState() => _instance; bool isLogged = false; set setLogged(v) => isLogged = v; bool? get getIsLogged => isLogged; String? _deviceToken; String? get getDeviceToken => _deviceToken; set setDeviceToken(String value) { _deviceToken = value; } String? _deviceType; String? get getDeviceType => _deviceType; set setDeviceType(String value) { _deviceType = value; } bool isArabic(BuildContext context) => Localizations.localeOf(context).languageCode == 'ar'; AppType currentAppType = AppType.provider; UserType userType = UserType.customer; void setAppType(AppType appType) { currentAppType = appType; } User? _user; set setUser(v) => _user = v; User get getUser => _user ?? User(); PostParamsModel? _postParams; PostParamsModel? get postParamsObject => _postParams; Map get postParamsJson => _postParams?.toJson() ?? {}; void setPostParamsModel(PostParamsModel _postParams) { this._postParams = _postParams; } LatLng currentLocation = const LatLng(0, 0); set setCurrentLocation(v) => currentLocation = v; LatLng get getCurrentLocation => currentLocation; List? _providerSubscription; List get getproviderSubscription => _providerSubscription ?? [Subscription(name: "")]; set setproviderSubscription(List? value) { _providerSubscription = value; } // A notification tapped before login completed (cold start, expired session) -- // stashed by FirebaseMessagingService so it can be resumed once login finishes. // Must be cleared on logout, same as setUser/setproviderSubscription below -- otherwise // a pending notification from the previous session could fire for the next user who // logs in on this device. Map? _pendingNotificationData; Map? get getPendingNotificationData => _pendingNotificationData; set setPendingNotificationData(Map? value) { _pendingNotificationData = value; } // getproviderSubscription falls back to a dummy Subscription(name: "") when there's no // real data, so adsRemaining != null is the signal that this is actual subscription data, // not the placeholder. // Ads-specific on purpose: only checks adsRemaining, not branchesRemaining/subUsersRemaining. // Don't reuse this for branch/user-limit checks -- add a separate getter for those instead. bool get hasAdsRemainingInActiveSubscription { final subscription = getproviderSubscription.first; return subscription.adsRemaining != null && subscription.isExpired != true && (subscription.adsRemaining ?? 0) > 0; } DropValue? _userRegisterCountrySelection; DropValue get getUserRegisterCountrySelection => _userRegisterCountrySelection!; set setUserRegisterCountrySelection(DropValue value) { _userRegisterCountrySelection = value; } bool _isViewOnly = false; bool get getIsViewOnly => _isViewOnly; set setIsViewOnly(bool value) { _isViewOnly = value; } }