diff --git a/lib/editors/work.dart b/lib/editors/work.dart index 909faef..fe09ebd 100644 --- a/lib/editors/work.dart +++ b/lib/editors/work.dart @@ -119,7 +119,9 @@ class _WorkEditorState extends State { final List selection = await Navigator.push( context, MaterialPageRoute( - builder: (context) => InstrumentsSelector(), + builder: (context) => InstrumentsSelector( + selection: instruments, + ), fullscreenDialog: true, )); diff --git a/lib/selectors/instruments.dart b/lib/selectors/instruments.dart index 84508cb..eb960bf 100644 --- a/lib/selectors/instruments.dart +++ b/lib/selectors/instruments.dart @@ -5,6 +5,12 @@ import '../database.dart'; import '../editors/instrument.dart'; class InstrumentsSelector extends StatefulWidget { + final List selection; + + InstrumentsSelector({ + this.selection, + }); + @override _InstrumentsSelectorState createState() => _InstrumentsSelectorState(); } @@ -12,6 +18,15 @@ class InstrumentsSelector extends StatefulWidget { class _InstrumentsSelectorState extends State { Set selection = {}; + @override + void initState() { + super.initState(); + + if (widget.selection != null) { + selection = widget.selection.toSet(); + } + } + @override Widget build(BuildContext context) { final backend = Backend.of(context); @@ -65,7 +80,7 @@ class _InstrumentsSelectorState extends State { builder: (context) => InstrumentEditor(), fullscreenDialog: true, )); - + if (instrument != null) { setState(() { selection.add(instrument);