UI Improvements: - Menu items displayed as attractive cards with icons and better typography - Restaurant selection upgraded to card-based layout with shadows - Animated pulsing beacon scanner with gradient effect - Enhanced item customization sheet with drag handle and pill-style pricing - Category headers with highlighted background and borders - Business and service point names now shown in app bar Persistent Login: - Created AuthStorage service for credential persistence using SharedPreferences - Auto-restore authentication on app launch - Seamless login flow: scan → browse → login on cart add - Users stay logged in across app restarts Cart Functionality Fixes: - Fixed duplicate item handling: now properly increments quantity - Prevented adding inactive items by skipping unselected modifiers - Fixed self-referential items (item cannot be its own child) - Added debug logging for cart state tracking - Success messages now show accurate item counts Technical Improvements: - AppState tracks business/service point names for display - Beacon scanner passes location names through navigation - Quantity calculation checks existing cart items before adding - Better null safety with firstOrNull pattern 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class AuthStorage {
|
|
static const _keyUserId = 'auth_user_id';
|
|
static const _keyUserToken = 'auth_user_token';
|
|
|
|
/// Save authentication credentials
|
|
static Future<void> saveAuth({
|
|
required int userId,
|
|
required String token,
|
|
}) async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setInt(_keyUserId, userId);
|
|
await prefs.setString(_keyUserToken, token);
|
|
}
|
|
|
|
/// Load saved authentication credentials
|
|
static Future<AuthCredentials?> loadAuth() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final userId = prefs.getInt(_keyUserId);
|
|
final token = prefs.getString(_keyUserToken);
|
|
|
|
if (userId != null && token != null && token.isNotEmpty) {
|
|
return AuthCredentials(userId: userId, token: token);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// Clear authentication credentials (logout)
|
|
static Future<void> clearAuth() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.remove(_keyUserId);
|
|
await prefs.remove(_keyUserToken);
|
|
}
|
|
}
|
|
|
|
class AuthCredentials {
|
|
final int userId;
|
|
final String token;
|
|
|
|
const AuthCredentials({
|
|
required this.userId,
|
|
required this.token,
|
|
});
|
|
}
|