@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
@@ -5,22 +5,43 @@ import {
5
5
  ScrollView,
6
6
  findNodeHandle,
7
7
  UIManager,
8
+ View,
9
+ Keyboard,
10
+ TouchableOpacity,
8
11
  } from 'react-native';
9
- import { useSelector } from 'react-redux';
10
- import { HMSPollState } from '@100mslive/react-native-hms';
12
+ import { useDispatch, useSelector } from 'react-redux';
13
+ import { HMSPollState, HMSPollType } from '@100mslive/react-native-hms';
11
14
 
12
15
  import { useHMSInstance, useHMSRoomStyleSheet } from '../hooks-util';
13
16
  import type { RootState } from '../redux';
14
- import { PollAndQuizQuestionResponseCard } from './PollAndQuizQuestionResponseCard';
15
17
  import { HMSDangerButton } from './HMSDangerButton';
18
+ import { PollAndQuizQuestionResponseCards } from './PollAndQuizQuestionResponseCards';
19
+ import {
20
+ popFromNavigationStack,
21
+ pushToNavigationStack,
22
+ } from '../redux/actions';
23
+ import { BottomSheet } from './BottomSheet';
24
+ import { ChevronIcon, CloseIcon } from '../Icons';
25
+ import { PollAndQuizzStateLabel } from './PollAndQuizzStateLabel';
26
+ import { HMSPrimaryButton } from './HMSPrimaryButton';
27
+ import { CreatePollStages } from '../redux/actionTypes';
28
+ import { VoterParticipationSummary } from './VoterParticipationSummary';
16
29
 
17
30
  export interface PollAndQuizVotingProps {
31
+ currentIdx: number;
18
32
  dismissModal(): void;
33
+ unmountScreenWithAnimation?(cb: Function): void;
19
34
  }
20
35
 
21
- export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
36
+ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = ({
37
+ currentIdx,
38
+ dismissModal,
39
+ unmountScreenWithAnimation,
40
+ }) => {
22
41
  const scrollViewRef = React.useRef<ScrollView>(null);
23
42
  const hmsInstance = useHMSInstance();
43
+ const dispatch = useDispatch();
44
+
24
45
  const selectedPoll = useSelector((state: RootState) => {
25
46
  const pollsData = state.polls;
26
47
  if (pollsData.selectedPollId !== null) {
@@ -32,16 +53,34 @@ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
32
53
  const permissions = state.hmsStates.localPeer?.role?.permissions;
33
54
  return permissions?.pollWrite;
34
55
  });
56
+ const headerTitle = useSelector((state: RootState) => {
57
+ const pollsData = state.polls;
58
+ if (pollsData.selectedPollId !== null) {
59
+ return pollsData.polls[pollsData.selectedPollId]?.title || null;
60
+ }
61
+ return null;
62
+ });
35
63
 
36
64
  const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
37
65
  regularMediumText: {
38
66
  color: theme.palette.on_surface_medium,
39
67
  fontFamily: `${typography.font_family}-Regular`,
40
68
  },
69
+ semiBoldHighText: {
70
+ color: theme.palette.on_surface_high,
71
+ fontFamily: `${typography.font_family}-SemiBold`,
72
+ },
41
73
  semiBoldMediumText: {
42
74
  color: theme.palette.on_surface_medium,
43
75
  fontFamily: `${typography.font_family}-SemiBold`,
44
76
  },
77
+ headerText: {
78
+ color: theme.palette.on_surface_high,
79
+ fontFamily: `${typography.font_family}-SemiBold`,
80
+ },
81
+ container: {
82
+ backgroundColor: theme.palette.surface_dim,
83
+ },
45
84
  }));
46
85
 
47
86
  const endPoll = async () => {
@@ -78,42 +117,134 @@ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
78
117
  );
79
118
  };
80
119
 
120
+ const viewLeaderboard = () => {
121
+ dispatch(pushToNavigationStack(CreatePollStages.QUIZ_LEADERBOARD));
122
+ };
123
+
124
+ const handleBackPress = () => {
125
+ Keyboard.dismiss();
126
+ if (typeof unmountScreenWithAnimation === 'function') {
127
+ unmountScreenWithAnimation(() => dispatch(popFromNavigationStack()));
128
+ } else {
129
+ dispatch(popFromNavigationStack());
130
+ }
131
+ };
132
+
133
+ const handleClosePress = () => {
134
+ Keyboard.dismiss();
135
+ dismissModal();
136
+ };
137
+
81
138
  return (
82
- <ScrollView
83
- ref={scrollViewRef}
84
- style={styles.contentContainer}
85
- contentContainerStyle={{ paddingVertical: 24 }}
86
- >
87
- <Text style={[styles.normalText, hmsRoomStyles.semiBoldMediumText]}>
88
- {selectedPoll?.createdBy?.name} started a Poll
89
- </Text>
90
-
91
- {selectedPoll?.questions
92
- ?.sort((a, b) => a.index - b.index)
93
- .map((question, _, arr) => (
94
- <PollAndQuizQuestionResponseCard
95
- key={question.index}
96
- pollState={selectedPoll.state}
97
- pollId={selectedPoll.pollId}
98
- totalQuestions={arr.length}
99
- pollQuestion={question}
100
- containerStyle={{ marginBottom: 16 }}
101
- onSubmit={handleVote}
139
+ <View style={[styles.fullView, hmsRoomStyles.container]}>
140
+ {/* Header */}
141
+ <View style={styles.header}>
142
+ <View style={styles.headerControls}>
143
+ {currentIdx > 0 ? (
144
+ <TouchableOpacity
145
+ onPress={handleBackPress}
146
+ hitSlop={styles.closeIconHitSlop}
147
+ style={styles.backIcon}
148
+ >
149
+ <ChevronIcon direction="left" />
150
+ </TouchableOpacity>
151
+ ) : null}
152
+
153
+ <Text
154
+ numberOfLines={2}
155
+ style={[
156
+ styles.headerText,
157
+ { flexShrink: 1 },
158
+ hmsRoomStyles.headerText,
159
+ ]}
160
+ >
161
+ {headerTitle}
162
+ </Text>
163
+
164
+ {selectedPoll?.state ? (
165
+ <PollAndQuizzStateLabel state={selectedPoll?.state} />
166
+ ) : null}
167
+ </View>
168
+
169
+ <TouchableOpacity
170
+ onPress={handleClosePress}
171
+ hitSlop={styles.closeIconHitSlop}
172
+ style={{ marginLeft: 16 }}
173
+ >
174
+ <CloseIcon />
175
+ </TouchableOpacity>
176
+ </View>
177
+
178
+ {/* Divider */}
179
+ <BottomSheet.Divider style={styles.halfDivider} />
180
+
181
+ {/* Content */}
182
+ <ScrollView
183
+ ref={scrollViewRef}
184
+ style={styles.contentContainer}
185
+ contentContainerStyle={{ flexGrow: 1, paddingVertical: 24 }}
186
+ >
187
+ {selectedPoll &&
188
+ selectedPoll.type === HMSPollType.quiz &&
189
+ selectedPoll.state === HMSPollState.stopped &&
190
+ !canCreateOrEndPoll ? (
191
+ <React.Fragment>
192
+ <VoterParticipationSummary pollId={selectedPoll.pollId} />
193
+
194
+ <Text style={[styles.normalText, hmsRoomStyles.semiBoldHighText]}>
195
+ Questions
196
+ </Text>
197
+ </React.Fragment>
198
+ ) : (
199
+ <Text style={[styles.normalText, hmsRoomStyles.semiBoldMediumText]}>
200
+ {selectedPoll?.createdBy?.name} started a{' '}
201
+ {selectedPoll?.type === HMSPollType.quiz ? 'quiz' : 'poll'}
202
+ </Text>
203
+ )}
204
+
205
+ {selectedPoll ? (
206
+ <PollAndQuizQuestionResponseCards
207
+ poll={selectedPoll}
208
+ onVote={handleVote}
102
209
  />
103
- ))}
210
+ ) : null}
211
+ </ScrollView>
104
212
 
105
213
  {selectedPoll &&
106
214
  selectedPoll.state === HMSPollState.started &&
107
215
  canCreateOrEndPoll ? (
108
216
  <HMSDangerButton
109
217
  disabled={!selectedPoll}
110
- title="End Poll"
218
+ title={
219
+ selectedPoll?.type === HMSPollType.quiz ? 'End Quiz' : 'End Poll'
220
+ }
111
221
  loading={false}
112
222
  onPress={endPoll}
113
- style={{ marginTop: 16, marginBottom: 16, alignSelf: 'flex-end' }}
223
+ style={{
224
+ marginTop: 16,
225
+ marginBottom: 16,
226
+ marginRight: 24,
227
+ alignSelf: 'flex-end',
228
+ }}
229
+ />
230
+ ) : null}
231
+
232
+ {selectedPoll &&
233
+ selectedPoll.state === HMSPollState.stopped &&
234
+ selectedPoll.type === HMSPollType.quiz ? (
235
+ <HMSPrimaryButton
236
+ title={'View Leaderboard'}
237
+ loading={false}
238
+ onPress={viewLeaderboard}
239
+ style={{
240
+ marginTop: 16,
241
+ marginBottom: 16,
242
+ marginRight: 24,
243
+ alignSelf: 'flex-end',
244
+ }}
114
245
  />
115
246
  ) : null}
116
- </ScrollView>
247
+ </View>
117
248
  );
118
249
  };
119
250
 
@@ -154,4 +285,51 @@ const styles = StyleSheet.create({
154
285
  marginRight: 8,
155
286
  padding: 8,
156
287
  },
288
+
289
+ // -----------------
290
+
291
+ // Utilities
292
+ fullView: {
293
+ flex: 1,
294
+ },
295
+ // Header
296
+ header: {
297
+ flexDirection: 'row',
298
+ alignItems: 'center',
299
+ justifyContent: 'space-between',
300
+ marginTop: 24,
301
+ marginHorizontal: 24,
302
+ },
303
+ headerControls: {
304
+ flexDirection: 'row',
305
+ alignItems: 'center',
306
+ flexShrink: 1,
307
+ },
308
+ headerText: {
309
+ fontSize: 20,
310
+ lineHeight: 24,
311
+ letterSpacing: 0.15,
312
+ marginRight: 12,
313
+ },
314
+ closeIconHitSlop: {
315
+ bottom: 16,
316
+ left: 16,
317
+ right: 16,
318
+ top: 16,
319
+ },
320
+ backIcon: {
321
+ marginRight: 8,
322
+ },
323
+ // Divider
324
+ halfDivider: {
325
+ marginHorizontal: 24,
326
+ marginVertical: 0,
327
+ marginTop: 24,
328
+ width: undefined,
329
+ },
330
+ divider: {
331
+ marginHorizontal: 24,
332
+ marginVertical: 24,
333
+ width: undefined,
334
+ },
157
335
  });
@@ -1,16 +1,23 @@
1
1
  import * as React from 'react';
2
- import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
3
- import { HMSPollQuestionType } from '@100mslive/react-native-hms';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ Platform,
8
+ } from 'react-native';
9
+ import { HMSPollQuestionType, HMSPollType } from '@100mslive/react-native-hms';
4
10
  import { useSelector } from 'react-redux';
5
11
 
6
12
  import { useHMSRoomStyleSheet } from '../hooks-util';
7
13
  import { BottomSheet } from './BottomSheet';
8
- import { AddIcon, ChevronIcon, TrashBinIcon } from '../Icons';
14
+ import { AddIcon, CheckBoxIcon, ChevronIcon, TrashBinIcon } from '../Icons';
9
15
  import { HMSTextInput } from './HMSTextInput';
10
16
  import { HMSBaseButton } from './HMSBaseButton';
11
17
  import { PressableIcon } from './PressableIcon';
12
18
  import type { PollQuestionUI } from '../redux/actionTypes';
13
19
  import type { RootState } from '../redux';
20
+ import { RadioInput } from './RadioInput';
14
21
 
15
22
  export interface PollQuestionProps {
16
23
  totalQuestions: number;
@@ -23,6 +30,11 @@ export interface PollQuestionProps {
23
30
  optionIndex: number,
24
31
  option: string
25
32
  ): void;
33
+ onSetPollQuestionCorrectOption(
34
+ questionIndex: number,
35
+ optionIndex: number,
36
+ correctOption: boolean
37
+ ): void;
26
38
  onQuestionFieldChange: <K extends keyof Omit<PollQuestionUI, 'options'>>(
27
39
  questionIndex: number,
28
40
  questionField: K,
@@ -61,6 +73,7 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
61
73
  onAddPollQuestionOption,
62
74
  onDeletePollQuestionOption,
63
75
  onEditPollQuestionOption,
76
+ onSetPollQuestionCorrectOption,
64
77
  onQuestionFieldChange,
65
78
  onDelete,
66
79
  }) => {
@@ -68,6 +81,9 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
68
81
  const launchingPoll = useSelector(
69
82
  (state: RootState) => state.polls.launchingPoll
70
83
  );
84
+ const pollType = useSelector(
85
+ (state: RootState) => state.polls.pollConfig.type
86
+ );
71
87
 
72
88
  const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
73
89
  container: {
@@ -122,12 +138,16 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
122
138
  }));
123
139
 
124
140
  const saveButtonDisabled =
125
- !pollQuestion.title ||
141
+ // Disable save button if:
142
+ !pollQuestion.title || // title is not vaild, OR
143
+ !pollQuestion.pointWeightage || // pointWeightage is not valid, OR
126
144
  ((pollQuestion.type === HMSPollQuestionType.singleChoice ||
127
- pollQuestion.type === HMSPollQuestionType.multipleChoice) &&
128
- pollQuestion.options &&
129
- (pollQuestion.options.length <= 1 ||
130
- pollQuestion.options.some((option) => !option)));
145
+ pollQuestion.type === HMSPollQuestionType.multipleChoice) && // If question type is singleChoice or multipleChoice, AND
146
+ pollQuestion.options && // options are defined
147
+ (pollQuestion.options.length <= 1 || // options are less than or equal to 1, OR
148
+ pollQuestion.options.some((option) => !option[1]) || // some options are not valid, OR
149
+ (pollType === HMSPollType.quiz &&
150
+ pollQuestion.options.every((option) => !option[0])))); // If poll type is quiz, all options are marked as not correct
131
151
 
132
152
  if (pollQuestion.saved) {
133
153
  return (
@@ -148,14 +168,11 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
148
168
  <TouchableOpacity
149
169
  activeOpacity={0.8}
150
170
  onPress={() => setQuestionTypesVisible((prev) => !prev)}
151
- style={[
152
- {
153
- flexDirection: 'row',
154
- alignItems: 'center',
155
- justifyContent: 'space-between',
156
- },
157
- { marginBottom: 16 },
158
- ]}
171
+ style={{
172
+ flexDirection: 'row',
173
+ alignItems: 'center',
174
+ justifyContent: 'space-between',
175
+ }}
159
176
  >
160
177
  <Text style={[styles.normalText, hmsRoomStyles.regularHighText]}>
161
178
  {pollQuestion.title}
@@ -163,19 +180,26 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
163
180
  <ChevronIcon direction={questionTypesVisible ? 'top' : 'down'} />
164
181
  </TouchableOpacity>
165
182
  ) : (
183
+ <Text style={[styles.normalText, hmsRoomStyles.regularHighText]}>
184
+ {pollQuestion.title}
185
+ </Text>
186
+ )}
187
+
188
+ {pollType === HMSPollType.quiz ? (
166
189
  <Text
167
190
  style={[
168
- styles.normalText,
169
- hmsRoomStyles.regularHighText,
170
- { marginBottom: 16 },
191
+ styles.smallerText,
192
+ hmsRoomStyles.regularMediumText,
193
+ { marginTop: 4 },
171
194
  ]}
172
195
  >
173
- {pollQuestion.title}
196
+ {pollQuestion.pointWeightage}{' '}
197
+ {parseInt(pollQuestion.pointWeightage) <= 1 ? 'point' : 'points'}
174
198
  </Text>
175
- )}
199
+ ) : null}
176
200
 
177
201
  {questionTypesVisible && pollQuestion.options ? (
178
- <View style={{ marginBottom: 8 }}>
202
+ <View style={{ marginTop: 16 }}>
179
203
  {pollQuestion.options.map((option, idx) => (
180
204
  <Text
181
205
  key={idx}
@@ -185,13 +209,13 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
185
209
  hmsRoomStyles.regularMediumText,
186
210
  ]}
187
211
  >
188
- {option}
212
+ {option[1]}
189
213
  </Text>
190
214
  ))}
191
215
  </View>
192
216
  ) : null}
193
217
 
194
- <View style={styles.saveContainer}>
218
+ <View style={[styles.saveContainer, { marginTop: 16 }]}>
195
219
  <PressableIcon
196
220
  disabled={launchingPoll}
197
221
  style={[styles.deleteIcon, launchingPoll ? { opacity: 0.4 } : null]}
@@ -230,6 +254,15 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
230
254
  );
231
255
  }
232
256
 
257
+ const InputComponent =
258
+ pollType === HMSPollType.quiz
259
+ ? pollQuestion.type === HMSPollQuestionType.singleChoice
260
+ ? RadioInput
261
+ : pollQuestion.type === HMSPollQuestionType.multipleChoice
262
+ ? CheckBoxIcon
263
+ : null
264
+ : null;
265
+
233
266
  return (
234
267
  <View style={[styles.container, hmsRoomStyles.container]}>
235
268
  <Text
@@ -361,10 +394,30 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
361
394
  isFirst ? null : styles.topSpace,
362
395
  ]}
363
396
  >
397
+ {!InputComponent ? null : (
398
+ <View style={{ marginRight: 8 }}>
399
+ <InputComponent
400
+ selected={option[0]}
401
+ type={option[0] ? 'checked' : 'unchecked'}
402
+ onChange={(data) => {
403
+ onSetPollQuestionCorrectOption(
404
+ currentQuestionIndex,
405
+ idx,
406
+ data === 'checked'
407
+ ? true
408
+ : data === 'unchecked'
409
+ ? false
410
+ : data
411
+ );
412
+ }}
413
+ />
414
+ </View>
415
+ )}
416
+
364
417
  <HMSTextInput
365
418
  placeholder={`Option ${idx + 1}`}
366
419
  style={hmsRoomStyles.optionText}
367
- value={option}
420
+ value={option[1]}
368
421
  autoCapitalize="none"
369
422
  autoCompleteType="off"
370
423
  autoFocus={false}
@@ -405,6 +458,64 @@ export const PollQuestion: React.FC<PollQuestionProps> = ({
405
458
 
406
459
  <BottomSheet.Divider style={hmsRoomStyles.divider} />
407
460
 
461
+ {/* {[
462
+ {
463
+ id: 'skippable' as const,
464
+ label: 'Allow to skip',
465
+ enabled: pollQuestion.skippable,
466
+ },
467
+ {
468
+ id: 'responseEditable' as const,
469
+ label: 'Allow to vote again',
470
+ enabled: pollQuestion.responseEditable,
471
+ },
472
+ ].map((item) => {
473
+ return (
474
+ <SwitchRow
475
+ key={item.id}
476
+ text={item.label}
477
+ containerStyle={styles.config}
478
+ textStyle={[styles.smallText, hmsRoomStyles.regularMediumText]}
479
+ value={item.enabled}
480
+ onChange={(value) => {
481
+ onQuestionFieldChange(currentQuestionIndex, item.id, value);
482
+ }}
483
+ />
484
+ );
485
+ })} */}
486
+
487
+ {pollType === HMSPollType.quiz ? (
488
+ <View
489
+ style={{
490
+ marginBottom: 16,
491
+ flexDirection: 'row',
492
+ alignItems: 'center',
493
+ justifyContent: 'space-between',
494
+ }}
495
+ >
496
+ <Text style={[styles.smallText, hmsRoomStyles.regularMediumText]}>
497
+ Point Weightage
498
+ </Text>
499
+
500
+ <HMSTextInput
501
+ placeholder=""
502
+ style={[hmsRoomStyles.optionText, { maxWidth: 88, marginLeft: 12 }]}
503
+ value={pollQuestion.pointWeightage}
504
+ autoFocus={false}
505
+ autoCapitalize="none"
506
+ autoCompleteType="off"
507
+ keyboardType={Platform.OS === 'android' ? 'numeric' : 'number-pad'}
508
+ onChangeText={(value) =>
509
+ onQuestionFieldChange(
510
+ currentQuestionIndex,
511
+ 'pointWeightage',
512
+ value
513
+ )
514
+ }
515
+ />
516
+ </View>
517
+ ) : null}
518
+
408
519
  <View style={styles.saveContainer}>
409
520
  <PressableIcon
410
521
  style={styles.deleteIcon}
@@ -453,6 +564,10 @@ const styles = StyleSheet.create({
453
564
  lineHeight: 16,
454
565
  letterSpacing: 1.5,
455
566
  },
567
+ smallerText: {
568
+ fontSize: 12,
569
+ lineHeight: 16,
570
+ },
456
571
  smallText: {
457
572
  fontSize: 14,
458
573
  lineHeight: 20,