From 3513cb18175b8feab58067a33b01a9b684db2f98 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Fri, 12 Jan 2024 12:27:03 +0530 Subject: [PATCH] Added remove peer functionality from message menu --- .../chat_utilities_bottom_sheet.dart | 37 ++++++++++++++++++- .../chat_widgets/recipient_selector_chip.dart | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_utilities_bottom_sheet.dart b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_utilities_bottom_sheet.dart index f492e66bd..358f53972 100644 --- a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_utilities_bottom_sheet.dart +++ b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_utilities_bottom_sheet.dart @@ -146,7 +146,9 @@ class _ChatUtilitiesBottomSheetState extends State { fontWeight: FontWeight.w600, textColor: HMSThemeColors.onSurfaceHighEmphasis)), - if (HMSRoomLayout.chatData?.realTimeControls?.canBlockUser ?? false) + if ((HMSRoomLayout.chatData?.realTimeControls?.canBlockUser ?? + false) && + !(widget.message.sender?.isLocal ?? true)) ListTile( horizontalTitleGap: 2, onTap: () async { @@ -171,6 +173,39 @@ class _ChatUtilitiesBottomSheetState extends State { letterSpacing: 0.1, fontWeight: FontWeight.w600, textColor: HMSThemeColors.alertErrorDefault)), + + if ((context + .read() + .localPeer + ?.role + .permissions + .removeOthers ?? + false) && + !(widget.message.sender?.isLocal ?? true)) + ListTile( + horizontalTitleGap: 2, + onTap: () async { + Navigator.pop(context); + if (widget.message.sender != null) { + context + .read() + .removePeerFromRoom(widget.message.sender!); + } + }, + contentPadding: EdgeInsets.zero, + leading: SvgPicture.asset( + "packages/hms_room_kit/lib/src/assets/icons/peer_remove.svg", + semanticsLabel: "fl_remove_peer", + height: 20, + width: 20, + colorFilter: ColorFilter.mode( + HMSThemeColors.alertErrorDefault, BlendMode.srcIn), + ), + title: HMSSubheadingText( + text: "Remove Participant", + letterSpacing: 0.1, + fontWeight: FontWeight.w600, + textColor: HMSThemeColors.alertErrorDefault)), ]), ), ), diff --git a/packages/hms_room_kit/lib/src/widgets/chat_widgets/recipient_selector_chip.dart b/packages/hms_room_kit/lib/src/widgets/chat_widgets/recipient_selector_chip.dart index 40afc8dd3..c39a78cb1 100644 --- a/packages/hms_room_kit/lib/src/widgets/chat_widgets/recipient_selector_chip.dart +++ b/packages/hms_room_kit/lib/src/widgets/chat_widgets/recipient_selector_chip.dart @@ -51,7 +51,7 @@ class _ReceipientSelectorChipState extends State { return GestureDetector( onTap: () => { if (!(HMSRoomLayout.chatData?.isPrivateChatEnabled ?? true) && - (HMSRoomLayout.chatData?.isPublicChatEnabled ?? false) || + (HMSRoomLayout.chatData?.isPublicChatEnabled ?? false) && (HMSRoomLayout.chatData?.rolesWhitelist.isEmpty ?? false)) {() {}} else