@100mslive/react-native-room-kit 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +5 -6
  2. package/lib/commonjs/HMSContainer.js +26 -5
  3. package/lib/commonjs/HMSContainer.js.map +1 -1
  4. package/lib/commonjs/HMSRoomSetup.js +2 -7
  5. package/lib/commonjs/HMSRoomSetup.js.map +1 -1
  6. package/lib/commonjs/components/GridView.js +9 -4
  7. package/lib/commonjs/components/GridView.js.map +1 -1
  8. package/lib/commonjs/components/Meeting.js +1 -0
  9. package/lib/commonjs/components/Meeting.js.map +1 -1
  10. package/lib/commonjs/components/OverlayContainer.js +6 -3
  11. package/lib/commonjs/components/OverlayContainer.js.map +1 -1
  12. package/lib/commonjs/components/OverlayedViews.js +5 -2
  13. package/lib/commonjs/components/OverlayedViews.js.map +1 -1
  14. package/lib/commonjs/components/PeerVideoTile/HMSPinchGesture.js +18 -87
  15. package/lib/commonjs/components/PeerVideoTile/HMSPinchGesture.js.map +1 -1
  16. package/lib/commonjs/components/PeerVideoTile/PeerVideoTileView.js +3 -1
  17. package/lib/commonjs/components/PeerVideoTile/PeerVideoTileView.js.map +1 -1
  18. package/lib/commonjs/components/TilesContainer.js +1 -1
  19. package/lib/commonjs/components/WebrtcView.js +14 -6
  20. package/lib/commonjs/components/WebrtcView.js.map +1 -1
  21. package/lib/commonjs/hooks-util.js +13 -4
  22. package/lib/commonjs/hooks-util.js.map +1 -1
  23. package/lib/commonjs/redux/reducers/hmsStates.js +21 -8
  24. package/lib/commonjs/redux/reducers/hmsStates.js.map +1 -1
  25. package/lib/commonjs/types.js +3 -2
  26. package/lib/commonjs/types.js.map +1 -1
  27. package/lib/module/HMSContainer.js +23 -3
  28. package/lib/module/HMSContainer.js.map +1 -1
  29. package/lib/module/HMSRoomSetup.js +2 -7
  30. package/lib/module/HMSRoomSetup.js.map +1 -1
  31. package/lib/module/components/GridView.js +10 -5
  32. package/lib/module/components/GridView.js.map +1 -1
  33. package/lib/module/components/Meeting.js +2 -1
  34. package/lib/module/components/Meeting.js.map +1 -1
  35. package/lib/module/components/OverlayContainer.js +5 -3
  36. package/lib/module/components/OverlayContainer.js.map +1 -1
  37. package/lib/module/components/OverlayedViews.js +5 -2
  38. package/lib/module/components/OverlayedViews.js.map +1 -1
  39. package/lib/module/components/PeerVideoTile/HMSPinchGesture.js +18 -87
  40. package/lib/module/components/PeerVideoTile/HMSPinchGesture.js.map +1 -1
  41. package/lib/module/components/PeerVideoTile/PeerVideoTileView.js +3 -1
  42. package/lib/module/components/PeerVideoTile/PeerVideoTileView.js.map +1 -1
  43. package/lib/module/components/TilesContainer.js +1 -1
  44. package/lib/module/components/WebrtcView.js +15 -7
  45. package/lib/module/components/WebrtcView.js.map +1 -1
  46. package/lib/module/hooks-util.js +12 -4
  47. package/lib/module/hooks-util.js.map +1 -1
  48. package/lib/module/redux/reducers/hmsStates.js +21 -8
  49. package/lib/module/redux/reducers/hmsStates.js.map +1 -1
  50. package/lib/module/types.js +3 -2
  51. package/lib/module/types.js.map +1 -1
  52. package/lib/typescript/HMSContainer.d.ts +1 -1
  53. package/lib/typescript/HMSContainer.d.ts.map +1 -1
  54. package/lib/typescript/HMSRoomSetup.d.ts.map +1 -1
  55. package/lib/typescript/components/GridView.d.ts.map +1 -1
  56. package/lib/typescript/components/Meeting.d.ts.map +1 -1
  57. package/lib/typescript/components/OverlayContainer.d.ts +5 -1
  58. package/lib/typescript/components/OverlayContainer.d.ts.map +1 -1
  59. package/lib/typescript/components/OverlayedViews.d.ts +2 -1
  60. package/lib/typescript/components/OverlayedViews.d.ts.map +1 -1
  61. package/lib/typescript/components/PeerVideoTile/HMSPinchGesture.d.ts.map +1 -1
  62. package/lib/typescript/components/PeerVideoTile/PeerVideoTileView.d.ts.map +1 -1
  63. package/lib/typescript/components/WebrtcView.d.ts.map +1 -1
  64. package/lib/typescript/hooks-util.d.ts +1 -0
  65. package/lib/typescript/hooks-util.d.ts.map +1 -1
  66. package/lib/typescript/redux/reducers/hmsStates.d.ts.map +1 -1
  67. package/lib/typescript/types.d.ts +3 -2
  68. package/lib/typescript/types.d.ts.map +1 -1
  69. package/package.json +2 -2
  70. package/src/HMSContainer.tsx +26 -5
  71. package/src/HMSRoomSetup.tsx +2 -7
  72. package/src/components/GridView.tsx +14 -5
  73. package/src/components/Meeting.tsx +3 -0
  74. package/src/components/OverlayContainer.tsx +12 -3
  75. package/src/components/OverlayedViews.tsx +7 -3
  76. package/src/components/PeerVideoTile/HMSPinchGesture.tsx +28 -71
  77. package/src/components/PeerVideoTile/PeerVideoTileView.tsx +4 -1
  78. package/src/components/TilesContainer.tsx +1 -1
  79. package/src/components/WebrtcView.tsx +27 -9
  80. package/src/hooks-util.ts +15 -3
  81. package/src/redux/reducers/hmsStates.ts +36 -13
  82. package/src/types.ts +1 -0
@@ -28,6 +28,7 @@ import {
28
28
  import { useHMSRoomStyleSheet } from '../../hooks-util';
29
29
  import { HMSFullScreenButton } from './HMSFullScreenButton';
30
30
  import { TestIds } from '../../utils/constants';
31
+ import { useIsLandscapeOrientation } from '../../utils/dimension';
31
32
 
32
33
  export interface PeerVideoTileViewProps {
33
34
  peerTrackNode: PeerTrackNode;
@@ -146,6 +147,8 @@ export const _PeerVideoTileView = React.forwardRef<
146
147
  !canTakeActionOnPeer || // If local peer can't take action on peer, Or
147
148
  !allowedToPublish; // If local peer can't publish tracks
148
149
 
150
+ const isLandscapeOrientation = useIsLandscapeOrientation();
151
+
149
152
  return (
150
153
  <View style={styles.container}>
151
154
  <AvatarView
@@ -181,7 +184,7 @@ export const _PeerVideoTileView = React.forwardRef<
181
184
 
182
185
  {/* Handling Peer Audio Mute indicator */}
183
186
  {screenShareTile && showingVideoTrack ? (
184
- isPipModeActive ? null : (
187
+ isPipModeActive || isLandscapeOrientation ? null : (
185
188
  <HMSFullScreenButton peerTrackNode={peerTrackNode} />
186
189
  )
187
190
  ) : peerCanPublishAudio ? (
@@ -55,7 +55,7 @@ const _TilesContainer: React.FC<TilesContainerProps> = ({
55
55
  ? 'row'
56
56
  : 'column',
57
57
  },
58
- { width: Dimensions.get('window').width - left - right },
58
+ { width: Dimensions.get('window').width + left + right },
59
59
  ]}
60
60
  >
61
61
  {peerTrackNodes.length <= 3 ? (
@@ -1,7 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { useSelector } from 'react-redux';
3
3
  import {
4
- SafeAreaView,
5
4
  useSafeAreaFrame,
6
5
  useSafeAreaInsets,
7
6
  } from 'react-native-safe-area-context';
@@ -25,6 +24,7 @@ import { OverlayContainer } from './OverlayContainer';
25
24
  import { OverlayedViews } from './OverlayedViews';
26
25
  import { useFooterHeight } from './Footer';
27
26
  import { useHeaderHeight } from './Header';
27
+ import { View } from 'react-native';
28
28
 
29
29
  interface WebrtcViewProps {
30
30
  offset: SharedValue<number>;
@@ -72,21 +72,36 @@ export const WebrtcView = React.forwardRef<GridViewRefAttrs, WebrtcViewProps>(
72
72
  !state.app.localPeerTrackNode && pairedPeers.length === 0
73
73
  );
74
74
 
75
+ const fullHeight = height - top - (isPortrait ? bottom : 0);
76
+ const smallHeight = isPortrait
77
+ ? height - headerHeight - footerHeight
78
+ : height;
79
+
75
80
  const animatedStyles = useAnimatedStyle(() => {
81
+ return {
82
+ height: interpolate(offset.value, [0, 1], [fullHeight, smallHeight]),
83
+ };
84
+ }, [fullHeight, smallHeight]);
85
+
86
+ const headerPlaceholderAnimatedStyles = useAnimatedStyle(() => {
76
87
  return {
77
88
  height: interpolate(
78
89
  offset.value,
79
90
  [0, 1],
80
- [height - top - bottom, height - headerHeight - footerHeight]
91
+ [top, isPortrait ? headerHeight : top]
81
92
  ),
82
93
  };
83
- }, [height, top, bottom, footerHeight, headerHeight]);
94
+ }, [headerHeight, top, isPortrait]);
84
95
 
85
- const headerPlaceholderAnimatedStyles = useAnimatedStyle(() => {
96
+ const overlayedAnimatedStyles = useAnimatedStyle(() => {
86
97
  return {
87
- height: interpolate(offset.value, [0, 1], [top, headerHeight]),
98
+ bottom: interpolate(
99
+ offset.value,
100
+ [0, 1],
101
+ [!isPortrait ? bottom : 0, 0]
102
+ ),
88
103
  };
89
- }, [headerHeight, top]);
104
+ }, [isPortrait, bottom]);
90
105
 
91
106
  if (isPipModeActive) {
92
107
  return (
@@ -104,7 +119,7 @@ export const WebrtcView = React.forwardRef<GridViewRefAttrs, WebrtcViewProps>(
104
119
  }
105
120
 
106
121
  return (
107
- <SafeAreaView edges={['left', 'right']} style={{ flex: 1 }}>
122
+ <View style={{ flex: 1 }}>
108
123
  <Animated.View style={headerPlaceholderAnimatedStyles} />
109
124
 
110
125
  <Animated.View style={animatedStyles}>
@@ -123,10 +138,13 @@ export const WebrtcView = React.forwardRef<GridViewRefAttrs, WebrtcViewProps>(
123
138
  />
124
139
  )}
125
140
 
126
- <OverlayedViews offset={offset} />
141
+ <OverlayedViews
142
+ animatedStyle={overlayedAnimatedStyles}
143
+ offset={offset}
144
+ />
127
145
  </OverlayContainer>
128
146
  </Animated.View>
129
- </SafeAreaView>
147
+ </View>
130
148
  );
131
149
  }
132
150
  );
package/src/hooks-util.ts CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  useHmsViewsResolutionsState,
22
22
  setSoftInputMode,
23
23
  getSoftInputMode,
24
+ WindowController,
24
25
  // useHMSPeerUpdates,
25
26
  } from '@100mslive/react-native-hms';
26
27
  import type { Chat as ChatConfig } from '@100mslive/types-prebuilt/elements/chat';
@@ -2149,18 +2150,17 @@ export const useLeaveMethods = () => {
2149
2150
  const onLeave = reduxStore.getState().user.onLeave;
2150
2151
 
2151
2152
  if (typeof onLeave === 'function') {
2153
+ dispatch(changeMeetingState(MeetingState.EXITED));
2152
2154
  onLeave(reason);
2153
- dispatch(clearStore());
2154
2155
  } else if (
2155
2156
  navigation &&
2156
2157
  typeof navigation.canGoBack === 'function' &&
2157
2158
  navigation.canGoBack()
2158
2159
  ) {
2160
+ dispatch(changeMeetingState(MeetingState.EXITED));
2159
2161
  navigation.goBack();
2160
- dispatch(clearStore());
2161
2162
  } else {
2162
2163
  // Otherwise default action is to show "Meeting Ended" screen
2163
- dispatch(clearStore()); // TODO: We need different clearStore for MeetingEnded
2164
2164
  dispatch(changeMeetingState(MeetingState.MEETING_ENDED));
2165
2165
  }
2166
2166
  } catch (e) {
@@ -2536,6 +2536,18 @@ export const useBackButtonPress = () => {
2536
2536
  }, [handleBackPress, handleModalVisibleType]);
2537
2537
  };
2538
2538
 
2539
+ export const useLandscapeImmersiveMode = () => {
2540
+ const isLandscapeOrientation = useIsLandscapeOrientation();
2541
+
2542
+ useEffect(() => {
2543
+ if (isLandscapeOrientation) {
2544
+ WindowController.hideSystemBars();
2545
+
2546
+ return WindowController.showSystemBars;
2547
+ }
2548
+ }, [isLandscapeOrientation]);
2549
+ };
2550
+
2539
2551
  export const useSavePropsToStore = (
2540
2552
  props: HMSPrebuiltProps,
2541
2553
  dispatch: AppDispatch
@@ -177,20 +177,40 @@ const hmsStatesReducer = (
177
177
  let updatedGroupedParticipants = state.groupedParticipants;
178
178
 
179
179
  if (action.localPeer !== null) {
180
- const savedLocalPeer = Object.values(state.groupedParticipants)
181
- .flat()
182
- .find(
183
- (participant) => participant.peerID === action.localPeer?.peerID
184
- );
180
+ let previousRoleName: HMSRole['name'] | null = null;
181
+ let savedLocalPeer: HMSLocalPeer | HMSPeer | null = null;
182
+
183
+ for (const groupName in state.groupedParticipants) {
184
+ if (
185
+ Object.prototype.hasOwnProperty.call(
186
+ state.groupedParticipants,
187
+ groupName
188
+ )
189
+ ) {
190
+ const participantsList = state.groupedParticipants[groupName];
191
+
192
+ if (Array.isArray(participantsList)) {
193
+ const result = participantsList.find(
194
+ (participant) => participant.peerID === action.localPeer?.peerID
195
+ );
196
+
197
+ if (result) {
198
+ previousRoleName = groupName;
199
+ savedLocalPeer = result;
200
+ break;
201
+ }
202
+ }
203
+ }
204
+ }
185
205
 
186
206
  // update peer or check if role change happened
187
207
  if (savedLocalPeer) {
188
- const previousRoleName = savedLocalPeer.role?.name!;
189
208
  const currentRoleName = action.localPeer.role?.name!;
190
209
 
191
- const roleChanged = previousRoleName !== currentRoleName;
210
+ const roleChanged =
211
+ previousRoleName && previousRoleName !== currentRoleName;
192
212
 
193
- if (roleChanged) {
213
+ if (roleChanged && previousRoleName) {
194
214
  const previousList = state.groupedParticipants[previousRoleName];
195
215
  const currentList = state.groupedParticipants[currentRoleName];
196
216
 
@@ -405,7 +425,12 @@ const hmsStatesReducer = (
405
425
  let previousRoleName: HMSRole['name'] | null = null;
406
426
 
407
427
  for (const groupName in state.groupedParticipants) {
408
- if (Object.prototype.hasOwnProperty.call(state.groupedParticipants, groupName)) {
428
+ if (
429
+ Object.prototype.hasOwnProperty.call(
430
+ state.groupedParticipants,
431
+ groupName
432
+ )
433
+ ) {
409
434
  const participantsList = state.groupedParticipants[groupName];
410
435
 
411
436
  if (Array.isArray(participantsList)) {
@@ -460,9 +485,7 @@ const hmsStatesReducer = (
460
485
  ...state.groupedParticipants,
461
486
  [currentRoleName]: Array.isArray(currentList)
462
487
  ? currentList.map((p) =>
463
- p.peerID === action.participant.peerID
464
- ? action.participant
465
- : p
488
+ p.peerID === action.participant.peerID ? action.participant : p
466
489
  )
467
490
  : [action.participant],
468
491
  },
@@ -473,7 +496,7 @@ const hmsStatesReducer = (
473
496
  ...state,
474
497
  groupedParticipants: {
475
498
  ...state.groupedParticipants,
476
- [action.roleName]: action.participants
499
+ [action.roleName]: action.participants,
477
500
  },
478
501
  };
479
502
  }
package/src/types.ts CHANGED
@@ -5,6 +5,7 @@ export enum MeetingState {
5
5
  NOT_JOINED,
6
6
  IN_PREVIEW,
7
7
  IN_MEETING,
8
+ EXITED,
8
9
  MEETING_ENDED,
9
10
  ERROR,
10
11
  }