Quellcode durchsuchen

Update remove from album dialog

Neeraj Gupta vor 2 Jahren
Ursprung
Commit
6c7ca791ba

+ 33 - 22
lib/ui/actions/collection/collection_sharing_actions.dart

@@ -143,33 +143,44 @@ class CollectionActions {
   }
 
   // removeParticipant remove the user from a share album
-  Future<bool?> removeParticipant(
+  Future<bool> removeParticipant(
     BuildContext context,
     Collection collection,
     User user,
   ) async {
-    final result = await showChoiceDialog(
-      context,
-      title: "Remove",
-      body: "${user.email} will be removed",
-      firstButtonLabel: "Yes, remove",
-      firstButtonOnTap: () async {
-        try {
-          final newSharees = await CollectionsService.instance
-              .unshare(collection.id, user.email);
-          collection.updateSharees(newSharees);
-        } catch (e, s) {
-          Logger("EmailItemWidget").severe(e, s);
-          rethrow;
-        }
-      },
+    final ButtonAction? result = await showActionSheet(
+      context: context,
+      buttons: [
+        ButtonWidget(
+          buttonType: ButtonType.critical,
+          isInAlert: true,
+          shouldStickToDarkTheme: true,
+          buttonAction: ButtonAction.first,
+          shouldSurfaceExecutionStates: true,
+          labelText: "Yes, remove",
+          onTap: () async {
+            final newSharees = await CollectionsService.instance
+                .unshare(collection.id, user.email);
+            collection.updateSharees(newSharees);
+          },
+        ),
+        const ButtonWidget(
+          buttonType: ButtonType.secondary,
+          buttonAction: ButtonAction.cancel,
+          isInAlert: true,
+          shouldStickToDarkTheme: true,
+          labelText: "Cancel",
+        )
+      ],
+      title: "Remove?",
+      body: '${user.email} will be removed from this shared album\n\nAny '
+          'photos added by them will also be removed from the album',
     );
-    if (result == ButtonAction.error) {
-      await showGenericErrorDialog(context: context);
-      return false;
-    }
-    if (result == ButtonAction.first) {
-      return true;
+    if (result != null) {
+      if (result == ButtonAction.error) {
+        showGenericErrorDialog(context: context);
+      }
+      return result == ButtonAction.first;
     } else {
       return false;
     }

+ 1 - 1
lib/ui/sharing/manage_album_participant.dart

@@ -146,7 +146,7 @@ class _ManageIndividualParticipantState
                   widget.user,
                 );
 
-                if ((result ?? false) && mounted) {
+                if ((result) && mounted) {
                   Navigator.of(context).pop(true);
                 }
               },