mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Tracks editor: Make tracks reorderable
This commit is contained in:
parent
20d685a3eb
commit
090c4501b1
1 changed files with 53 additions and 42 deletions
|
|
@ -37,7 +37,8 @@ class _TracksEditorState extends State<TracksEditor> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ReorderableListView(
|
||||||
|
header: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
recordingId != null
|
recordingId != null
|
||||||
? RecordingTile(
|
? RecordingTile(
|
||||||
|
|
@ -72,19 +73,29 @@ class _TracksEditorState extends State<TracksEditor> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
for (final track in tracks)
|
],
|
||||||
ListTile(
|
),
|
||||||
title: Text(track.path),
|
children: tracks
|
||||||
|
.map((t) => ListTile(
|
||||||
|
key: Key(t.hashCode.toString()),
|
||||||
|
title: Text(t.path),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: const Icon(Icons.delete),
|
icon: const Icon(Icons.delete),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
tracks.remove(track);
|
tracks.remove(t);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
))
|
||||||
],
|
.toList(),
|
||||||
|
onReorder: (i1, i2) {
|
||||||
|
setState(() {
|
||||||
|
final track = tracks.removeAt(i1);
|
||||||
|
final newIndex = i2 > i1 ? i2 - 1 : i2;
|
||||||
|
tracks.insert(newIndex, track);
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue