mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 10:47:25 +01:00
Add initial selection to instrument selector
Also use this from the work editor.
This commit is contained in:
parent
4855cafdf3
commit
40acc2b555
2 changed files with 19 additions and 2 deletions
|
|
@ -119,7 +119,9 @@ class _WorkEditorState extends State<WorkEditor> {
|
||||||
final List<Instrument> selection = await Navigator.push(
|
final List<Instrument> selection = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => InstrumentsSelector(),
|
builder: (context) => InstrumentsSelector(
|
||||||
|
selection: instruments,
|
||||||
|
),
|
||||||
fullscreenDialog: true,
|
fullscreenDialog: true,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@ import '../database.dart';
|
||||||
import '../editors/instrument.dart';
|
import '../editors/instrument.dart';
|
||||||
|
|
||||||
class InstrumentsSelector extends StatefulWidget {
|
class InstrumentsSelector extends StatefulWidget {
|
||||||
|
final List<Instrument> selection;
|
||||||
|
|
||||||
|
InstrumentsSelector({
|
||||||
|
this.selection,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_InstrumentsSelectorState createState() => _InstrumentsSelectorState();
|
_InstrumentsSelectorState createState() => _InstrumentsSelectorState();
|
||||||
}
|
}
|
||||||
|
|
@ -12,6 +18,15 @@ class InstrumentsSelector extends StatefulWidget {
|
||||||
class _InstrumentsSelectorState extends State<InstrumentsSelector> {
|
class _InstrumentsSelectorState extends State<InstrumentsSelector> {
|
||||||
Set<Instrument> selection = {};
|
Set<Instrument> selection = {};
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
if (widget.selection != null) {
|
||||||
|
selection = widget.selection.toSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final backend = Backend.of(context);
|
final backend = Backend.of(context);
|
||||||
|
|
@ -65,7 +80,7 @@ class _InstrumentsSelectorState extends State<InstrumentsSelector> {
|
||||||
builder: (context) => InstrumentEditor(),
|
builder: (context) => InstrumentEditor(),
|
||||||
fullscreenDialog: true,
|
fullscreenDialog: true,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (instrument != null) {
|
if (instrument != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selection.add(instrument);
|
selection.add(instrument);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue