@100mslive/react-native-room-kit 1.1.1 → 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 (255) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/HMSRoomSetup.js +15 -5
  3. package/lib/commonjs/HMSRoomSetup.js.map +1 -1
  4. package/lib/commonjs/Icons/Check/assets/check-in-circle.png +0 -0
  5. package/lib/commonjs/Icons/Check/assets/check-in-circle@2x.png +0 -0
  6. package/lib/commonjs/Icons/Check/assets/check-in-circle@3x.png +0 -0
  7. package/lib/commonjs/Icons/Check/index.js +2 -1
  8. package/lib/commonjs/Icons/Check/index.js.map +1 -1
  9. package/lib/commonjs/Icons/CheckBox/index.js +8 -1
  10. package/lib/commonjs/Icons/CheckBox/index.js.map +1 -1
  11. package/lib/commonjs/Icons/Clock/assets/clock-vector.png +0 -0
  12. package/lib/commonjs/Icons/Clock/assets/clock-vector@2x.png +0 -0
  13. package/lib/commonjs/Icons/Clock/assets/clock-vector@3x.png +0 -0
  14. package/lib/commonjs/Icons/Clock/assets/clock.png +0 -0
  15. package/lib/commonjs/Icons/Clock/assets/clock@2x.png +0 -0
  16. package/lib/commonjs/Icons/Clock/assets/clock@3x.png +0 -0
  17. package/lib/commonjs/Icons/Clock/index.js +7 -2
  18. package/lib/commonjs/Icons/Clock/index.js.map +1 -1
  19. package/lib/commonjs/components/CreatePoll.js +100 -53
  20. package/lib/commonjs/components/CreatePoll.js.map +1 -1
  21. package/lib/commonjs/components/GridView.js +4 -8
  22. package/lib/commonjs/components/GridView.js.map +1 -1
  23. package/lib/commonjs/components/HLSView.js +15 -1
  24. package/lib/commonjs/components/HLSView.js.map +1 -1
  25. package/lib/commonjs/components/HMSPollsQuizzesNotification.js +2 -2
  26. package/lib/commonjs/components/HMSPollsQuizzesNotification.js.map +1 -1
  27. package/lib/commonjs/components/LeaderboardEntry.js +135 -0
  28. package/lib/commonjs/components/LeaderboardEntry.js.map +1 -0
  29. package/lib/commonjs/components/PollAndQuizQuestionResponseCard.js +80 -32
  30. package/lib/commonjs/components/PollAndQuizQuestionResponseCard.js.map +1 -1
  31. package/lib/commonjs/components/PollAndQuizQuestionResponseCards.js +53 -0
  32. package/lib/commonjs/components/PollAndQuizQuestionResponseCards.js.map +1 -0
  33. package/lib/commonjs/components/PollAndQuizSheetScreen.js +69 -0
  34. package/lib/commonjs/components/PollAndQuizSheetScreen.js.map +1 -0
  35. package/lib/commonjs/components/PollAndQuizVoting.js +145 -17
  36. package/lib/commonjs/components/PollAndQuizVoting.js.map +1 -1
  37. package/lib/commonjs/components/PollQuestion.js +70 -14
  38. package/lib/commonjs/components/PollQuestion.js.map +1 -1
  39. package/lib/commonjs/components/PollQuestions.js +126 -12
  40. package/lib/commonjs/components/PollQuestions.js.map +1 -1
  41. package/lib/commonjs/components/PollsAndQuizBottomSheet.js +9 -11
  42. package/lib/commonjs/components/PollsAndQuizBottomSheet.js.map +1 -1
  43. package/lib/commonjs/components/PollsAndQuizzesCard.js +1 -1
  44. package/lib/commonjs/components/PollsAndQuizzesCard.js.map +1 -1
  45. package/lib/commonjs/components/PollsAndQuizzesModalContent.js +26 -120
  46. package/lib/commonjs/components/PollsAndQuizzesModalContent.js.map +1 -1
  47. package/lib/commonjs/components/PollsConfigAndList.js +81 -4
  48. package/lib/commonjs/components/PollsConfigAndList.js.map +1 -1
  49. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js +7 -15
  50. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js.map +1 -1
  51. package/lib/commonjs/components/QuizEndOptionsView.js +63 -0
  52. package/lib/commonjs/components/QuizEndOptionsView.js.map +1 -0
  53. package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js +284 -0
  54. package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js.map +1 -0
  55. package/lib/commonjs/components/QuizLeaderboardScreen.js +279 -0
  56. package/lib/commonjs/components/QuizLeaderboardScreen.js.map +1 -0
  57. package/lib/commonjs/components/QuizLeaderboardSummary.js +195 -0
  58. package/lib/commonjs/components/QuizLeaderboardSummary.js.map +1 -0
  59. package/lib/commonjs/components/RadioInput.js +9 -2
  60. package/lib/commonjs/components/RadioInput.js.map +1 -1
  61. package/lib/commonjs/components/RoomSettingsModalContent.js +1 -1
  62. package/lib/commonjs/components/RoomSettingsModalContent.js.map +1 -1
  63. package/lib/commonjs/components/TilesContainer.js +3 -4
  64. package/lib/commonjs/components/TilesContainer.js.map +1 -1
  65. package/lib/commonjs/components/VoterParticipationSummary.js +46 -0
  66. package/lib/commonjs/components/VoterParticipationSummary.js.map +1 -0
  67. package/lib/commonjs/hooks-util.js +1 -1
  68. package/lib/commonjs/hooks-util.js.map +1 -1
  69. package/lib/commonjs/redux/actionTypes.js +9 -1
  70. package/lib/commonjs/redux/actionTypes.js.map +1 -1
  71. package/lib/commonjs/redux/actions/index.js +38 -5
  72. package/lib/commonjs/redux/actions/index.js.map +1 -1
  73. package/lib/commonjs/redux/reducers/polls.js +95 -8
  74. package/lib/commonjs/redux/reducers/polls.js.map +1 -1
  75. package/lib/commonjs/utils/functions.js +48 -3
  76. package/lib/commonjs/utils/functions.js.map +1 -1
  77. package/lib/commonjs/utils/hooks.js +107 -2
  78. package/lib/commonjs/utils/hooks.js.map +1 -1
  79. package/lib/module/HMSRoomSetup.js +16 -6
  80. package/lib/module/HMSRoomSetup.js.map +1 -1
  81. package/lib/module/Icons/Check/assets/check-in-circle.png +0 -0
  82. package/lib/module/Icons/Check/assets/check-in-circle@2x.png +0 -0
  83. package/lib/module/Icons/Check/assets/check-in-circle@3x.png +0 -0
  84. package/lib/module/Icons/Check/index.js +2 -1
  85. package/lib/module/Icons/Check/index.js.map +1 -1
  86. package/lib/module/Icons/CheckBox/index.js +9 -2
  87. package/lib/module/Icons/CheckBox/index.js.map +1 -1
  88. package/lib/module/Icons/Clock/assets/clock-vector.png +0 -0
  89. package/lib/module/Icons/Clock/assets/clock-vector@2x.png +0 -0
  90. package/lib/module/Icons/Clock/assets/clock-vector@3x.png +0 -0
  91. package/lib/module/Icons/Clock/assets/clock.png +0 -0
  92. package/lib/module/Icons/Clock/assets/clock@2x.png +0 -0
  93. package/lib/module/Icons/Clock/assets/clock@3x.png +0 -0
  94. package/lib/module/Icons/Clock/index.js +7 -2
  95. package/lib/module/Icons/Clock/index.js.map +1 -1
  96. package/lib/module/components/CreatePoll.js +102 -56
  97. package/lib/module/components/CreatePoll.js.map +1 -1
  98. package/lib/module/components/GridView.js +5 -9
  99. package/lib/module/components/GridView.js.map +1 -1
  100. package/lib/module/components/HLSView.js +17 -3
  101. package/lib/module/components/HLSView.js.map +1 -1
  102. package/lib/module/components/HMSPollsQuizzesNotification.js +3 -3
  103. package/lib/module/components/HMSPollsQuizzesNotification.js.map +1 -1
  104. package/lib/module/components/LeaderboardEntry.js +126 -0
  105. package/lib/module/components/LeaderboardEntry.js.map +1 -0
  106. package/lib/module/components/PollAndQuizQuestionResponseCard.js +81 -33
  107. package/lib/module/components/PollAndQuizQuestionResponseCard.js.map +1 -1
  108. package/lib/module/components/PollAndQuizQuestionResponseCards.js +44 -0
  109. package/lib/module/components/PollAndQuizQuestionResponseCards.js.map +1 -0
  110. package/lib/module/components/PollAndQuizSheetScreen.js +60 -0
  111. package/lib/module/components/PollAndQuizSheetScreen.js.map +1 -0
  112. package/lib/module/components/PollAndQuizVoting.js +148 -20
  113. package/lib/module/components/PollAndQuizVoting.js.map +1 -1
  114. package/lib/module/components/PollQuestion.js +73 -17
  115. package/lib/module/components/PollQuestion.js.map +1 -1
  116. package/lib/module/components/PollQuestions.js +129 -15
  117. package/lib/module/components/PollQuestions.js.map +1 -1
  118. package/lib/module/components/PollsAndQuizBottomSheet.js +11 -13
  119. package/lib/module/components/PollsAndQuizBottomSheet.js.map +1 -1
  120. package/lib/module/components/PollsAndQuizzesCard.js +2 -2
  121. package/lib/module/components/PollsAndQuizzesCard.js.map +1 -1
  122. package/lib/module/components/PollsAndQuizzesModalContent.js +28 -122
  123. package/lib/module/components/PollsAndQuizzesModalContent.js.map +1 -1
  124. package/lib/module/components/PollsConfigAndList.js +82 -5
  125. package/lib/module/components/PollsConfigAndList.js.map +1 -1
  126. package/lib/module/components/PreviousPollsAndQuizzesList.js +7 -15
  127. package/lib/module/components/PreviousPollsAndQuizzesList.js.map +1 -1
  128. package/lib/module/components/QuizEndOptionsView.js +54 -0
  129. package/lib/module/components/QuizEndOptionsView.js.map +1 -0
  130. package/lib/module/components/QuizLeaderboardEntriesScreen.js +275 -0
  131. package/lib/module/components/QuizLeaderboardEntriesScreen.js.map +1 -0
  132. package/lib/module/components/QuizLeaderboardScreen.js +270 -0
  133. package/lib/module/components/QuizLeaderboardScreen.js.map +1 -0
  134. package/lib/module/components/QuizLeaderboardSummary.js +186 -0
  135. package/lib/module/components/QuizLeaderboardSummary.js.map +1 -0
  136. package/lib/module/components/RadioInput.js +10 -3
  137. package/lib/module/components/RadioInput.js.map +1 -1
  138. package/lib/module/components/RoomSettingsModalContent.js +1 -1
  139. package/lib/module/components/RoomSettingsModalContent.js.map +1 -1
  140. package/lib/module/components/TilesContainer.js +5 -6
  141. package/lib/module/components/TilesContainer.js.map +1 -1
  142. package/lib/module/components/VoterParticipationSummary.js +37 -0
  143. package/lib/module/components/VoterParticipationSummary.js.map +1 -0
  144. package/lib/module/hooks-util.js +2 -4
  145. package/lib/module/hooks-util.js.map +1 -1
  146. package/lib/module/redux/actionTypes.js +9 -1
  147. package/lib/module/redux/actionTypes.js.map +1 -1
  148. package/lib/module/redux/actions/index.js +29 -3
  149. package/lib/module/redux/actions/index.js.map +1 -1
  150. package/lib/module/redux/reducers/polls.js +96 -9
  151. package/lib/module/redux/reducers/polls.js.map +1 -1
  152. package/lib/module/utils/functions.js +43 -3
  153. package/lib/module/utils/functions.js.map +1 -1
  154. package/lib/module/utils/hooks.js +105 -2
  155. package/lib/module/utils/hooks.js.map +1 -1
  156. package/lib/typescript/HMSRoomSetup.d.ts.map +1 -1
  157. package/lib/typescript/Icons/Check/index.d.ts +1 -0
  158. package/lib/typescript/Icons/Check/index.d.ts.map +1 -1
  159. package/lib/typescript/Icons/CheckBox/index.d.ts +1 -0
  160. package/lib/typescript/Icons/CheckBox/index.d.ts.map +1 -1
  161. package/lib/typescript/Icons/Clock/index.d.ts +1 -0
  162. package/lib/typescript/Icons/Clock/index.d.ts.map +1 -1
  163. package/lib/typescript/components/CreatePoll.d.ts.map +1 -1
  164. package/lib/typescript/components/GridView.d.ts.map +1 -1
  165. package/lib/typescript/components/HLSView.d.ts.map +1 -1
  166. package/lib/typescript/components/LeaderboardEntry.d.ts +11 -0
  167. package/lib/typescript/components/LeaderboardEntry.d.ts.map +1 -0
  168. package/lib/typescript/components/PollAndQuizQuestionResponseCard.d.ts.map +1 -1
  169. package/lib/typescript/components/PollAndQuizQuestionResponseCards.d.ts +9 -0
  170. package/lib/typescript/components/PollAndQuizQuestionResponseCards.d.ts.map +1 -0
  171. package/lib/typescript/components/PollAndQuizSheetScreen.d.ts +8 -0
  172. package/lib/typescript/components/PollAndQuizSheetScreen.d.ts.map +1 -0
  173. package/lib/typescript/components/PollAndQuizVoting.d.ts +2 -0
  174. package/lib/typescript/components/PollAndQuizVoting.d.ts.map +1 -1
  175. package/lib/typescript/components/PollQuestion.d.ts +1 -0
  176. package/lib/typescript/components/PollQuestion.d.ts.map +1 -1
  177. package/lib/typescript/components/PollQuestions.d.ts +2 -0
  178. package/lib/typescript/components/PollQuestions.d.ts.map +1 -1
  179. package/lib/typescript/components/PollsAndQuizBottomSheet.d.ts.map +1 -1
  180. package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts +0 -1
  181. package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts.map +1 -1
  182. package/lib/typescript/components/PollsConfigAndList.d.ts +1 -0
  183. package/lib/typescript/components/PollsConfigAndList.d.ts.map +1 -1
  184. package/lib/typescript/components/PreviousPollsAndQuizzesList.d.ts.map +1 -1
  185. package/lib/typescript/components/QuizEndOptionsView.d.ts +10 -0
  186. package/lib/typescript/components/QuizEndOptionsView.d.ts.map +1 -0
  187. package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts +8 -0
  188. package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts.map +1 -0
  189. package/lib/typescript/components/QuizLeaderboardScreen.d.ts +8 -0
  190. package/lib/typescript/components/QuizLeaderboardScreen.d.ts.map +1 -0
  191. package/lib/typescript/components/QuizLeaderboardSummary.d.ts +9 -0
  192. package/lib/typescript/components/QuizLeaderboardSummary.d.ts.map +1 -0
  193. package/lib/typescript/components/RadioInput.d.ts +1 -0
  194. package/lib/typescript/components/RadioInput.d.ts.map +1 -1
  195. package/lib/typescript/components/VoterParticipationSummary.d.ts +7 -0
  196. package/lib/typescript/components/VoterParticipationSummary.d.ts.map +1 -0
  197. package/lib/typescript/hooks-util.d.ts.map +1 -1
  198. package/lib/typescript/redux/actionTypes.d.ts +45 -9
  199. package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
  200. package/lib/typescript/redux/actions/index.d.ts +8 -2
  201. package/lib/typescript/redux/actions/index.d.ts.map +1 -1
  202. package/lib/typescript/redux/index.d.ts +2 -1
  203. package/lib/typescript/redux/index.d.ts.map +1 -1
  204. package/lib/typescript/redux/reducers/index.d.ts +2 -1
  205. package/lib/typescript/redux/reducers/index.d.ts.map +1 -1
  206. package/lib/typescript/redux/reducers/polls.d.ts +3 -2
  207. package/lib/typescript/redux/reducers/polls.d.ts.map +1 -1
  208. package/lib/typescript/utils/functions.d.ts +6 -2
  209. package/lib/typescript/utils/functions.d.ts.map +1 -1
  210. package/lib/typescript/utils/hooks.d.ts +6 -0
  211. package/lib/typescript/utils/hooks.d.ts.map +1 -1
  212. package/package.json +3 -3
  213. package/src/HMSRoomSetup.tsx +25 -6
  214. package/src/Icons/Check/assets/check-in-circle.png +0 -0
  215. package/src/Icons/Check/assets/check-in-circle@2x.png +0 -0
  216. package/src/Icons/Check/assets/check-in-circle@3x.png +0 -0
  217. package/src/Icons/Check/index.tsx +9 -2
  218. package/src/Icons/CheckBox/index.tsx +16 -2
  219. package/src/Icons/Clock/assets/clock-vector.png +0 -0
  220. package/src/Icons/Clock/assets/clock-vector@2x.png +0 -0
  221. package/src/Icons/Clock/assets/clock-vector@3x.png +0 -0
  222. package/src/Icons/Clock/assets/clock.png +0 -0
  223. package/src/Icons/Clock/assets/clock@2x.png +0 -0
  224. package/src/Icons/Clock/assets/clock@3x.png +0 -0
  225. package/src/Icons/Clock/index.tsx +16 -3
  226. package/src/components/CreatePoll.tsx +150 -72
  227. package/src/components/GridView.tsx +4 -14
  228. package/src/components/HLSView.tsx +27 -1
  229. package/src/components/HMSPollsQuizzesNotification.tsx +3 -3
  230. package/src/components/LeaderboardEntry.tsx +172 -0
  231. package/src/components/PollAndQuizQuestionResponseCard.tsx +151 -48
  232. package/src/components/PollAndQuizQuestionResponseCards.tsx +62 -0
  233. package/src/components/PollAndQuizSheetScreen.tsx +85 -0
  234. package/src/components/PollAndQuizVoting.tsx +206 -28
  235. package/src/components/PollQuestion.tsx +140 -25
  236. package/src/components/PollQuestions.tsx +214 -74
  237. package/src/components/PollsAndQuizBottomSheet.tsx +20 -42
  238. package/src/components/PollsAndQuizzesCard.tsx +2 -2
  239. package/src/components/PollsAndQuizzesModalContent.tsx +40 -163
  240. package/src/components/PollsConfigAndList.tsx +107 -11
  241. package/src/components/PreviousPollsAndQuizzesList.tsx +33 -40
  242. package/src/components/QuizEndOptionsView.tsx +71 -0
  243. package/src/components/QuizLeaderboardEntriesScreen.tsx +323 -0
  244. package/src/components/QuizLeaderboardScreen.tsx +342 -0
  245. package/src/components/QuizLeaderboardSummary.tsx +207 -0
  246. package/src/components/RadioInput.tsx +14 -2
  247. package/src/components/RoomSettingsModalContent.tsx +1 -1
  248. package/src/components/TilesContainer.tsx +4 -4
  249. package/src/components/VoterParticipationSummary.tsx +67 -0
  250. package/src/hooks-util.ts +1 -3
  251. package/src/redux/actionTypes.ts +56 -6
  252. package/src/redux/actions/index.ts +56 -6
  253. package/src/redux/reducers/polls.ts +139 -11
  254. package/src/utils/functions.ts +90 -6
  255. package/src/utils/hooks.ts +190 -3
@@ -1,7 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { View, Text, StyleSheet } from 'react-native';
3
3
  import type { StyleProp, ViewStyle } from 'react-native';
4
- import { HMSPollQuestionType, HMSPollState } from '@100mslive/react-native-hms';
4
+ import { useDispatch, useSelector } from 'react-redux';
5
+ import {
6
+ HMSPollQuestionType,
7
+ HMSPollState,
8
+ HMSPollType,
9
+ } from '@100mslive/react-native-hms';
5
10
  import type {
6
11
  HMSPoll,
7
12
  HMSPollQuestion,
@@ -16,8 +21,7 @@ import {
16
21
  import { RadioInputRow } from './RadioInputRow';
17
22
  import { HMSPrimaryButton } from './HMSPrimaryButton';
18
23
  import { HMSBaseButton } from './HMSBaseButton';
19
- import { useDispatch, useSelector } from 'react-redux';
20
- import type { RootState } from 'src/redux';
24
+ import type { RootState } from '../redux';
21
25
  import {
22
26
  addPollQuestionResponse,
23
27
  removePollQuestionResponse,
@@ -25,6 +29,14 @@ import {
25
29
  } from '../redux/actions';
26
30
  import { PollResponseProgressView } from './PollResponseProgressView';
27
31
  import { CheckboxInputRow } from './CheckboxInputRow';
32
+ import {
33
+ checkIsCorrectAnswer,
34
+ checkIsCorrectOption,
35
+ checkIsSelected,
36
+ getLabelFromPollQuestionType,
37
+ } from '../utils/functions';
38
+ import { CheckIcon, CrossCircleIcon } from '../Icons';
39
+ import { QuizEndOptionsView } from './QuizEndOptionsView';
28
40
 
29
41
  export interface PollAndQuizQuestionResponseCardProps {
30
42
  pollId: HMSPoll['pollId'];
@@ -53,6 +65,7 @@ export const PollAndQuizQuestionResponseCard: React.FC<
53
65
  const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
54
66
  container: {
55
67
  backgroundColor: theme.palette.surface_default,
68
+ borderColor: theme.palette.surface_default,
56
69
  },
57
70
  surfaceLowSemiBoldText: {
58
71
  color: theme.palette.on_surface_low,
@@ -62,7 +75,24 @@ export const PollAndQuizQuestionResponseCard: React.FC<
62
75
  color: theme.palette.on_surface_high,
63
76
  fontFamily: `${typography.font_family}-Regular`,
64
77
  },
65
-
78
+ wrongAnswer: {
79
+ borderColor: theme.palette.alert_error_default,
80
+ },
81
+ correctAnswer: {
82
+ borderColor: theme.palette.alert_success,
83
+ },
84
+ wrongAnswerText: {
85
+ color: theme.palette.alert_error_default,
86
+ },
87
+ correctAnswerText: {
88
+ color: theme.palette.alert_success,
89
+ },
90
+ wrongAnswerIcon: {
91
+ tintColor: theme.palette.alert_error_default,
92
+ },
93
+ correctAnswerIcon: {
94
+ tintColor: theme.palette.alert_success,
95
+ },
66
96
  skipButton: {
67
97
  borderColor: theme.palette.border_bright,
68
98
  borderWidth: 1,
@@ -74,6 +104,13 @@ export const PollAndQuizQuestionResponseCard: React.FC<
74
104
  },
75
105
  }));
76
106
 
107
+ // variable to save timestamp when the question became visible to user
108
+ const startTime = React.useRef<number | null>(null);
109
+
110
+ React.useEffect(() => {
111
+ startTime.current = Date.now();
112
+ }, [pollQuestion.index]);
113
+
77
114
  const hmsInstance = useHMSInstance();
78
115
  const dispatch = useDispatch();
79
116
 
@@ -81,6 +118,9 @@ export const PollAndQuizQuestionResponseCard: React.FC<
81
118
  (state: RootState) =>
82
119
  state.polls.pollsResponses[pollId]?.[pollQuestion.index] ?? null
83
120
  );
121
+ const pollType = useSelector(
122
+ (state: RootState) => state.polls.polls[pollId]?.type ?? HMSPollType.poll
123
+ );
84
124
 
85
125
  const canViewPollResponse = useSelector((state: RootState) => {
86
126
  const localPeerRole = state.hmsStates.localPeer?.role;
@@ -129,6 +169,10 @@ export const PollAndQuizQuestionResponseCard: React.FC<
129
169
  options: Array.isArray(selectedOptions)
130
170
  ? selectedOptions
131
171
  : [selectedOptions],
172
+ duration:
173
+ pollType === HMSPollType.quiz && startTime.current !== null
174
+ ? Date.now() - startTime.current
175
+ : undefined,
132
176
  },
133
177
  });
134
178
  console.log(JSON.stringify(result, null, 4));
@@ -150,18 +194,68 @@ export const PollAndQuizQuestionResponseCard: React.FC<
150
194
  ? CheckboxInputRow
151
195
  : null;
152
196
 
197
+ const isCorrectAnswer = checkIsCorrectAnswer(
198
+ pollQuestion.type,
199
+ pollQuestion.myResponses,
200
+ pollQuestion.answer
201
+ );
202
+
153
203
  return (
154
- <View style={[hmsRoomStyles.container, styles.container, containerStyle]}>
155
- <Text
156
- style={[
157
- styles.tinyText,
158
- hmsRoomStyles.surfaceLowSemiBoldText,
159
- styles.uppercaseContent,
160
- ]}
161
- >
162
- Question {pollQuestion.index} of {totalQuestions}:{' '}
163
- {getLabelFromPollQuestionType(pollQuestion.type)}
164
- </Text>
204
+ <View
205
+ style={[
206
+ hmsRoomStyles.container,
207
+ styles.container,
208
+ pollType === HMSPollType.quiz &&
209
+ isVoted &&
210
+ pollState === HMSPollState.stopped
211
+ ? isCorrectAnswer
212
+ ? hmsRoomStyles.correctAnswer
213
+ : hmsRoomStyles.wrongAnswer
214
+ : null,
215
+ containerStyle,
216
+ ]}
217
+ >
218
+ <View style={{ flexDirection: 'row' }}>
219
+ {pollType === HMSPollType.quiz &&
220
+ isVoted &&
221
+ pollState === HMSPollState.stopped ? (
222
+ isCorrectAnswer ? (
223
+ <CheckIcon
224
+ type="in-circle"
225
+ style={[
226
+ hmsRoomStyles.correctAnswerIcon,
227
+ { marginRight: 8, width: 16, height: 16 },
228
+ ]}
229
+ />
230
+ ) : (
231
+ <CrossCircleIcon
232
+ style={[
233
+ hmsRoomStyles.wrongAnswerIcon,
234
+ { marginRight: 8, width: 16, height: 16 },
235
+ ]}
236
+ />
237
+ )
238
+ ) : null}
239
+
240
+ <Text
241
+ numberOfLines={2}
242
+ style={[
243
+ styles.tinyText,
244
+ hmsRoomStyles.surfaceLowSemiBoldText,
245
+ styles.uppercaseContent,
246
+ pollType === HMSPollType.quiz &&
247
+ isVoted &&
248
+ pollState === HMSPollState.stopped
249
+ ? isCorrectAnswer
250
+ ? hmsRoomStyles.correctAnswerText
251
+ : hmsRoomStyles.wrongAnswerText
252
+ : null,
253
+ ]}
254
+ >
255
+ Question {pollQuestion.index} of {totalQuestions}:{' '}
256
+ {getLabelFromPollQuestionType(pollQuestion.type)}
257
+ </Text>
258
+ </View>
165
259
 
166
260
  <Text
167
261
  style={[
@@ -175,7 +269,8 @@ export const PollAndQuizQuestionResponseCard: React.FC<
175
269
 
176
270
  {!InputComponent ? null : (
177
271
  <>
178
- {canViewPollResponse &&
272
+ {pollType === HMSPollType.poll &&
273
+ canViewPollResponse &&
179
274
  (pollQuestion.myResponses.length > 0 ||
180
275
  pollState === HMSPollState.stopped) ? (
181
276
  <>
@@ -186,9 +281,36 @@ export const PollAndQuizQuestionResponseCard: React.FC<
186
281
  <PollResponseProgressView
187
282
  key={option.index}
188
283
  option={option}
189
- totalVotes={arr.reduce((acc, curr) => {
190
- return acc + curr.voteCount;
191
- }, 0)}
284
+ totalVotes={arr.reduce(
285
+ (acc, curr) => acc + curr.voteCount,
286
+ 0
287
+ )}
288
+ />
289
+ );
290
+ })}
291
+ </>
292
+ ) : pollType === HMSPollType.quiz &&
293
+ pollState === HMSPollState.stopped ? (
294
+ <>
295
+ {pollQuestion.options
296
+ ?.sort((a, b) => a.index - b.index)
297
+ .map((option) => {
298
+ const isSelected = checkIsSelected(
299
+ pollQuestion,
300
+ option,
301
+ null
302
+ );
303
+ const isCorrect = checkIsCorrectOption(
304
+ pollQuestion.type,
305
+ option,
306
+ pollQuestion.answer
307
+ );
308
+ return (
309
+ <QuizEndOptionsView
310
+ key={option.index}
311
+ option={option}
312
+ isSelected={isSelected}
313
+ isCorrect={isCorrect}
192
314
  />
193
315
  );
194
316
  })}
@@ -198,19 +320,11 @@ export const PollAndQuizQuestionResponseCard: React.FC<
198
320
  {pollQuestion.options
199
321
  ?.sort((a, b) => a.index - b.index)
200
322
  .map((option) => {
201
- const isSelected =
202
- pollQuestion.myResponses.length > 0
203
- ? pollQuestion.type === HMSPollQuestionType.singleChoice
204
- ? !!pollQuestion.myResponses.find(
205
- (r) => r.option === option.index
206
- )
207
- : !!pollQuestion.myResponses.find((r) =>
208
- r.options ? r.options.includes(option.index) : false
209
- )
210
- : Array.isArray(selectedOptions)
211
- ? selectedOptions.includes(option.index)
212
- : selectedOptions === option.index;
213
-
323
+ const isSelected = checkIsSelected(
324
+ pollQuestion,
325
+ option,
326
+ selectedOptions
327
+ );
214
328
  return (
215
329
  <InputComponent
216
330
  key={option.index}
@@ -236,7 +350,8 @@ export const PollAndQuizQuestionResponseCard: React.FC<
236
350
  </>
237
351
  )}
238
352
 
239
- {isVoted ? (
353
+ {isVoted &&
354
+ (pollType === HMSPollType.poll || pollState === HMSPollState.started) ? (
240
355
  <Text
241
356
  style={[
242
357
  styles.regularText,
@@ -244,7 +359,7 @@ export const PollAndQuizQuestionResponseCard: React.FC<
244
359
  hmsRoomStyles.surfaceLowSemiBoldText,
245
360
  ]}
246
361
  >
247
- Voted
362
+ {pollType === HMSPollType.quiz ? 'Answered' : 'Voted'}
248
363
  </Text>
249
364
  ) : pollState === HMSPollState.started ? (
250
365
  <View style={{ alignSelf: 'flex-end', flexDirection: 'row' }}>
@@ -263,7 +378,7 @@ export const PollAndQuizQuestionResponseCard: React.FC<
263
378
  loading={false}
264
379
  disabled={!anyOptionSelected}
265
380
  onPress={handleVotePress}
266
- title="Vote"
381
+ title={pollType === HMSPollType.quiz ? 'Answer' : 'Vote'}
267
382
  />
268
383
  </View>
269
384
  ) : null}
@@ -275,6 +390,7 @@ const styles = StyleSheet.create({
275
390
  container: {
276
391
  padding: 16,
277
392
  borderRadius: 8,
393
+ borderWidth: 1,
278
394
  },
279
395
  tinyText: {
280
396
  fontSize: 10,
@@ -296,16 +412,3 @@ const styles = StyleSheet.create({
296
412
  textTransform: 'uppercase',
297
413
  },
298
414
  });
299
-
300
- function getLabelFromPollQuestionType(type: HMSPollQuestionType): string {
301
- switch (type) {
302
- case HMSPollQuestionType.singleChoice:
303
- return 'Single Choice';
304
- case HMSPollQuestionType.multipleChoice:
305
- return 'Multiple Choice';
306
- case HMSPollQuestionType.longAnswer:
307
- return 'Long Answer';
308
- case HMSPollQuestionType.shortAnswer:
309
- return 'Short Answer';
310
- }
311
- }
@@ -0,0 +1,62 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+ import { HMSPollType, type HMSPoll } from '@100mslive/react-native-hms';
4
+
5
+ import { PollAndQuizQuestionResponseCard } from './PollAndQuizQuestionResponseCard';
6
+ import type { PollAndQuizQuestionResponseCardProps } from './PollAndQuizQuestionResponseCard';
7
+
8
+ export interface PollAndQuizQuestionResponseCardsProps {
9
+ poll: HMSPoll;
10
+ onVote: PollAndQuizQuestionResponseCardProps['onSubmit'];
11
+ }
12
+
13
+ export const PollAndQuizQuestionResponseCards: React.FC<
14
+ PollAndQuizQuestionResponseCardsProps
15
+ > = ({ poll, onVote }) => {
16
+ if (!Array.isArray(poll.questions) || poll.questions.length <= 0) {
17
+ return null;
18
+ }
19
+
20
+ const pollQuestions = poll.questions.sort((a, b) => a.index - b.index);
21
+
22
+ // Show all question cards if the pollType is a `poll` OR if all questions have been answered
23
+ if (
24
+ poll.type === HMSPollType.poll ||
25
+ pollQuestions.every((q) => q.myResponses.length > 0)
26
+ ) {
27
+ return (
28
+ <View>
29
+ {pollQuestions.map((question, _, arr) => (
30
+ <PollAndQuizQuestionResponseCard
31
+ key={question.index}
32
+ pollState={poll.state}
33
+ pollId={poll.pollId}
34
+ totalQuestions={arr.length}
35
+ pollQuestion={question}
36
+ containerStyle={{ marginBottom: 16 }}
37
+ onSubmit={onVote}
38
+ />
39
+ ))}
40
+ </View>
41
+ );
42
+ }
43
+
44
+ const unansweredQuestion = pollQuestions.find(
45
+ (q) => !q.myResponses || q.myResponses.length <= 0
46
+ );
47
+
48
+ // Show question cards one at a time if the pollType is a `quiz` and not all questions have been answered
49
+ if (unansweredQuestion) {
50
+ return (
51
+ <PollAndQuizQuestionResponseCard
52
+ pollState={poll.state}
53
+ pollId={poll.pollId}
54
+ totalQuestions={pollQuestions.length}
55
+ pollQuestion={unansweredQuestion}
56
+ containerStyle={{ marginBottom: 16 }}
57
+ />
58
+ );
59
+ }
60
+
61
+ return null;
62
+ };
@@ -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
+ });