74 lines
1.5 KiB
Dart
74 lines
1.5 KiB
Dart
import "package:flutter/foundation.dart";
|
|
|
|
class AppState extends ChangeNotifier {
|
|
int? _selectedBusinessId;
|
|
int? _selectedServicePointId;
|
|
|
|
int? _userId;
|
|
|
|
int? _cartOrderId;
|
|
String? _cartOrderUuid;
|
|
|
|
int? get selectedBusinessId => _selectedBusinessId;
|
|
int? get selectedServicePointId => _selectedServicePointId;
|
|
|
|
int? get userId => _userId;
|
|
bool get isLoggedIn => _userId != null && _userId! > 0;
|
|
|
|
int? get cartOrderId => _cartOrderId;
|
|
String? get cartOrderUuid => _cartOrderUuid;
|
|
|
|
bool get hasLocationSelection =>
|
|
_selectedBusinessId != null && _selectedServicePointId != null;
|
|
|
|
void setBusiness(int businessId) {
|
|
_selectedBusinessId = businessId;
|
|
_selectedServicePointId = null;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
void setServicePoint(int servicePointId) {
|
|
_selectedServicePointId = servicePointId;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
void setUserId(int userId) {
|
|
_userId = userId;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearAuth() {
|
|
_userId = null;
|
|
notifyListeners();
|
|
}
|
|
|
|
void setCartOrder({required int orderId, required String orderUuid}) {
|
|
_cartOrderId = orderId;
|
|
_cartOrderUuid = orderUuid;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearCart() {
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearAll() {
|
|
_selectedBusinessId = null;
|
|
_selectedServicePointId = null;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
|
|
notifyListeners();
|
|
}
|
|
}
|