From 1a92a9e967e6e9acbe61aacb17a6fc55dc2f7ea6 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 21 Oct 2024 20:28:27 +0530 Subject: [PATCH] [mob][photos] Fix buggy create album --- mobile/lib/ui/collections/new_album_icon.dart | 6 ++++-- mobile/lib/ui/components/dialog_widget.dart | 4 +++- mobile/lib/utils/dialog_util.dart | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mobile/lib/ui/collections/new_album_icon.dart b/mobile/lib/ui/collections/new_album_icon.dart index 01d871210f..61b7355a9f 100644 --- a/mobile/lib/ui/collections/new_album_icon.dart +++ b/mobile/lib/ui/collections/new_album_icon.dart @@ -34,8 +34,8 @@ class NewAlbumIcon extends StatelessWidget { alwaysShowSuccessState: false, initialValue: "", textCapitalization: TextCapitalization.words, + popnavAfterSubmission: false, onSubmit: (String text) async { - // indicates user cancelled the rename request if (text.trim() == "") { return; } @@ -44,10 +44,11 @@ class NewAlbumIcon extends StatelessWidget { final Collection c = await CollectionsService.instance.createAlbum(text); // ignore: unawaited_futures - routeToPage( + await routeToPage( context, CollectionPage(CollectionWithThumbnail(c, null)), ); + Navigator.of(context).pop(); } catch (e, s) { Logger("CreateNewAlbumIcon") .severe("Failed to rename album", e, s); @@ -55,6 +56,7 @@ class NewAlbumIcon extends StatelessWidget { } }, ); + if (result is Exception) { await showGenericErrorDialog(context: context, error: result); } diff --git a/mobile/lib/ui/components/dialog_widget.dart b/mobile/lib/ui/components/dialog_widget.dart index 1567151401..2d8fe96b75 100644 --- a/mobile/lib/ui/components/dialog_widget.dart +++ b/mobile/lib/ui/components/dialog_widget.dart @@ -180,6 +180,7 @@ class TextInputDialog extends StatefulWidget { final TextEditingController? textEditingController; final List? textInputFormatter; final TextInputType? textInputType; + final bool popnavAfterSubmission; const TextInputDialog({ required this.title, this.body, @@ -200,6 +201,7 @@ class TextInputDialog extends StatefulWidget { this.textEditingController, this.textInputFormatter, this.textInputType, + this.popnavAfterSubmission = true, super.key, }); @@ -273,7 +275,7 @@ class _TextInputDialogState extends State { maxLength: widget.maxLength, submitNotifier: _submitNotifier, onSubmit: widget.onSubmit, - popNavAfterSubmission: true, + popNavAfterSubmission: widget.popnavAfterSubmission, showOnlyLoadingState: widget.showOnlyLoadingState, textCapitalization: widget.textCapitalization, alwaysShowSuccessState: widget.alwaysShowSuccessState, diff --git a/mobile/lib/utils/dialog_util.dart b/mobile/lib/utils/dialog_util.dart index 1274d6d8b0..f72af1c9a7 100644 --- a/mobile/lib/utils/dialog_util.dart +++ b/mobile/lib/utils/dialog_util.dart @@ -357,6 +357,7 @@ Future showTextInputDialog( List? textInputFormatter, TextInputType? textInputType, bool useRootNavigator = false, + bool popnavAfterSubmission = true, }) { return showDialog( barrierColor: backdropFaintDark, @@ -388,6 +389,7 @@ Future showTextInputDialog( textEditingController: textEditingController, textInputFormatter: textInputFormatter, textInputType: textInputType, + popnavAfterSubmission: popnavAfterSubmission, ), ), );