mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Files selector: Return parent document ID
This commit is contained in:
parent
448a0de6fa
commit
9da8f8891b
2 changed files with 27 additions and 2 deletions
|
|
@ -55,12 +55,16 @@ class _TracksEditorState extends State<TracksEditor> {
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final Set<String> paths = await Navigator.push(
|
final FilesSelectorResult result = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => FilesSelector(),
|
builder: (context) => FilesSelector(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
// TODO: Add tracks.
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,21 @@ import 'package:flutter/material.dart';
|
||||||
import '../backend.dart';
|
import '../backend.dart';
|
||||||
import '../platform.dart';
|
import '../platform.dart';
|
||||||
|
|
||||||
|
/// Result of the user's interaction with the files selector.
|
||||||
|
///
|
||||||
|
/// This will be given back when popping the navigator.
|
||||||
|
class FilesSelectorResult {
|
||||||
|
/// Document ID of the parent directory of the selected files.
|
||||||
|
///
|
||||||
|
/// This will be null, if they are in the toplevel directory.
|
||||||
|
final String parentId;
|
||||||
|
|
||||||
|
/// Document IDs of the selected files.
|
||||||
|
final List<String> trackIds;
|
||||||
|
|
||||||
|
FilesSelectorResult(this.parentId, this.trackIds);
|
||||||
|
}
|
||||||
|
|
||||||
class FilesSelector extends StatefulWidget {
|
class FilesSelector extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_FilesSelectorState createState() => _FilesSelectorState();
|
_FilesSelectorState createState() => _FilesSelectorState();
|
||||||
|
|
@ -38,7 +53,13 @@ class _FilesSelectorState extends State<FilesSelector> {
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text('DONE'),
|
child: Text('DONE'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context, selectedIds);
|
Navigator.pop(
|
||||||
|
context,
|
||||||
|
FilesSelectorResult(
|
||||||
|
history.isNotEmpty ? history.last.id : null,
|
||||||
|
selectedIds.toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue