فهرست منبع

Support for removing participant from manage participant

Neeraj Gupta 2 سال پیش
والد
کامیت
5be75c7878
2فایلهای تغییر یافته به همراه40 افزوده شده و 5 حذف شده
  1. 23 0
      lib/ui/actions/collection/collection_sharing_actions.dart
  2. 17 5
      lib/ui/sharing/manage_album_participant.dart

+ 23 - 0
lib/ui/actions/collection/collection_sharing_actions.dart

@@ -6,6 +6,7 @@ import 'package:photos/services/collections_service.dart';
 import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/payment/subscription.dart';
 import 'package:photos/utils/dialog_util.dart';
+import 'package:photos/utils/toast_util.dart';
 
 class CollectionSharingActions {
   final Logger _logger = Logger((CollectionSharingActions).toString());
@@ -55,6 +56,28 @@ class CollectionSharingActions {
     }
   }
 
+  // removeParticipant remove the user from a share album
+  Future<bool> removeParticipant(
+    BuildContext context,
+    Collection collection,
+    User user,
+  ) async {
+    final dialog = createProgressDialog(context, "Please wait...");
+    await dialog.show();
+    try {
+      await CollectionsService.instance.unshare(collection.id, user.email);
+      collection.sharees!.removeWhere((u) => u!.email == user.email);
+      await dialog.hide();
+      showToast(context, "Stopped sharing with " + user.email + ".");
+      return true;
+    } catch (e, s) {
+      Logger("EmailItemWidget").severe(e, s);
+      await dialog.hide();
+      await showGenericErrorDialog(context);
+      return false;
+    }
+  }
+
   void _showUnSupportedAlert(BuildContext context) {
     final AlertDialog alert = AlertDialog(
       title: const Text("Sorry"),

+ 17 - 5
lib/ui/sharing/manage_album_participant.dart

@@ -1,7 +1,9 @@
 import 'package:flutter/material.dart';
 import 'package:photos/models/collection.dart';
+import 'package:photos/services/collections_service.dart';
 import 'package:photos/theme/colors.dart';
 import 'package:photos/theme/ente_theme.dart';
+import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
 import 'package:photos/ui/components/captioned_text_widget.dart';
 import 'package:photos/ui/components/divider_widget.dart';
 import 'package:photos/ui/components/menu_item_widget.dart';
@@ -26,6 +28,9 @@ class ManageIndividualParticipant extends StatefulWidget {
 
 class _ManageIndividualParticipantState
     extends State<ManageIndividualParticipant> {
+  final CollectionSharingActions sharingActions =
+      CollectionSharingActions(CollectionsService.instance);
+
   @override
   Widget build(BuildContext context) {
     final colorScheme = getEnteColorScheme(context);
@@ -57,7 +62,7 @@ class _ManageIndividualParticipantState
                 ],
               ),
             ),
-            const SizedBox(height: 0),
+            const SizedBox(height: 12),
             const MenuSectionTitle(title: "Added as"),
             MenuItemWidget(
               captionedTextWidget: const CaptionedTextWidget(
@@ -68,7 +73,7 @@ class _ManageIndividualParticipantState
               pressedColor: getEnteColorScheme(context).fillFaint,
               trailingIcon: widget.user.isCollaborator ? Icons.check : null,
               onTap: () async {
-                showShortToast(context, "yet to implement");
+                showShortToast(context, "coming soon!");
               },
               isBottomBorderRadiusRemoved: true,
             ),
@@ -77,7 +82,7 @@ class _ManageIndividualParticipantState
               bgColor: getEnteColorScheme(context).blurStrokeFaint,
             ),
             MenuItemWidget(
-              captionedTextWidget: CaptionedTextWidget(
+              captionedTextWidget: const CaptionedTextWidget(
                 title: " Viewer",
               ),
               leadingIcon: Icons.photo,
@@ -85,7 +90,7 @@ class _ManageIndividualParticipantState
               pressedColor: getEnteColorScheme(context).fillFaint,
               trailingIcon: widget.user.isViewer ? Icons.check : null,
               onTap: () async {
-                showShortToast(context, "yet to implement");
+                // showShortToast(context, "yet to implement");
               },
               isTopBorderRadiusRemoved: true,
             ),
@@ -106,7 +111,14 @@ class _ManageIndividualParticipantState
               menuItemColor: getEnteColorScheme(context).fillFaint,
               pressedColor: getEnteColorScheme(context).fillFaint,
               onTap: () async {
-                showShortToast(context, "yet to implement");
+                final result = await sharingActions.removeParticipant(
+                  context,
+                  widget.collection,
+                  widget.user,
+                );
+                if (result && mounted) {
+                  Navigator.of(context).pop(true);
+                }
               },
             )
           ],