瀏覽代碼

Used new TextInputDialog for renaming album

ashilkn 2 年之前
父節點
當前提交
da3088eab1
共有 2 個文件被更改,包括 7 次插入30 次删除
  1. 6 29
      lib/ui/viewer/gallery/gallery_app_bar_widget.dart
  2. 1 1
      lib/utils/dialog_util.dart

+ 6 - 29
lib/ui/viewer/gallery/gallery_app_bar_widget.dart

@@ -111,10 +111,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
     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<GalleryAppBarWidget> {
             setState(() {});
           }
         } catch (e) {
-          showGenericErrorDialog(context: context);
+          rethrow;
         }
       },
     );
-    // final result = await showDialog<String>(
-    //   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<dynamic> _leaveAlbum(BuildContext context) async {

+ 1 - 1
lib/utils/dialog_util.dart

@@ -251,7 +251,7 @@ Future<ButtonAction?> showConfettiDialog<T>({
   );
 }
 
-showTextInputDialog(
+Future<ButtonAction?> showTextInputDialog(
   BuildContext context, {
   required String title,
   String? body,