This commit is contained in:
Thibault Deckers 2022-07-11 09:41:44 +02:00
parent f154278bf9
commit 15f1f5eb63
2 changed files with 8 additions and 7 deletions

View file

@ -48,7 +48,6 @@ android {
main.java.srcDirs += 'src/main/kotlin' main.java.srcDirs += 'src/main/kotlin'
} }
defaultConfig { defaultConfig {
applicationId appId applicationId appId
// minSdkVersion constraints: // minSdkVersion constraints:

View file

@ -22,6 +22,8 @@ class DrawerAlbumTab extends StatefulWidget {
} }
class _DrawerAlbumTabState extends State<DrawerAlbumTab> { class _DrawerAlbumTabState extends State<DrawerAlbumTab> {
List<String> get items => widget.items;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final source = context.read<CollectionSource>(); final source = context.read<CollectionSource>();
@ -32,7 +34,7 @@ class _DrawerAlbumTabState extends State<DrawerAlbumTab> {
Flexible( Flexible(
child: ReorderableListView.builder( child: ReorderableListView.builder(
itemBuilder: (context, index) { itemBuilder: (context, index) {
final album = widget.items[index]; final album = items[index];
final filter = AlbumFilter(album, source.getAlbumDisplayName(context, album)); final filter = AlbumFilter(album, source.getAlbumDisplayName(context, album));
return ListTile( return ListTile(
key: ValueKey(album), key: ValueKey(album),
@ -41,17 +43,17 @@ class _DrawerAlbumTabState extends State<DrawerAlbumTab> {
trailing: IconButton( trailing: IconButton(
icon: const Icon(AIcons.clear), icon: const Icon(AIcons.clear),
onPressed: () { onPressed: () {
setState(() => widget.items.remove(album)); setState(() => items.remove(album));
}, },
tooltip: context.l10n.actionRemove, tooltip: context.l10n.actionRemove,
), ),
); );
}, },
itemCount: widget.items.length, itemCount: items.length,
onReorder: (oldIndex, newIndex) { onReorder: (oldIndex, newIndex) {
setState(() { setState(() {
if (oldIndex < newIndex) newIndex -= 1; if (oldIndex < newIndex) newIndex -= 1;
widget.items.insert(newIndex, widget.items.removeAt(oldIndex)); items.insert(newIndex, items.removeAt(oldIndex));
}); });
}, },
shrinkWrap: true, shrinkWrap: true,
@ -64,8 +66,8 @@ class _DrawerAlbumTabState extends State<DrawerAlbumTab> {
label: context.l10n.settingsNavigationDrawerAddAlbum, label: context.l10n.settingsNavigationDrawerAddAlbum,
onPressed: () async { onPressed: () async {
final album = await pickAlbum(context: context, moveType: null); final album = await pickAlbum(context: context, moveType: null);
if (album == null) return; if (album == null || items.contains(album)) return;
setState(() => widget.items.add(album)); setState(() => items.add(album));
}, },
), ),
], ],