💄 Optimize settings screen
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:groovybox/providers/settings_provider.dart';
|
||||
import 'package:groovybox/providers/watch_folder_provider.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
class SettingsScreen extends ConsumerWidget {
|
||||
const SettingsScreen({super.key});
|
||||
@@ -15,15 +16,19 @@ class SettingsScreen extends ConsumerWidget {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Settings')),
|
||||
body: settingsAsync.when(
|
||||
data: (settings) => SingleChildScrollView(
|
||||
data: (settings) => Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 640),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
spacing: 16,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Auto Scan Section
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
margin: EdgeInsets.zero,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -33,13 +38,15 @@ class SettingsScreen extends ConsumerWidget {
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
).padding(horizontal: 16, bottom: 8, top: 16),
|
||||
SwitchListTile(
|
||||
title: const Text('Auto-scan music libraries'),
|
||||
subtitle: const Text(
|
||||
'Automatically scan music libraries for new music files',
|
||||
),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
value: settings.autoScan,
|
||||
onChanged: (value) {
|
||||
ref.read(autoScanProvider.notifier).update(value);
|
||||
@@ -50,6 +57,9 @@ class SettingsScreen extends ConsumerWidget {
|
||||
subtitle: const Text(
|
||||
'Monitor music libraries for file changes',
|
||||
),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
value: settings.watchForChanges,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
@@ -57,19 +67,18 @@ class SettingsScreen extends ConsumerWidget {
|
||||
.update(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Watch Folders Section
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
margin: EdgeInsets.zero,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -84,25 +93,38 @@ class SettingsScreen extends ConsumerWidget {
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => _scanLibraries(context, ref),
|
||||
onPressed: () =>
|
||||
_scanLibraries(context, ref),
|
||||
icon: const Icon(Icons.refresh),
|
||||
tooltip: 'Scan Libraries',
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: -4,
|
||||
vertical: -4,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _addMusicLibrary(context, ref),
|
||||
onPressed: () =>
|
||||
_addMusicLibrary(context, ref),
|
||||
icon: const Icon(Icons.add),
|
||||
tooltip: 'Add Music Library',
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: -4,
|
||||
vertical: -4,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Add folder libraries to index music files. Files will be copied to internal storage for playback.',
|
||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 14,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
),
|
||||
],
|
||||
).padding(horizontal: 16, top: 16, bottom: 8),
|
||||
watchFoldersAsync.when(
|
||||
data: (folders) => folders.isEmpty
|
||||
? const Text(
|
||||
@@ -111,13 +133,17 @@ class SettingsScreen extends ConsumerWidget {
|
||||
color: Colors.grey,
|
||||
fontSize: 14,
|
||||
),
|
||||
)
|
||||
).padding(horizontal: 16, vertical: 8)
|
||||
: Column(
|
||||
children: folders
|
||||
.map(
|
||||
(folder) => ListTile(
|
||||
title: Text(folder.name),
|
||||
subtitle: Text(folder.path),
|
||||
contentPadding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -156,13 +182,15 @@ class SettingsScreen extends ConsumerWidget {
|
||||
error: (error, _) =>
|
||||
Text('Error loading libraries: $error'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (error, stack) =>
|
||||
Center(child: Text('Error loading settings: $error')),
|
||||
|
||||
Reference in New Issue
Block a user