From 3af7c23bbca6dedc581d92d64704803fc7d53229 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Wed, 13 May 2020 21:46:53 +0200 Subject: [PATCH] mobile: Access editors from context menu --- mobile/lib/screens/home.dart | 25 +++++++++++++ mobile/lib/screens/person.dart | 41 ++++++++++++--------- mobile/lib/screens/work.dart | 65 ++++++++++++++++++++-------------- 3 files changed, 88 insertions(+), 43 deletions(-) diff --git a/mobile/lib/screens/home.dart b/mobile/lib/screens/home.dart index 831d630..387959e 100644 --- a/mobile/lib/screens/home.dart +++ b/mobile/lib/screens/home.dart @@ -85,6 +85,31 @@ class _HomeScreenState extends State { ), ), ), + onLongPress: () { + showDialog( + context: context, + builder: (context) { + return SimpleDialog( + children: [ + ListTile( + title: Text('Edit person'), + onTap: () async { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => PersonEditor( + person: person, + ), + fullscreenDialog: true, + ), + ); + }, + ), + ], + ); + }, + ); + }, ), ), ); diff --git a/mobile/lib/screens/person.dart b/mobile/lib/screens/person.dart index 772509b..930ba34 100644 --- a/mobile/lib/screens/person.dart +++ b/mobile/lib/screens/person.dart @@ -36,22 +36,6 @@ class _PersonScreenState extends State { 'Works by ${widget.person.firstName} ${widget.person.lastName}', ), ), - actions: [ - IconButton( - icon: const Icon(Icons.edit), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => PersonEditor( - person: widget.person, - ), - fullscreenDialog: true, - ), - ); - }, - ), - ], ), body: PagedListView( search: _search, @@ -68,6 +52,31 @@ class _PersonScreenState extends State { ), ), ), + onLongPress: () { + showDialog( + context: context, + builder: (context) { + return SimpleDialog( + children: [ + ListTile( + title: Text('Edit work'), + onTap: () async { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => WorkEditor( + workInfo: workInfo, + ), + fullscreenDialog: true, + ), + ); + }, + ), + ], + ); + }, + ); + }, ), ), ); diff --git a/mobile/lib/screens/work.dart b/mobile/lib/screens/work.dart index 002bf7c..666d1e7 100644 --- a/mobile/lib/screens/work.dart +++ b/mobile/lib/screens/work.dart @@ -16,39 +16,50 @@ class WorkScreen extends StatelessWidget { return Scaffold( appBar: AppBar( title: Text(workInfo.work.title), - actions: [ - IconButton( - icon: const Icon(Icons.edit), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => WorkEditor( - workInfo: workInfo, - ), - fullscreenDialog: true, - ), - ); - }, - ), - ], ), body: PagedListView( fetch: (page, _) async { return await backend.db.getRecordings(workInfo.work.id, page); }, - builder: (context, recordingInfo) => ListTile( - title: PerformancesText( - performanceInfos: recordingInfo.performances, - ), - onTap: () { - final tracks = backend.library.tracks[recordingInfo.recording.id]; - tracks.sort((t1, t2) => t1.track.index.compareTo(t2.track.index)); + builder: (context, recordingInfo) { + final recordingId = recordingInfo.recording.id; - backend.playback - .addTracks(backend.library.tracks[recordingInfo.recording.id]); - }, - ), + return ListTile( + title: PerformancesText( + performanceInfos: recordingInfo.performances, + ), + onTap: () { + final tracks = backend.library.tracks[recordingId]; + tracks.sort((t1, t2) => t1.track.index.compareTo(t2.track.index)); + backend.playback.addTracks(tracks); + }, + onLongPress: () { + showDialog( + context: context, + builder: (context) { + return SimpleDialog( + children: [ + ListTile( + title: Text('Edit recording'), + onTap: () { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => RecordingEditor( + recordingInfo: recordingInfo, + ), + fullscreenDialog: true, + ), + ); + }, + ), + ], + ); + }, + ); + }, + ); + }, ), ); }