@100mslive/react-native-room-kit 1.1.2 → 1.1.3

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 (168) hide show
  1. package/lib/commonjs/HMSRoomSetup.js +13 -1
  2. package/lib/commonjs/HMSRoomSetup.js.map +1 -1
  3. package/lib/commonjs/Icons/Clock/assets/clock-vector.png +0 -0
  4. package/lib/commonjs/Icons/Clock/assets/clock-vector@2x.png +0 -0
  5. package/lib/commonjs/Icons/Clock/assets/clock-vector@3x.png +0 -0
  6. package/lib/commonjs/Icons/Clock/assets/clock.png +0 -0
  7. package/lib/commonjs/Icons/Clock/assets/clock@2x.png +0 -0
  8. package/lib/commonjs/Icons/Clock/assets/clock@3x.png +0 -0
  9. package/lib/commonjs/Icons/Clock/index.js +7 -2
  10. package/lib/commonjs/Icons/Clock/index.js.map +1 -1
  11. package/lib/commonjs/components/CreatePoll.js +3 -2
  12. package/lib/commonjs/components/CreatePoll.js.map +1 -1
  13. package/lib/commonjs/components/HLSView.js +15 -1
  14. package/lib/commonjs/components/HLSView.js.map +1 -1
  15. package/lib/commonjs/components/HMSPollsQuizzesNotification.js +1 -1
  16. package/lib/commonjs/components/HMSPollsQuizzesNotification.js.map +1 -1
  17. package/lib/commonjs/components/LeaderboardEntry.js +135 -0
  18. package/lib/commonjs/components/LeaderboardEntry.js.map +1 -0
  19. package/lib/commonjs/components/PollAndQuizSheetScreen.js +69 -0
  20. package/lib/commonjs/components/PollAndQuizSheetScreen.js.map +1 -0
  21. package/lib/commonjs/components/PollAndQuizVoting.js +133 -4
  22. package/lib/commonjs/components/PollAndQuizVoting.js.map +1 -1
  23. package/lib/commonjs/components/PollQuestions.js +104 -4
  24. package/lib/commonjs/components/PollQuestions.js.map +1 -1
  25. package/lib/commonjs/components/PollsAndQuizBottomSheet.js +9 -11
  26. package/lib/commonjs/components/PollsAndQuizBottomSheet.js.map +1 -1
  27. package/lib/commonjs/components/PollsAndQuizzesCard.js +1 -1
  28. package/lib/commonjs/components/PollsAndQuizzesCard.js.map +1 -1
  29. package/lib/commonjs/components/PollsAndQuizzesModalContent.js +26 -120
  30. package/lib/commonjs/components/PollsAndQuizzesModalContent.js.map +1 -1
  31. package/lib/commonjs/components/PollsConfigAndList.js +81 -4
  32. package/lib/commonjs/components/PollsConfigAndList.js.map +1 -1
  33. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js +7 -15
  34. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js.map +1 -1
  35. package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js +284 -0
  36. package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js.map +1 -0
  37. package/lib/commonjs/components/QuizLeaderboardScreen.js +279 -0
  38. package/lib/commonjs/components/QuizLeaderboardScreen.js.map +1 -0
  39. package/lib/commonjs/components/QuizLeaderboardSummary.js +195 -0
  40. package/lib/commonjs/components/QuizLeaderboardSummary.js.map +1 -0
  41. package/lib/commonjs/components/VoterParticipationSummary.js +46 -0
  42. package/lib/commonjs/components/VoterParticipationSummary.js.map +1 -0
  43. package/lib/commonjs/redux/actionTypes.js +7 -1
  44. package/lib/commonjs/redux/actionTypes.js.map +1 -1
  45. package/lib/commonjs/redux/actions/index.js +25 -5
  46. package/lib/commonjs/redux/actions/index.js.map +1 -1
  47. package/lib/commonjs/redux/reducers/polls.js +65 -5
  48. package/lib/commonjs/redux/reducers/polls.js.map +1 -1
  49. package/lib/commonjs/utils/hooks.js +107 -2
  50. package/lib/commonjs/utils/hooks.js.map +1 -1
  51. package/lib/module/HMSRoomSetup.js +13 -1
  52. package/lib/module/HMSRoomSetup.js.map +1 -1
  53. package/lib/module/Icons/Clock/assets/clock-vector.png +0 -0
  54. package/lib/module/Icons/Clock/assets/clock-vector@2x.png +0 -0
  55. package/lib/module/Icons/Clock/assets/clock-vector@3x.png +0 -0
  56. package/lib/module/Icons/Clock/assets/clock.png +0 -0
  57. package/lib/module/Icons/Clock/assets/clock@2x.png +0 -0
  58. package/lib/module/Icons/Clock/assets/clock@3x.png +0 -0
  59. package/lib/module/Icons/Clock/index.js +7 -2
  60. package/lib/module/Icons/Clock/index.js.map +1 -1
  61. package/lib/module/components/CreatePoll.js +4 -3
  62. package/lib/module/components/CreatePoll.js.map +1 -1
  63. package/lib/module/components/HLSView.js +17 -3
  64. package/lib/module/components/HLSView.js.map +1 -1
  65. package/lib/module/components/HMSPollsQuizzesNotification.js +2 -2
  66. package/lib/module/components/HMSPollsQuizzesNotification.js.map +1 -1
  67. package/lib/module/components/LeaderboardEntry.js +126 -0
  68. package/lib/module/components/LeaderboardEntry.js.map +1 -0
  69. package/lib/module/components/PollAndQuizSheetScreen.js +60 -0
  70. package/lib/module/components/PollAndQuizSheetScreen.js.map +1 -0
  71. package/lib/module/components/PollAndQuizVoting.js +135 -6
  72. package/lib/module/components/PollAndQuizVoting.js.map +1 -1
  73. package/lib/module/components/PollQuestions.js +107 -7
  74. package/lib/module/components/PollQuestions.js.map +1 -1
  75. package/lib/module/components/PollsAndQuizBottomSheet.js +11 -13
  76. package/lib/module/components/PollsAndQuizBottomSheet.js.map +1 -1
  77. package/lib/module/components/PollsAndQuizzesCard.js +2 -2
  78. package/lib/module/components/PollsAndQuizzesCard.js.map +1 -1
  79. package/lib/module/components/PollsAndQuizzesModalContent.js +28 -122
  80. package/lib/module/components/PollsAndQuizzesModalContent.js.map +1 -1
  81. package/lib/module/components/PollsConfigAndList.js +82 -5
  82. package/lib/module/components/PollsConfigAndList.js.map +1 -1
  83. package/lib/module/components/PreviousPollsAndQuizzesList.js +7 -15
  84. package/lib/module/components/PreviousPollsAndQuizzesList.js.map +1 -1
  85. package/lib/module/components/QuizLeaderboardEntriesScreen.js +275 -0
  86. package/lib/module/components/QuizLeaderboardEntriesScreen.js.map +1 -0
  87. package/lib/module/components/QuizLeaderboardScreen.js +270 -0
  88. package/lib/module/components/QuizLeaderboardScreen.js.map +1 -0
  89. package/lib/module/components/QuizLeaderboardSummary.js +186 -0
  90. package/lib/module/components/QuizLeaderboardSummary.js.map +1 -0
  91. package/lib/module/components/VoterParticipationSummary.js +37 -0
  92. package/lib/module/components/VoterParticipationSummary.js.map +1 -0
  93. package/lib/module/redux/actionTypes.js +7 -1
  94. package/lib/module/redux/actionTypes.js.map +1 -1
  95. package/lib/module/redux/actions/index.js +18 -3
  96. package/lib/module/redux/actions/index.js.map +1 -1
  97. package/lib/module/redux/reducers/polls.js +65 -5
  98. package/lib/module/redux/reducers/polls.js.map +1 -1
  99. package/lib/module/utils/hooks.js +105 -2
  100. package/lib/module/utils/hooks.js.map +1 -1
  101. package/lib/typescript/HMSRoomSetup.d.ts.map +1 -1
  102. package/lib/typescript/Icons/Clock/index.d.ts +1 -0
  103. package/lib/typescript/Icons/Clock/index.d.ts.map +1 -1
  104. package/lib/typescript/components/CreatePoll.d.ts.map +1 -1
  105. package/lib/typescript/components/HLSView.d.ts.map +1 -1
  106. package/lib/typescript/components/LeaderboardEntry.d.ts +11 -0
  107. package/lib/typescript/components/LeaderboardEntry.d.ts.map +1 -0
  108. package/lib/typescript/components/PollAndQuizSheetScreen.d.ts +8 -0
  109. package/lib/typescript/components/PollAndQuizSheetScreen.d.ts.map +1 -0
  110. package/lib/typescript/components/PollAndQuizVoting.d.ts +2 -0
  111. package/lib/typescript/components/PollAndQuizVoting.d.ts.map +1 -1
  112. package/lib/typescript/components/PollQuestions.d.ts +2 -0
  113. package/lib/typescript/components/PollQuestions.d.ts.map +1 -1
  114. package/lib/typescript/components/PollsAndQuizBottomSheet.d.ts.map +1 -1
  115. package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts +0 -1
  116. package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts.map +1 -1
  117. package/lib/typescript/components/PollsConfigAndList.d.ts +1 -0
  118. package/lib/typescript/components/PollsConfigAndList.d.ts.map +1 -1
  119. package/lib/typescript/components/PreviousPollsAndQuizzesList.d.ts.map +1 -1
  120. package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts +8 -0
  121. package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts.map +1 -0
  122. package/lib/typescript/components/QuizLeaderboardScreen.d.ts +8 -0
  123. package/lib/typescript/components/QuizLeaderboardScreen.d.ts.map +1 -0
  124. package/lib/typescript/components/QuizLeaderboardSummary.d.ts +9 -0
  125. package/lib/typescript/components/QuizLeaderboardSummary.d.ts.map +1 -0
  126. package/lib/typescript/components/VoterParticipationSummary.d.ts +7 -0
  127. package/lib/typescript/components/VoterParticipationSummary.d.ts.map +1 -0
  128. package/lib/typescript/redux/actionTypes.d.ts +29 -8
  129. package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
  130. package/lib/typescript/redux/actions/index.d.ts +6 -2
  131. package/lib/typescript/redux/actions/index.d.ts.map +1 -1
  132. package/lib/typescript/redux/index.d.ts +2 -1
  133. package/lib/typescript/redux/index.d.ts.map +1 -1
  134. package/lib/typescript/redux/reducers/index.d.ts +2 -1
  135. package/lib/typescript/redux/reducers/index.d.ts.map +1 -1
  136. package/lib/typescript/redux/reducers/polls.d.ts +3 -2
  137. package/lib/typescript/redux/reducers/polls.d.ts.map +1 -1
  138. package/lib/typescript/utils/hooks.d.ts +6 -0
  139. package/lib/typescript/utils/hooks.d.ts.map +1 -1
  140. package/package.json +3 -3
  141. package/src/HMSRoomSetup.tsx +19 -1
  142. package/src/Icons/Clock/assets/clock-vector.png +0 -0
  143. package/src/Icons/Clock/assets/clock-vector@2x.png +0 -0
  144. package/src/Icons/Clock/assets/clock-vector@3x.png +0 -0
  145. package/src/Icons/Clock/assets/clock.png +0 -0
  146. package/src/Icons/Clock/assets/clock@2x.png +0 -0
  147. package/src/Icons/Clock/assets/clock@3x.png +0 -0
  148. package/src/Icons/Clock/index.tsx +16 -3
  149. package/src/components/CreatePoll.tsx +7 -2
  150. package/src/components/HLSView.tsx +27 -1
  151. package/src/components/HMSPollsQuizzesNotification.tsx +2 -2
  152. package/src/components/LeaderboardEntry.tsx +172 -0
  153. package/src/components/PollAndQuizSheetScreen.tsx +85 -0
  154. package/src/components/PollAndQuizVoting.tsx +181 -7
  155. package/src/components/PollQuestions.tsx +171 -49
  156. package/src/components/PollsAndQuizBottomSheet.tsx +20 -42
  157. package/src/components/PollsAndQuizzesCard.tsx +2 -2
  158. package/src/components/PollsAndQuizzesModalContent.tsx +40 -163
  159. package/src/components/PollsConfigAndList.tsx +107 -11
  160. package/src/components/PreviousPollsAndQuizzesList.tsx +33 -40
  161. package/src/components/QuizLeaderboardEntriesScreen.tsx +323 -0
  162. package/src/components/QuizLeaderboardScreen.tsx +342 -0
  163. package/src/components/QuizLeaderboardSummary.tsx +207 -0
  164. package/src/components/VoterParticipationSummary.tsx +67 -0
  165. package/src/redux/actionTypes.ts +35 -5
  166. package/src/redux/actions/index.ts +34 -6
  167. package/src/redux/reducers/polls.ts +84 -6
  168. package/src/utils/hooks.ts +190 -3
@@ -1,2 +1,8 @@
1
+ import type { HMSPoll } from '@100mslive/react-native-hms';
1
2
  export declare const useRTCStatsListeners: () => void;
3
+ export declare const useFetchLeaderboardResponse: (pollId: HMSPoll['pollId'] | undefined) => import("@100mslive/react-native-hms").PollLeaderboardResponse | null;
4
+ export declare const useLeaderboardSummaryData: (pollId: HMSPoll['pollId'] | undefined) => {
5
+ label: string;
6
+ value: any;
7
+ }[][] | null;
2
8
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,oBAAoB,YAmFhC,CAAC"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAO3D,eAAO,MAAM,oBAAoB,YAmFhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,WAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,yEA2CtC,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,KACpC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,EAAE,EAAE,GAAG,IAuItC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100mslive/react-native-room-kit",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "100ms Room Kit provides simple & easy to use UI components to build Live Streaming & Video Conferencing experiences in your apps.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -51,7 +51,7 @@
51
51
  "registry": "https://registry.npmjs.org/"
52
52
  },
53
53
  "dependencies": {
54
- "@100mslive/types-prebuilt": "^0.12.4",
54
+ "@100mslive/types-prebuilt": "^0.12.7",
55
55
  "@react-navigation/native": "^6.0.8",
56
56
  "react-redux": "^7.2.4",
57
57
  "redux": "^4.1.0"
@@ -79,7 +79,7 @@
79
79
  "typescript": "^5.0.2"
80
80
  },
81
81
  "peerDependencies": {
82
- "@100mslive/react-native-hms": "1.9.12",
82
+ "@100mslive/react-native-hms": "1.10.0",
83
83
  "@react-native-community/blur": "^4.3.2",
84
84
  "@react-native-masked-view/masked-view": "^0.2.9",
85
85
  "@shopify/flash-list": "^1.4.3",
@@ -402,10 +402,28 @@ export const HMSRoomSetup = () => {
402
402
 
403
403
  useEffect(() => {
404
404
  const subscription = hmsInstance.interactivityCenter.addPollUpdateListener(
405
- (poll, pollUpdateType) => {
405
+ async (poll, pollUpdateType) => {
406
406
  const reduxState = reduxStore.getState();
407
407
  const pollsData = reduxState.polls.polls;
408
408
 
409
+ // Send HLS Timed Metadata for poll if it is started by local peer
410
+ if (
411
+ poll.createdBy &&
412
+ reduxState.hmsStates.localPeer &&
413
+ poll.createdBy.peerID === reduxState.hmsStates.localPeer.peerID
414
+ ) {
415
+ hmsInstance
416
+ .sendHLSTimedMetadata([
417
+ { duration: 20, payload: `poll:${poll.pollId}` },
418
+ ])
419
+ .then((result) => {
420
+ console.log('sendHLSTimedMetadata result: ', result);
421
+ })
422
+ .catch((error: any) => {
423
+ console.log('sendHLSTimedMetadata error: ', error);
424
+ });
425
+ }
426
+
409
427
  batch(() => {
410
428
  // Update poll object in store
411
429
  dispatch(addPoll(poll));
Binary file
Binary file
Binary file
@@ -2,16 +2,29 @@ import React from 'react';
2
2
  import { Image, StyleSheet } from 'react-native';
3
3
  import type { ImageProps } from 'react-native';
4
4
 
5
- interface ClockIconProps extends Omit<ImageProps, 'source'> {}
5
+ import { useHMSRoomStyle } from '../../hooks-util';
6
+
7
+ interface ClockIconProps extends Omit<ImageProps, 'source'> {
8
+ type?: 'vector' | 'normal';
9
+ }
6
10
 
7
11
  export const ClockIcon: React.FC<ClockIconProps> = ({
8
12
  style,
13
+ type = 'vector',
9
14
  ...restProps
10
15
  }) => {
16
+ const iconStyles = useHMSRoomStyle((theme) => ({
17
+ tintColor: theme.palette.on_surface_high,
18
+ }));
19
+
11
20
  return (
12
21
  <Image
13
- source={require('./assets/clock.png')}
14
- style={[styles.icon, style]}
22
+ source={
23
+ type === 'vector'
24
+ ? require('./assets/clock-vector.png')
25
+ : require('./assets/clock.png')
26
+ }
27
+ style={[styles.icon, style, type === 'vector' ? undefined : iconStyles]}
15
28
  {...restProps}
16
29
  />
17
30
  );
@@ -9,7 +9,11 @@ import { HMSTextInput } from './HMSTextInput';
9
9
  import { HMSPrimaryButton } from './HMSPrimaryButton';
10
10
  import { COLORS } from '../utils/theme';
11
11
  import type { RootState } from '../redux';
12
- import { setPollConfig, setPollName, setPollStage } from '../redux/actions';
12
+ import {
13
+ pushToNavigationStack,
14
+ setPollConfig,
15
+ setPollName,
16
+ } from '../redux/actions';
13
17
  import { CreatePollStages } from '../redux/actionTypes';
14
18
  import type { PollConfig } from '../redux/actionTypes';
15
19
  import { PollIcon, QuizIcon } from '../Icons';
@@ -67,7 +71,7 @@ export const CreatePoll: React.FC<CreatePollProps> = ({}) => {
67
71
 
68
72
  const addQuestions = () => {
69
73
  if (pollName.trim().length > 0) {
70
- dispatch(setPollStage(CreatePollStages.POLL_QUESTION_CONFIG));
74
+ dispatch(pushToNavigationStack(CreatePollStages.POLL_QUESTION_CONFIG));
71
75
  }
72
76
  };
73
77
 
@@ -230,6 +234,7 @@ const styles = StyleSheet.create({
230
234
  },
231
235
  createPollBtn: {
232
236
  marginTop: 24,
237
+ marginBottom: 16,
233
238
  },
234
239
  contentContainer: {
235
240
  marginHorizontal: 24,
@@ -1,11 +1,18 @@
1
1
  import React, { useRef } from 'react';
2
2
  import type { ComponentRef } from 'react';
3
3
  import { useDispatch, useSelector } from 'react-redux';
4
- import { View, Text, StyleSheet, Platform } from 'react-native';
4
+ import {
5
+ View,
6
+ Text,
7
+ StyleSheet,
8
+ Platform,
9
+ useWindowDimensions,
10
+ } from 'react-native';
5
11
  import {
6
12
  HMSHLSPlayer,
7
13
  HMSHLSPlayerPlaybackState,
8
14
  useHMSHLSPlayerPlaybackState,
15
+ useHMSHLSPlayerResolution,
9
16
  } from '@100mslive/react-native-hms';
10
17
 
11
18
  import type { RootState } from '../redux';
@@ -18,6 +25,7 @@ import { HMSHLSNotStarted } from './HMSHLSNotStarted';
18
25
  import { CrossCircleIcon } from '../Icons';
19
26
  import { useHMSRoomStyleSheet } from '../hooks-util';
20
27
  import { useIsHLSStreamingOn } from '../hooks-sdk';
28
+ import { useIsLandscapeOrientation } from '../utils/dimension';
21
29
 
22
30
  export const _HLSView: React.FC = () => {
23
31
  const dispatch = useDispatch();
@@ -26,6 +34,7 @@ export const _HLSView: React.FC = () => {
26
34
  (state: RootState) =>
27
35
  !!state.hmsStates.room?.hlsStreamingState.variants?.[0]?.hlsStreamUrl
28
36
  );
37
+ const { width, height } = useWindowDimensions();
29
38
  const hmsHlsPlayerRef = useRef<ComponentRef<typeof HMSHLSPlayer>>(null);
30
39
  const showHLSStats = useSelector(
31
40
  (state: RootState) => state.app.joinConfig.showHLSStats
@@ -99,6 +108,8 @@ export const _HLSView: React.FC = () => {
99
108
  );
100
109
 
101
110
  const hlsPlayerPlaybackState = useHMSHLSPlayerPlaybackState();
111
+ const resolution = useHMSHLSPlayerResolution();
112
+ const isLandscapeOrientation = useIsLandscapeOrientation();
102
113
 
103
114
  const isPlaybackFailed =
104
115
  hlsPlayerPlaybackState === HMSHLSPlayerPlaybackState.FAILED;
@@ -141,6 +152,21 @@ export const _HLSView: React.FC = () => {
141
152
  ref={hmsHlsPlayerRef}
142
153
  enableStats={showHLSStats}
143
154
  enableControls={enableHLSPlayerControls}
155
+ style={
156
+ isLandscapeOrientation
157
+ ? {
158
+ height,
159
+ width: resolution
160
+ ? height * (resolution.width / resolution.height)
161
+ : width,
162
+ }
163
+ : {
164
+ width,
165
+ height: resolution
166
+ ? width / (resolution.width / resolution.height)
167
+ : height,
168
+ }
169
+ }
144
170
  />
145
171
 
146
172
  <HLSPlayerEmoticons />
@@ -14,8 +14,8 @@ import {
14
14
  import { HMSNotification } from './HMSNotification';
15
15
  import { ModalTypes } from '../utils/types';
16
16
  import {
17
+ pushToNavigationStack,
17
18
  removeNotification,
18
- setPollStage,
19
19
  setSelectedPollId,
20
20
  } from '../redux/actions';
21
21
  import { CreatePollStages } from '../redux/actionTypes';
@@ -56,7 +56,7 @@ export const HMSPollsQuizzesNotification: React.FC<
56
56
  // return;
57
57
  // }
58
58
  batch(() => {
59
- dispatch(setPollStage(CreatePollStages.POLL_VOTING));
59
+ dispatch(pushToNavigationStack(CreatePollStages.POLL_VOTING));
60
60
  dispatch(setSelectedPollId(poll.pollId));
61
61
  handleModalVisibleType(ModalTypes.POLLS_AND_QUIZZES);
62
62
  dispatch(removeNotification(id));
@@ -0,0 +1,172 @@
1
+ import * as React from 'react';
2
+ import { Text, StyleSheet, View } from 'react-native';
3
+ import type { ViewStyle, StyleProp } from 'react-native';
4
+ import type { HMSPollLeaderboardEntry } from '@100mslive/react-native-hms';
5
+
6
+ import { useHMSRoomStyleSheet } from '../hooks-util';
7
+ import { CheckIcon, ClockIcon } from '../Icons';
8
+
9
+ export interface LeaderboardEntryProps {
10
+ entry: HMSPollLeaderboardEntry;
11
+ totalPoints: number;
12
+ totalQuestions: number;
13
+ style?: StyleProp<ViewStyle>;
14
+ }
15
+
16
+ export const LeaderboardEntry: React.FC<LeaderboardEntryProps> = ({
17
+ entry,
18
+ style,
19
+ totalPoints,
20
+ totalQuestions,
21
+ }) => {
22
+ const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
23
+ regularHighText: {
24
+ color: theme.palette.on_surface_high,
25
+ fontFamily: `${typography.font_family}-Regular`,
26
+ },
27
+ regularMediumText: {
28
+ color: theme.palette.on_surface_medium,
29
+ fontFamily: `${typography.font_family}-Regular`,
30
+ },
31
+ semiBoldHighText: {
32
+ color: theme.palette.on_surface_high,
33
+ fontFamily: `${typography.font_family}-SemiBold`,
34
+ },
35
+ semiBoldWhiteText: {
36
+ color: '#ffffff',
37
+ fontFamily: `${typography.font_family}-SemiBold`,
38
+ },
39
+ icon: {
40
+ tintColor: theme.palette.on_surface_medium,
41
+ },
42
+ }));
43
+
44
+ return (
45
+ <View style={[styles.container, style]}>
46
+ <View style={styles.namePositionWrapper}>
47
+ <Text
48
+ style={[
49
+ styles.smallerText,
50
+ hmsRoomStyles.semiBoldWhiteText,
51
+ styles.position,
52
+ entry.position === 1
53
+ ? styles.firstPosition
54
+ : entry.position === 2
55
+ ? styles.secondPosition
56
+ : entry.position === 3
57
+ ? styles.thirdPosition
58
+ : null,
59
+ ]}
60
+ >
61
+ {entry.position}
62
+ </Text>
63
+
64
+ <View style={styles.flexShrink}>
65
+ <Text
66
+ numberOfLines={2}
67
+ style={[styles.smallText, hmsRoomStyles.semiBoldHighText]}
68
+ >
69
+ {entry.peer?.userName}
70
+ </Text>
71
+ <Text style={[styles.smallerText, hmsRoomStyles.regularMediumText]}>
72
+ {entry.score}/{totalPoints} points
73
+ </Text>
74
+ </View>
75
+ </View>
76
+
77
+ <View style={styles.scoreDurationWrapper}>
78
+ {entry.position === 1 &&
79
+ entry.correctResponses &&
80
+ entry.correctResponses > 0 ? (
81
+ <Text
82
+ style={[
83
+ styles.normalText,
84
+ { marginLeft: 12 },
85
+ hmsRoomStyles.semiBoldHighText,
86
+ ]}
87
+ >
88
+ 🏆
89
+ </Text>
90
+ ) : null}
91
+
92
+ <View style={styles.iconWrapper}>
93
+ <CheckIcon
94
+ type="in-circle"
95
+ style={[styles.icon, hmsRoomStyles.icon]}
96
+ />
97
+ <Text style={[styles.smallerText, hmsRoomStyles.regularHighText]}>
98
+ {entry.correctResponses}/{totalQuestions}
99
+ </Text>
100
+ </View>
101
+
102
+ {entry.duration ? (
103
+ <View style={styles.iconWrapper}>
104
+ <ClockIcon
105
+ type="normal"
106
+ style={[styles.icon, hmsRoomStyles.icon]}
107
+ />
108
+ <Text style={[styles.smallerText, hmsRoomStyles.regularHighText]}>
109
+ {(entry.duration / 1000).toFixed(2)}s
110
+ </Text>
111
+ </View>
112
+ ) : null}
113
+ </View>
114
+ </View>
115
+ );
116
+ };
117
+
118
+ const styles = StyleSheet.create({
119
+ container: {
120
+ flexDirection: 'row',
121
+ alignItems: 'center',
122
+ justifyContent: 'space-between',
123
+ },
124
+ namePositionWrapper: {
125
+ flexDirection: 'row',
126
+ alignItems: 'center',
127
+ flexShrink: 1,
128
+ },
129
+ scoreDurationWrapper: { flexDirection: 'row', alignItems: 'center' },
130
+ flexShrink: {
131
+ flexShrink: 1,
132
+ },
133
+ smallerText: {
134
+ fontSize: 12,
135
+ lineHeight: 16,
136
+ },
137
+ smallText: {
138
+ fontSize: 14,
139
+ lineHeight: 20,
140
+ },
141
+ normalText: {
142
+ fontSize: 16,
143
+ lineHeight: 24,
144
+ },
145
+ position: {
146
+ width: 24,
147
+ height: 24,
148
+ borderRadius: 12,
149
+ textAlign: 'center',
150
+ textAlignVertical: 'center',
151
+ marginRight: 12,
152
+ },
153
+ firstPosition: {
154
+ backgroundColor: '#D69516', // '#FFD700'
155
+ },
156
+ secondPosition: {
157
+ backgroundColor: '#3E3E3E', // '#C0C0C0'
158
+ },
159
+ thirdPosition: {
160
+ backgroundColor: '#583B0F', // '#CD7F32'
161
+ },
162
+ iconWrapper: {
163
+ flexDirection: 'row',
164
+ alignItems: 'center',
165
+ marginLeft: 12,
166
+ },
167
+ icon: {
168
+ width: 16,
169
+ height: 16,
170
+ marginRight: 4,
171
+ },
172
+ });
@@ -0,0 +1,85 @@
1
+ import * as React from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import Animated, {
4
+ interpolate,
5
+ useAnimatedStyle,
6
+ useSharedValue,
7
+ withTiming,
8
+ runOnJS,
9
+ } from 'react-native-reanimated';
10
+ import { useSafeAreaFrame } from 'react-native-safe-area-context';
11
+
12
+ import { useIsLandscapeOrientation } from '../utils/dimension';
13
+
14
+ export interface PollAndQuizSheetScreenProps {
15
+ children: React.ReactElement | null;
16
+ zIndex: number;
17
+ disableAnimation?: boolean;
18
+ }
19
+
20
+ export const PollAndQuizSheetScreen: React.FC<PollAndQuizSheetScreenProps> = ({
21
+ children,
22
+ zIndex,
23
+ disableAnimation,
24
+ }) => {
25
+ const isLandscapeOrientation = useIsLandscapeOrientation();
26
+ const { width } = useSafeAreaFrame();
27
+ const xPosition = useSharedValue(disableAnimation ? 0 : 1);
28
+
29
+ const animatedStyle = useAnimatedStyle(
30
+ () => ({
31
+ opacity: interpolate(xPosition.value, [0, 1], [1, 0]),
32
+ transform: [
33
+ {
34
+ translateX: interpolate(
35
+ xPosition.value,
36
+ [0, 1],
37
+ [0, isLandscapeOrientation ? width * 0.6 : width],
38
+ 'clamp'
39
+ ),
40
+ },
41
+ ],
42
+ }),
43
+ [isLandscapeOrientation]
44
+ );
45
+
46
+ React.useEffect(() => {
47
+ if (disableAnimation) {
48
+ return;
49
+ }
50
+ xPosition.value = withTiming(0, { duration: 150 });
51
+ return () => {
52
+ cancelAnimationFrame(xPosition.value);
53
+ };
54
+ }, []);
55
+
56
+ const unmountScreenWithAnimation = React.useCallback(
57
+ (cb: () => void) => {
58
+ if (disableAnimation) {
59
+ cb();
60
+ return;
61
+ }
62
+ xPosition.value = withTiming(1, { duration: 150 }, () => {
63
+ runOnJS(cb)();
64
+ });
65
+ },
66
+ [disableAnimation]
67
+ );
68
+
69
+ return (
70
+ <Animated.View style={[styles.absolute, { zIndex }, animatedStyle]}>
71
+ {children
72
+ ? React.cloneElement(children, { unmountScreenWithAnimation })
73
+ : null}
74
+ </Animated.View>
75
+ );
76
+ };
77
+
78
+ const styles = StyleSheet.create({
79
+ absolute: {
80
+ width: '100%',
81
+ height: '100%',
82
+ position: 'absolute',
83
+ overflow: 'hidden',
84
+ },
85
+ });