diff --git a/lib/editors/tracks.dart b/lib/editors/tracks.dart index efb5dc8..6b6baaa 100644 --- a/lib/editors/tracks.dart +++ b/lib/editors/tracks.dart @@ -55,12 +55,16 @@ class _TracksEditorState extends State { trailing: IconButton( icon: const Icon(Icons.add), onPressed: () async { - final Set paths = await Navigator.push( + final FilesSelectorResult result = await Navigator.push( context, MaterialPageRoute( builder: (context) => FilesSelector(), ), ); + + if (result != null) { + // TODO: Add tracks. + } }, ), ), diff --git a/lib/selectors/files.dart b/lib/selectors/files.dart index 577faef..896d47e 100644 --- a/lib/selectors/files.dart +++ b/lib/selectors/files.dart @@ -3,6 +3,21 @@ import 'package:flutter/material.dart'; import '../backend.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 trackIds; + + FilesSelectorResult(this.parentId, this.trackIds); +} + class FilesSelector extends StatefulWidget { @override _FilesSelectorState createState() => _FilesSelectorState(); @@ -38,7 +53,13 @@ class _FilesSelectorState extends State { FlatButton( child: Text('DONE'), onPressed: () { - Navigator.pop(context, selectedIds); + Navigator.pop( + context, + FilesSelectorResult( + history.isNotEmpty ? history.last.id : null, + selectedIds.toList(), + ), + ); }, ), ],