Skip to content

commit 301ac75

abduznik edited this page May 23, 2026 · 1 revision

fix: improve initial setup flow, fix settings loading, and update Windows default paths

Commit: 301ac75b7c6db1ff75f6a0da6552cde0e0fce4d6

Author: abduznik

Date: 2026-04-28

Why: Fixes a bug or regression in the existing codebase.

Files Changed

lib/app.dart                            | 13 +++++++------
 lib/core/storage/directory_service.dart | 10 ++--------
 lib/providers/ui_provider.dart          |  3 +++
 lib/ui/screens/library_screen.dart      |  6 ++----
 lib/ui/screens/settings_screen.dart     |  2 --
 5 files changed, 14 insertions(+), 20 deletions(-)
  • lib/app.dart
  • lib/core/storage/directory_service.dart
  • lib/providers/ui_provider.dart
  • lib/ui/screens/library_screen.dart
  • lib/ui/screens/settings_screen.dart

Diff

diff --git a/lib/app.dart b/lib/app.dart
index 2c96645..e250cca 100644
--- a/lib/app.dart
+++ b/lib/app.dart
@@ -10,6 +10,7 @@ import 'core/save/background_sync_queue.dart';
 import 'ui/screens/library_screen.dart';
 import 'ui/screens/download_screen.dart';
 import 'ui/screens/settings_screen.dart';
+import 'providers/ui_provider.dart';
 
 class CustomScrollBehavior extends MaterialScrollBehavior {
   @override
@@ -29,7 +30,7 @@ class FreegosyApp extends ConsumerStatefulWidget {
 }
 
 class _FreegosyAppState extends ConsumerState<FreegosyApp> {
-  int _currentIndex = 0;
+
 
   final List<Widget> _screens = const [
     LibraryScreen(),
@@ -72,6 +73,8 @@ class _FreegosyAppState extends ConsumerState<FreegosyApp> {
       }
     });
 
+    final currentIndex = ref.watch(currentTabIndexProvider);
+
     return ExcludeSemantics(
       child: MaterialApp(
         title: 'Freegosy',
@@ -120,13 +123,11 @@ class _FreegosyAppState extends ConsumerState<FreegosyApp> {
           ),
         ),
         home: Scaffold(
-          body: _screens[_currentIndex],
+          body: _screens[currentIndex],
           bottomNavigationBar: NavigationBar(
-            selectedIndex: _currentIndex,
+            selectedIndex: currentIndex,
             onDestinationSelected: (index) {
-              setState(() {
-                _currentIndex = index;
-              });
+              ref.read(currentTabIndexProvider.notifier).state = index;
             },
             destinations: const [
               NavigationDestination(
diff --git a/lib/core/storage/directory_service.dart b/lib/core/storage/directory_service.dart
index 58479c6..93b4edb 100644
--- a/lib/core/storage/directory_service.dart
+++ b/lib/core/storage/directory_service.dart
@@ -193,14 +193,8 @@ class DirectoryService {
   }
 
   Future<String> getDefaultBase() async {
-    if (defaultTargetPlatform == TargetPlatform.macOS ||
-        defaultTargetPlatform == TargetPlatform.linux) {
-      final appSupport = await getApplicationSupportDirectory();
-      return appSupport.path;
-    } else {
-      final docsDir = await getApplicationDocumentsDirectory();
-      return docsDir.path;
-    }
+    final appSupport = await getApplicationSupportDirectory();
+    return appSupport.path;
   }
 
   Future<void> resetRomsRoot() async {
diff --git a/lib/providers/ui_provider.dart b/lib/providers/ui_provider.dart
new file mode 100644
index 0000000..101ad97
--- /dev/null
+++ b/lib/providers/ui_provider.dart
@@ -0,0 +1,3 @@
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+
+final currentTabIndexProvider = StateProvider<int>((ref) => 0);
diff --git a/lib/ui/screens/library_screen.dart b/lib/ui/screens/library_screen.dart
index 0ee2096..cf4c147 100644
--- a/lib/ui/screens/library_screen.dart
+++ b/lib/ui/screens/library_screen.dart
@@ -18,6 +18,7 @@ import 'game_detail_screen.dart';
 import 'library_actions.dart';
 
 import '../../providers/download_provider.dart';
+import '../../providers/ui_provider.dart';
 
 final isHomeSelectedProvider = StateProvider<bool>((ref) => true);
 
@@ -450,10 +451,7 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen> with LibraryActio
                             const SizedBox(height: 24),
                             ElevatedButton(
                               onPressed: () {
-                                // Ideally we would switch the tab, but for now just a hint
-                                ScaffoldMessenger.of(context).showSnackBar(
-                                  const SnackBar(content: Text('Click the Settings icon at the bottom.')),
-                                );
+                                ref.read(currentTabIndexProvider.notifier).state = 2;
                               },
                               child: const Text('Go to Settings'),
                             ),
diff --git a/lib/ui/screens/settings_screen.dart b/lib/ui/screens/settings_screen.dart
index e3caa05..7619b64 100644
--- a/lib/ui/screens/settings_screen.dart
+++ b/lib/ui/screens/settings_screen.dart
@@ -85,11 +85,9 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
                            (rommConfig.username.isNotEmpty || rommConfig.password.isNotEmpty);
             _preferencesLoaded = true;
           }
-
           return directoryServiceAsync.when(
             data: (directoryService) {
               if (directoryService == null) return const Center(child: Text('Storage service not available.'));
-              if (rommService == null) return const Center(child: CircularProgressIndicator());
 
               return ListView(
                 padding: const EdgeInsets.all(16.0),

Clone this wiki locally