diff --git a/lib/main.dart b/lib/main.dart index a2ab4ec..4f800b2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -42,18 +42,19 @@ class AppRouter extends StatefulWidget { class _AppRouterState extends State { bool _loading = true; - bool _hasData = false; + bool _hasCompletedOnboarding = false; @override void initState() { super.initState(); - _checkExistingData(); + _checkState(); } - Future _checkExistingData() async { + Future _checkState() async { + // Check if user has ever completed a run (has saved data) final hasData = await LocalStorage.hasCompletedSetup(); setState(() { - _hasData = hasData; + _hasCompletedOnboarding = hasData; _loading = false; }); } @@ -68,40 +69,12 @@ class _AppRouterState extends State { ); } - // If user has existing data, go straight to results - if (_hasData) { - return FutureBuilder( - future: _loadExistingData(), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const Scaffold( - body: Center(child: CircularProgressIndicator()), - ); - } - - if (snapshot.hasData) { - final data = snapshot.data!; - return ResultsScreen( - profile: data.$1, - behaviors: data.$2, - ); - } - - return const OnboardingScreen(); - }, - ); + // First launch: show onboarding + // Returning users: show welcome screen (where they can start fresh or continue) + if (_hasCompletedOnboarding) { + return const WelcomeScreen(); } return const OnboardingScreen(); } - - Future<(dynamic, dynamic)?> _loadExistingData() async { - final profile = await LocalStorage.getProfile(); - final behaviors = await LocalStorage.getBehaviors(); - - if (profile != null && behaviors != null) { - return (profile, behaviors); - } - return null; - } }