diff --git a/lib/forez/ui/screens/forez_directory_screen.dart b/lib/forez/ui/screens/forez_directory_screen.dart index 3926961..4c9a0da 100644 --- a/lib/forez/ui/screens/forez_directory_screen.dart +++ b/lib/forez/ui/screens/forez_directory_screen.dart @@ -3,6 +3,7 @@ import 'package:comunic/helpers/groups_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/lists/group_members_list.dart'; import 'package:comunic/lists/users_list.dart'; +import 'package:comunic/models/group.dart'; import 'package:comunic/models/group_membership.dart'; import 'package:comunic/models/user.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; @@ -10,13 +11,15 @@ import 'package:comunic/ui/widgets/async_screen_widget.dart'; import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/conversations_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; +import 'package:comunic/utils/log_utils.dart'; +import 'package:comunic/utils/ui_utils.dart'; import 'package:flutter/material.dart'; /// Forez directory screen /// /// @author Pierre Hubert -enum _PopupMenuActions { PRIVATE_CONVERSATION } +enum _PopupMenuActions { PRIVATE_CONVERSATION, CANCEL_INVITATION } class ForezDirectoryScreen extends StatefulWidget { @override @@ -52,10 +55,20 @@ class _ForezDirectoryScreenState extends State { ); void _doPopupMenuAction(_PopupMenuActions action, User user) async { - switch (action) { - case _PopupMenuActions.PRIVATE_CONVERSATION: - openPrivateConversation(context, user.id); - break; + try { + switch (action) { + case _PopupMenuActions.PRIVATE_CONVERSATION: + openPrivateConversation(context, user.id); + break; + + case _PopupMenuActions.CANCEL_INVITATION: + await GroupsHelper.cancelInvitation(forezGroup.id, user.id); + _key.currentState.refresh(); + break; + } + } catch (e, s) { + logError(e, s); + snack(context, tr("Error while processing action!")); } } } @@ -89,6 +102,14 @@ class _ForezMemberTile extends StatelessWidget { PopupMenuItem( child: Text(tr("Private conversation")), value: _PopupMenuActions.PRIVATE_CONVERSATION, - ), - ]; + ) + ]..addAll(member.level == GroupMembershipLevel.INVITED && + forezGroup.isAtLeastModerator + ? [ + PopupMenuItem( + child: Text(tr("Cancel invitation")), + value: _PopupMenuActions.CANCEL_INVITATION, + ), + ] + : []); }