From c270999febd6032029e62b743c80c00e124eee09 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 27 Aug 2024 04:00:49 +0530 Subject: [PATCH 1/2] feat: Hand Raise sorting based on Time --- .../lib/src/meeting/meeting_store.dart | 32 +++++++++++ .../participants_bottom_sheet.dart | 53 +++++++++++-------- .../hmssdk_flutter/example/ios/Podfile.lock | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- 5 files changed, 67 insertions(+), 24 deletions(-) diff --git a/packages/hms_room_kit/lib/src/meeting/meeting_store.dart b/packages/hms_room_kit/lib/src/meeting/meeting_store.dart index a3730dd64..1abcbcf15 100644 --- a/packages/hms_room_kit/lib/src/meeting/meeting_store.dart +++ b/packages/hms_room_kit/lib/src/meeting/meeting_store.dart @@ -666,16 +666,45 @@ class MeetingStore extends ChangeNotifier void toggleLocalPeerHandRaise() { if (isRaisedHand) { _hmsSDKInteractor.lowerLocalPeerHand(hmsActionResultListener: this); + resetTimestampWhenHandDown(); } else { _hmsSDKInteractor.raiseLocalPeerHand(hmsActionResultListener: this); + setTimestampWhenHandRaise(); } } + void setTimestampWhenHandRaise() { + int currentTime = DateTime.now().millisecondsSinceEpoch; + log("Vkohli Setting timestamp for hand raise $currentTime"); + _hmsSDKInteractor.changeMetadata( + metadata: + "{\"isBRBOn\":false,\"prevRole\":\"$previousRole\",\"handRaisedAt\":${currentTime}}", + hmsActionResultListener: this); + } + + void resetTimestampWhenHandDown() { + _hmsSDKInteractor.changeMetadata( + metadata: "{\"isBRBOn\":false,\"prevRole\":\"$previousRole\"}", + hmsActionResultListener: this); + } + void lowerRemotePeerHand(HMSPeer forPeer) { _hmsSDKInteractor.lowerRemotePeerHand( forPeer: forPeer, hmsActionResultListener: this); } + int _getTimestampFromPeerMetadata(String? metadata) { + if(metadata == null) { + return 0; + } + try { + Map metadataMap = jsonDecode(metadata); + return metadataMap["handRaisedAt"]; + } catch (e) { + return 0; + } + } + bool isBRB = false; void changeMetadataBRB() { @@ -1604,6 +1633,9 @@ class MeetingStore extends ChangeNotifier (handDownPeer) => handDownPeer.peer.peerId == peer.peerId); participantsInMeetingMap[peer.role.name]?[index].updatePeer(peer); } + participantsInMeetingMap["Hand Raised"]?.sort((a, b) { + return _getTimestampFromPeerMetadata(a.peer.metadata).compareTo(_getTimestampFromPeerMetadata(b.peer.metadata)); + }); notifyListeners(); } else if (peerUpdate == HMSPeerUpdate.metadataChanged) { participantsInMeetingMap[peer.role.name]?[index].updatePeer(peer); diff --git a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart index 34cbf292d..fddf6cc16 100644 --- a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart +++ b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart @@ -69,6 +69,10 @@ class _ParticipantsBottomSheetState extends State { ); } + bool isHandRaisedRow(String role) { + return role == "Hand Raised"; + } + Widget _kebabMenu(HMSPeer peer) { final meetingStore = context.read(); PeerTrackNode? peerTrackNode; @@ -410,12 +414,13 @@ class _ParticipantsBottomSheetState extends State { .keys .elementAt(index); return Selector?>>( - selector: (_, meetingStore) => Tuple2( + Tuple3?, String>>( + selector: (_, meetingStore) => Tuple3( meetingStore .participantsInMeetingMap[role]?.length ?? 0, - meetingStore.participantsInMeetingMap[role]), + meetingStore.participantsInMeetingMap[role], + role), builder: (_, participantsPerRole, __) { return (participantsPerRole.item2?.isNotEmpty ?? false) @@ -458,7 +463,9 @@ class _ParticipantsBottomSheetState extends State { null ? 0 : (participantsPerRole.item1) * - 54, + (isHandRaisedRow(role) + ? 60 + : 54), child: Center( child: ListView.builder( physics: @@ -538,15 +545,18 @@ class _ParticipantsBottomSheetState extends State { isSIPPeer, __) { return isSIPPeer - ? CircleAvatar( - radius: 16, - backgroundColor: HMSThemeColors.surfaceBright, - child: SvgPicture.asset( - "packages/hms_room_kit/lib/src/assets/icons/sip_call.svg", - height: 12, - width: 12, - colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn), - )) + ? Padding( + padding: const EdgeInsets.only(right:4.0), + child: CircleAvatar( + radius: 12, + backgroundColor: HMSThemeColors.surfaceDefault, + child: SvgPicture.asset( + "packages/hms_room_kit/lib/src/assets/icons/sip_call.svg", + height: 12, + width: 12, + colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn), + )), + ) : const SizedBox(); }, selector: (_, participantsStore) => @@ -560,16 +570,17 @@ class _ParticipantsBottomSheetState extends State { participantsStore.peer.networkQuality?.quality ?? -1, participantsStore.peer.type != HMSPeerType.sip), builder: (_, participantData, __) { - return participantData.item1 != -1 && participantData.item1 < 3 && participantData.item2 + return + participantData.item1 != -1 && participantData.item1 < 3 && participantData.item2 ? Padding( - padding: const EdgeInsets.only(right: 16.0), + padding: const EdgeInsets.only(right: 4.0), child: CircleAvatar( - radius: 16, + radius: 12, backgroundColor: HMSThemeColors.surfaceDefault, child: SvgPicture.asset( "packages/hms_room_kit/lib/src/assets/icons/network_${participantData.item1}.svg", - height: 16, - width: 16, + height: 12, + width: 12, ), ), ) @@ -588,12 +599,12 @@ class _ParticipantsBottomSheetState extends State { ? Padding( padding: const EdgeInsets.only(right: 16.0), child: CircleAvatar( - radius: 16, + radius: 12, backgroundColor: HMSThemeColors.surfaceDefault, child: SvgPicture.asset( "packages/hms_room_kit/lib/src/assets/icons/hand_outline.svg", - height: 16, - width: 16, + height: 12, + width: 12, colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn), ), ), diff --git a/packages/hmssdk_flutter/example/ios/Podfile.lock b/packages/hmssdk_flutter/example/ios/Podfile.lock index 56ece5a0b..c7f975b7c 100644 --- a/packages/hmssdk_flutter/example/ios/Podfile.lock +++ b/packages/hmssdk_flutter/example/ios/Podfile.lock @@ -303,7 +303,7 @@ SPEC CHECKSUMS: FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_foreground_task: 21ef182ab0a29a3005cc72cd70e5f45cb7f7f817 GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleMLKit: 2bd0dc6253c4d4f227aad460f69215a504b2980e diff --git a/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/project.pbxproj index fc0c44fb7..37fb2667c 100644 --- a/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -248,7 +248,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1340; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = 100ms; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a6b826db2..5e31d3d34 100644 --- a/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/hmssdk_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ Date: Mon, 26 Aug 2024 22:33:24 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A4=96=20Automated=20Format=20and=20F?= =?UTF-8?q?ix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/src/meeting/meeting_store.dart | 5 ++-- .../participants_bottom_sheet.dart | 25 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/hms_room_kit/lib/src/meeting/meeting_store.dart b/packages/hms_room_kit/lib/src/meeting/meeting_store.dart index 1abcbcf15..bebe8531d 100644 --- a/packages/hms_room_kit/lib/src/meeting/meeting_store.dart +++ b/packages/hms_room_kit/lib/src/meeting/meeting_store.dart @@ -694,7 +694,7 @@ class MeetingStore extends ChangeNotifier } int _getTimestampFromPeerMetadata(String? metadata) { - if(metadata == null) { + if (metadata == null) { return 0; } try { @@ -1634,7 +1634,8 @@ class MeetingStore extends ChangeNotifier participantsInMeetingMap[peer.role.name]?[index].updatePeer(peer); } participantsInMeetingMap["Hand Raised"]?.sort((a, b) { - return _getTimestampFromPeerMetadata(a.peer.metadata).compareTo(_getTimestampFromPeerMetadata(b.peer.metadata)); + return _getTimestampFromPeerMetadata(a.peer.metadata) + .compareTo(_getTimestampFromPeerMetadata(b.peer.metadata)); }); notifyListeners(); } else if (peerUpdate == HMSPeerUpdate.metadataChanged) { diff --git a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart index fddf6cc16..a1ac8375a 100644 --- a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart +++ b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/participants_bottom_sheet.dart @@ -546,17 +546,17 @@ class _ParticipantsBottomSheetState extends State { __) { return isSIPPeer ? Padding( - padding: const EdgeInsets.only(right:4.0), - child: CircleAvatar( - radius: 12, - backgroundColor: HMSThemeColors.surfaceDefault, - child: SvgPicture.asset( - "packages/hms_room_kit/lib/src/assets/icons/sip_call.svg", - height: 12, - width: 12, - colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn), - )), - ) + padding: const EdgeInsets.only(right: 4.0), + child: CircleAvatar( + radius: 12, + backgroundColor: HMSThemeColors.surfaceDefault, + child: SvgPicture.asset( + "packages/hms_room_kit/lib/src/assets/icons/sip_call.svg", + height: 12, + width: 12, + colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn), + )), + ) : const SizedBox(); }, selector: (_, participantsStore) => @@ -570,8 +570,7 @@ class _ParticipantsBottomSheetState extends State { participantsStore.peer.networkQuality?.quality ?? -1, participantsStore.peer.type != HMSPeerType.sip), builder: (_, participantData, __) { - return - participantData.item1 != -1 && participantData.item1 < 3 && participantData.item2 + return participantData.item1 != -1 && participantData.item1 < 3 && participantData.item2 ? Padding( padding: const EdgeInsets.only(right: 4.0), child: CircleAvatar(