Cart/Payment: - Custom tip option (0-200%) with dialog input - Tip buttons now include "Custom" option - Default custom tip starts at 25% Order Flow: - New order type selection screen (Dine-In, Takeout, Delivery) - Group order invite screen (placeholder) - App router updated with new routes Menu Display: - Category headers now text-only (removed image loading) - Simplified category background with gradient and styled text Beacon Scanning: - Improved beacon detection flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
152 lines
3.5 KiB
Dart
152 lines
3.5 KiB
Dart
import "package:flutter/foundation.dart";
|
|
|
|
enum OrderType {
|
|
dineIn, // Table service (beacon detected)
|
|
delivery, // Delivery to customer
|
|
takeaway, // Pickup at counter
|
|
}
|
|
|
|
class AppState extends ChangeNotifier {
|
|
int? _selectedBusinessId;
|
|
String? _selectedBusinessName;
|
|
int? _selectedServicePointId;
|
|
String? _selectedServicePointName;
|
|
|
|
int? _userId;
|
|
|
|
OrderType? _orderType;
|
|
|
|
int? _cartOrderId;
|
|
String? _cartOrderUuid;
|
|
int _cartItemCount = 0;
|
|
|
|
int? _activeOrderId;
|
|
int? _activeOrderStatusId;
|
|
|
|
int? get selectedBusinessId => _selectedBusinessId;
|
|
String? get selectedBusinessName => _selectedBusinessName;
|
|
int? get selectedServicePointId => _selectedServicePointId;
|
|
String? get selectedServicePointName => _selectedServicePointName;
|
|
|
|
int? get userId => _userId;
|
|
bool get isLoggedIn => _userId != null && _userId! > 0;
|
|
|
|
OrderType? get orderType => _orderType;
|
|
bool get isDelivery => _orderType == OrderType.delivery;
|
|
bool get isTakeaway => _orderType == OrderType.takeaway;
|
|
bool get isDineIn => _orderType == OrderType.dineIn;
|
|
|
|
int? get cartOrderId => _cartOrderId;
|
|
String? get cartOrderUuid => _cartOrderUuid;
|
|
int get cartItemCount => _cartItemCount;
|
|
|
|
int? get activeOrderId => _activeOrderId;
|
|
int? get activeOrderStatusId => _activeOrderStatusId;
|
|
bool get hasActiveOrder => _activeOrderId != null;
|
|
|
|
bool get hasLocationSelection =>
|
|
_selectedBusinessId != null && _selectedServicePointId != null;
|
|
|
|
void setBusiness(int businessId) {
|
|
_selectedBusinessId = businessId;
|
|
_selectedServicePointId = null;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
_cartItemCount = 0;
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
void setServicePoint(int servicePointId) {
|
|
_selectedServicePointId = servicePointId;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
_cartItemCount = 0;
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
void setBusinessAndServicePoint(
|
|
int businessId,
|
|
int servicePointId, {
|
|
String? businessName,
|
|
String? servicePointName,
|
|
}) {
|
|
_selectedBusinessId = businessId;
|
|
_selectedBusinessName = businessName;
|
|
_selectedServicePointId = servicePointId;
|
|
_selectedServicePointName = servicePointName;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
_cartItemCount = 0;
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
void setUserId(int userId) {
|
|
_userId = userId;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearAuth() {
|
|
_userId = null;
|
|
notifyListeners();
|
|
}
|
|
|
|
void setOrderType(OrderType? type) {
|
|
_orderType = type;
|
|
notifyListeners();
|
|
}
|
|
|
|
void setCartOrder({required int orderId, required String orderUuid, int itemCount = 0}) {
|
|
_cartOrderId = orderId;
|
|
_cartOrderUuid = orderUuid;
|
|
_cartItemCount = itemCount;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateCartItemCount(int count) {
|
|
_cartItemCount = count;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearCart() {
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
_cartItemCount = 0;
|
|
notifyListeners();
|
|
}
|
|
|
|
void setActiveOrder({required int orderId, required int statusId}) {
|
|
_activeOrderId = orderId;
|
|
_activeOrderStatusId = statusId;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateActiveOrderStatus(int statusId) {
|
|
_activeOrderStatusId = statusId;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearActiveOrder() {
|
|
_activeOrderId = null;
|
|
_activeOrderStatusId = null;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearAll() {
|
|
_selectedBusinessId = null;
|
|
_selectedServicePointId = null;
|
|
_orderType = null;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
_cartItemCount = 0;
|
|
|
|
_activeOrderId = null;
|
|
_activeOrderStatusId = null;
|
|
}
|
|
}
|