From 97c4359ad9e022d7431e6d6d5c6765e58d80d93a Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 26 Apr 2020 17:12:34 +0200 Subject: [PATCH] Recording editor: Initialize from recording --- mobile/lib/editors/recording.dart | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mobile/lib/editors/recording.dart b/mobile/lib/editors/recording.dart index ade9a7f..c98ccec 100644 --- a/mobile/lib/editors/recording.dart +++ b/mobile/lib/editors/recording.dart @@ -11,10 +11,13 @@ import '../selectors/work.dart'; /// If the user has finished editing, the result will be returned using the /// navigator as a [RecordingSelectorResult] object. class RecordingEditor extends StatefulWidget { - final Recording recording; + /// The recording to edit. + /// + /// If this is null, a new recording will be created. + final RecordingInfo recordingInfo; RecordingEditor({ - this.recording, + this.recordingInfo, }); @override @@ -31,8 +34,13 @@ class _RecordingEditorState extends State { void initState() { super.initState(); - if (widget.recording != null) { - // TODO: Initialize. + if (widget.recordingInfo != null) { + final backend = Backend.of(context); + + () async { + workInfo = await backend.db.getWork(widget.recordingInfo.recording.id); + performanceInfos = List.from(widget.recordingInfo.performances); + }(); } } @@ -100,7 +108,7 @@ class _RecordingEditorState extends State { onPressed: () async { final recordingInfo = RecordingInfo( recording: Recording( - id: widget.recording?.id ?? generateId(), + id: widget?.recordingInfo?.recording?.id ?? generateId(), work: workInfo.work.id, comment: commentController.text, ),