From e873f1f4e28561f60c5be2ba0a55bbe794dffd7f Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 10 Nov 2020 18:24:43 +0100 Subject: [PATCH] Fix sharing to the app It's super hacky, but since I broke it, I just want to first fix it, and later I'll try to make it nicer. --- lib/app.dart | 10 ++++++---- lib/app_router.dart | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index f73b72d1..7072ad61 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -297,10 +297,12 @@ class _JournalAppState extends State { debugShowCheckedModeBanner: false, //debugShowMaterialGrid: true, onGenerateRoute: (rs) { - var r = router.generateRoute( - rs, stateContainer, _sharedText, _sharedImages); - _sharedText = null; - _sharedImages = null; + var r = router + .generateRoute(rs, stateContainer, _sharedText, _sharedImages, () { + _sharedText = null; + _sharedImages = null; + }); + return r; }, ); diff --git a/lib/app_router.dart b/lib/app_router.dart index ce6ce7c4..5db145a7 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -42,6 +42,7 @@ class AppRouter { Repository repository, String sharedText, List sharedImages, + Function callbackIfUsedShared, ) { var route = routeSettings.name; if (route == '/folders' || route == '/tags' || route == '/filesystem') { @@ -53,6 +54,7 @@ class AppRouter { settings, sharedText, sharedImages, + callbackIfUsedShared, ), transitionsBuilder: (_, anim, __, child) { return FadeTransition(opacity: anim, child: child); @@ -68,6 +70,7 @@ class AppRouter { settings, sharedText, sharedImages, + callbackIfUsedShared, ), ); } @@ -78,6 +81,7 @@ class AppRouter { Settings settings, String sharedText, List sharedImages, + Function callbackIfUsedShared, ) { switch (route) { case '/': @@ -126,6 +130,8 @@ class AppRouter { }); } + callbackIfUsedShared(); + var folder = getFolderForEditor(settings, rootFolder, et); return NoteEditor.newNote( folder,