🐛 Bug fixes of libraries
This commit is contained in:
@@ -20,85 +20,6 @@ class SettingsScreen extends ConsumerWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Import Mode Section
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Import Mode',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(ImportMode.copy.displayName),
|
||||
subtitle: const Text(
|
||||
'Copy music files to internal storage',
|
||||
),
|
||||
leading: RadioGroup<ImportMode>(
|
||||
groupValue: settings.importMode,
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref
|
||||
.read(importModeProvider.notifier)
|
||||
.update(value);
|
||||
}
|
||||
},
|
||||
child: Radio<ImportMode>(value: ImportMode.copy),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(ImportMode.inplace.displayName),
|
||||
subtitle: const Text(
|
||||
'Index music files in their original location',
|
||||
),
|
||||
leading: RadioGroup<ImportMode>(
|
||||
groupValue: settings.importMode,
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref
|
||||
.read(importModeProvider.notifier)
|
||||
.update(value);
|
||||
}
|
||||
},
|
||||
child: Radio<ImportMode>(
|
||||
value: ImportMode.inplace,
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(ImportMode.mixed.displayName),
|
||||
subtitle: const Text(
|
||||
'Use internal storage and add folder libraries',
|
||||
),
|
||||
leading: RadioGroup<ImportMode>(
|
||||
groupValue: settings.importMode,
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref
|
||||
.read(importModeProvider.notifier)
|
||||
.update(value);
|
||||
}
|
||||
},
|
||||
child: Radio<ImportMode>(value: ImportMode.mixed),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Auto Scan Section
|
||||
Card(
|
||||
child: Padding(
|
||||
@@ -160,95 +81,81 @@ class SettingsScreen extends ConsumerWidget {
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (settings.importMode == ImportMode.inplace ||
|
||||
settings.importMode == ImportMode.mixed)
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => _scanLibraries(context, ref),
|
||||
icon: const Icon(Icons.refresh),
|
||||
tooltip: 'Scan Libraries',
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () =>
|
||||
_addMusicLibrary(context, ref),
|
||||
icon: const Icon(Icons.add),
|
||||
tooltip: 'Add Music Library',
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => _scanLibraries(context, ref),
|
||||
icon: const Icon(Icons.refresh),
|
||||
tooltip: 'Scan Libraries',
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _addMusicLibrary(context, ref),
|
||||
icon: const Icon(Icons.add),
|
||||
tooltip: 'Add Music Library',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (settings.importMode == ImportMode.inplace ||
|
||||
settings.importMode == ImportMode.mixed) ...[
|
||||
const Text(
|
||||
'Add folder libraries to index music files in their original location.',
|
||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
if (settings.importMode == ImportMode.copy)
|
||||
const Text(
|
||||
'Folder libraries are available in in-place and mixed modes.',
|
||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||
),
|
||||
if (settings.importMode == ImportMode.inplace ||
|
||||
settings.importMode == ImportMode.mixed) ...[
|
||||
watchFoldersAsync.when(
|
||||
data: (folders) => folders.isEmpty
|
||||
? const Text(
|
||||
'No music libraries added yet.',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 14,
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
children: folders
|
||||
.map(
|
||||
(folder) => ListTile(
|
||||
title: Text(folder.name),
|
||||
subtitle: Text(folder.path),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Switch(
|
||||
value: folder.isActive,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(
|
||||
watchFolderServiceProvider,
|
||||
)
|
||||
.toggleWatchFolder(
|
||||
folder.id,
|
||||
value,
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(
|
||||
watchFolderServiceProvider,
|
||||
)
|
||||
.removeWatchFolder(
|
||||
folder.id,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
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),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
watchFoldersAsync.when(
|
||||
data: (folders) => folders.isEmpty
|
||||
? const Text(
|
||||
'No music libraries added yet.',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 14,
|
||||
),
|
||||
loading: () => const CircularProgressIndicator(),
|
||||
error: (error, _) =>
|
||||
Text('Error loading libraries: $error'),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: folders
|
||||
.map(
|
||||
(folder) => ListTile(
|
||||
title: Text(folder.name),
|
||||
subtitle: Text(folder.path),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Switch(
|
||||
value: folder.isActive,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(
|
||||
watchFolderServiceProvider,
|
||||
)
|
||||
.toggleWatchFolder(
|
||||
folder.id,
|
||||
value,
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(
|
||||
watchFolderServiceProvider,
|
||||
)
|
||||
.removeWatchFolder(
|
||||
folder.id,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
loading: () => const CircularProgressIndicator(),
|
||||
error: (error, _) =>
|
||||
Text('Error loading libraries: $error'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user