From da3088eab188dc25a7eb3a2ddb4f21a2ed8f4ef6 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 7 Feb 2023 10:58:57 +0530 Subject: [PATCH] Used new TextInputDialog for renaming album --- .../gallery/gallery_app_bar_widget.dart | 35 ++++--------------- lib/utils/dialog_util.dart | 2 +- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index 6868d6367..559cc50a5 100644 --- a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -111,10 +111,9 @@ class _GalleryAppBarWidgetState extends State { if (widget.type != GalleryType.ownedCollection) { return; } - showTextInputDialog( + final result = await showTextInputDialog( context, - title: "Title", - message: "Message", + title: "Rename album", confirmationButtonLabel: "Rename", onConfirm: (String text) async { // indicates user cancelled the rename request @@ -129,35 +128,13 @@ class _GalleryAppBarWidgetState extends State { setState(() {}); } } catch (e) { - showGenericErrorDialog(context: context); + rethrow; } }, ); - // final result = await showDialog( - // context: context, - // builder: (BuildContext context) { - // return RenameDialog(_appBarTitle, 'Album'); - // }, - // barrierColor: Colors.black.withOpacity(0.85), - // ); - // // indicates user cancelled the rename request - // if (result == null || result.trim() == _appBarTitle!.trim()) { - // return; - // } - - // final dialog = createProgressDialog(context, "Changing name..."); - // await dialog.show(); - // try { - // await CollectionsService.instance.rename(widget.collection!, result); - // await dialog.hide(); - // if (mounted) { - // _appBarTitle = result; - // setState(() {}); - // } - // } catch (e) { - // await dialog.hide(); - // showGenericErrorDialog(context: context); - // } + if (result == ButtonAction.error) { + showGenericErrorDialog(context: context); + } } Future _leaveAlbum(BuildContext context) async { diff --git a/lib/utils/dialog_util.dart b/lib/utils/dialog_util.dart index 7d8bb2b4f..4a6ed2495 100644 --- a/lib/utils/dialog_util.dart +++ b/lib/utils/dialog_util.dart @@ -251,7 +251,7 @@ Future showConfettiDialog({ ); } -showTextInputDialog( +Future showTextInputDialog( BuildContext context, { required String title, String? body,