payfrit-app/lib/screens/splash_screen.dart
John Mizerek 7c366d5a9c Add production API support and fix login flow
- Configure production API URL (biz.payfrit.com) as default
- Add INTERNET permission to AndroidManifest for API calls
- Remove login requirement from restaurant selection (allow anonymous browsing)
- Add enhanced logging for beacon scanning diagnostics
- Add splash screen logging for auth flow debugging

Technical changes:
- api.dart: Default baseUrl to production instead of throwing error
- restaurant_select_screen.dart: Remove userId requirement for browsing
- beacon_scan_screen.dart: Replace debugPrint with print for better log capture
- splash_screen.dart: Add diagnostic logging for auth restoration
- AndroidManifest.xml: Add INTERNET permission

Known issue:
- Beacon detection not working - app receives beacon data from API (3 beacons)
  but BLE scanning not detecting physical beacons. Needs investigation of:
  * Physical beacon UUID configuration
  * Android BLE permissions at runtime
  * Beacon plugin initialization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-31 12:04:50 -08:00

73 lines
2 KiB
Dart
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import "dart:async";
import "package:flutter/material.dart";
import "package:provider/provider.dart";
import "../app/app_router.dart";
import "../app/app_state.dart";
import "../services/api.dart";
import "../services/auth_storage.dart";
class SplashScreen extends StatefulWidget {
const SplashScreen({super.key});
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
Timer? _timer;
@override
void initState() {
super.initState();
print('[Splash] 🚀 SplashScreen initState called');
_timer = Timer(const Duration(milliseconds: 2400), () async {
print('[Splash] ⏰ Timer fired, starting navigation logic');
if (!mounted) return;
// Check for saved authentication credentials
print('[Splash] 🔐 Checking for saved auth credentials...');
final credentials = await AuthStorage.loadAuth();
if (credentials != null) {
print('[Splash] ✅ Found saved credentials: UserID=${credentials.userId}');
// Restore authentication state
Api.setAuthToken(credentials.token);
final appState = context.read<AppState>();
appState.setUserId(credentials.userId);
} else {
print('[Splash] No saved credentials found');
}
if (!mounted) return;
// Always go to beacon scan first - allows browsing without login
print('[Splash] 📡 Navigating to beacon scan screen');
Navigator.of(context).pushReplacementNamed(AppRoutes.beaconScan);
});
}
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return const Scaffold(
backgroundColor: Colors.black,
body: Center(
child: Text(
"PAYFRIT",
style: TextStyle(
color: Colors.white,
fontSize: 38,
fontWeight: FontWeight.w800,
letterSpacing: 3,
),
),
),
);
}
}