From 5126b67c9c546fac58c6c74bbb654ef6ce0d8904 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:21:52 +0100 Subject: [PATCH] refactor: remove redundant library management in settings --- lib/screens/settings_screen.dart | 102 ------------------------------- 1 file changed, 102 deletions(-) diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 96927186..4a651a5e 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -46,20 +46,6 @@ class _SettingsScreenState extends State { }); } - Future _unhideLibrary(String libraryKey) async { - // Unhide library using provider - final hiddenLibrariesProvider = Provider.of( - context, - listen: false, - ); - await hiddenLibrariesProvider.unhideLibrary(libraryKey); - - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Library shown')), - ); - } - } @override Widget build(BuildContext context) { @@ -77,8 +63,6 @@ class _SettingsScreenState extends State { delegate: SliverChildListDelegate([ _buildAppearanceSection(), const SizedBox(height: 24), - _buildLibraryManagementSection(), - const SizedBox(height: 24), _buildVideoPlaybackSection(), const SizedBox(height: 24), _buildKeyboardShortcutsSection(), @@ -151,92 +135,6 @@ class _SettingsScreenState extends State { ); } - Widget _buildLibraryManagementSection() { - // Watch for hidden libraries changes to trigger rebuild - final hiddenLibrariesProvider = context.watch(); - final hiddenKeys = hiddenLibrariesProvider.hiddenLibraryKeys; - - return Card( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(16), - child: Text( - 'Library Management', - style: Theme.of( - context, - ).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold), - ), - ), - if (hiddenKeys.isEmpty) - Padding( - padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), - child: Text( - 'No hidden libraries', - style: TextStyle(color: Colors.grey[600]), - ), - ) - else - // Use FutureBuilder to fetch library details for hidden keys - FutureBuilder>( - future: _fetchHiddenLibraries(hiddenKeys), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const Padding( - padding: EdgeInsets.all(16), - child: Center(child: CircularProgressIndicator()), - ); - } - - if (snapshot.hasError || !snapshot.hasData) { - return Padding( - padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), - child: Text( - 'Error loading hidden libraries', - style: TextStyle(color: Colors.grey[600]), - ), - ); - } - - final hiddenLibraries = snapshot.data!; - return Column( - children: hiddenLibraries.map((library) { - return ListTile( - leading: const Icon(Icons.visibility_off), - title: Text(library.title), - subtitle: Text('${library.type} library'), - trailing: TextButton( - onPressed: () => _unhideLibrary(library.key), - child: const Text('Show'), - ), - ); - }).toList(), - ); - }, - ), - ], - ), - ); - } - - Future> _fetchHiddenLibraries(Set hiddenKeys) async { - final clientProvider = Provider.of( - context, - listen: false, - ); - final client = clientProvider.client; - - if (client == null) { - return []; - } - - final allLibraries = await client.getLibraries(); - return allLibraries - .where((lib) => hiddenKeys.contains(lib.key)) - .toList(); - } - Widget _buildVideoPlaybackSection() { return Card( child: Column(