@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,14 +5,15 @@ import {
5
5
  StyleSheet,
6
6
  TouchableOpacity,
7
7
  ScrollView,
8
+ Keyboard,
8
9
  } from 'react-native';
9
10
  import { HMSPollQuestionType, HMSPollType } from '@100mslive/react-native-hms';
11
+ import { batch, useDispatch, useSelector, useStore } from 'react-redux';
10
12
 
11
- import { AddIcon } from '../Icons';
13
+ import { AddIcon, ChevronIcon, CloseIcon } from '../Icons';
12
14
  import { useHMSInstance, useHMSRoomStyleSheet } from '../hooks-util';
13
15
  import { HMSPrimaryButton } from './HMSPrimaryButton';
14
16
  import { PollQuestion } from './PollQuestion';
15
- import { batch, useDispatch, useSelector, useStore } from 'react-redux';
16
17
  import type { RootState } from '../redux';
17
18
  import {
18
19
  addPollQuestion,
@@ -20,8 +21,11 @@ import {
20
21
  cleaPollFormState,
21
22
  deletePollQuestionOption,
22
23
  editPollQuestionOption,
24
+ popFromNavigationStack,
23
25
  setLaunchingPoll,
24
26
  setPollQDeleteConfirmationVisible,
27
+ setPollQuestionCorrectOption,
28
+ setPollQuestionPointWeightage,
25
29
  setPollQuestionResponseEditable,
26
30
  setPollQuestionSaved,
27
31
  setPollQuestionSkippable,
@@ -29,13 +33,21 @@ import {
29
33
  setPollQuestionType,
30
34
  setSelectedPollQuestionIndex,
31
35
  } from '../redux/actions';
32
- import type { PollQuestionUI } from 'src/redux/actionTypes';
36
+ import type { PollQuestionUI } from '../redux/actionTypes';
37
+ import { PollQDeleteConfirmationSheetView } from './PollQDeleteConfirmationSheetView';
38
+ import { BottomSheet } from './BottomSheet';
33
39
 
34
40
  export interface PollQuestionsProps {
41
+ currentIdx: number;
35
42
  dismissModal(): void;
43
+ unmountScreenWithAnimation?: (cb: Function) => void;
36
44
  }
37
45
 
38
- export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
46
+ export const PollQuestions: React.FC<PollQuestionsProps> = ({
47
+ currentIdx,
48
+ dismissModal,
49
+ unmountScreenWithAnimation,
50
+ }) => {
39
51
  const dispatch = useDispatch();
40
52
  const hmsInstance = useHMSInstance();
41
53
  const reduxStore = useStore<RootState>();
@@ -45,6 +57,10 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
45
57
  const launchingPoll = useSelector(
46
58
  (state: RootState) => state.polls.launchingPoll
47
59
  );
60
+ const pollType = useSelector(
61
+ (state: RootState) => state.polls.pollConfig.type
62
+ );
63
+ const headerTitle = useSelector((state: RootState) => state.polls.pollName);
48
64
  const questions = useSelector((state: RootState) => state.polls.questions);
49
65
 
50
66
  const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
@@ -52,31 +68,22 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
52
68
  color: theme.palette.on_surface_medium,
53
69
  fontFamily: `${typography.font_family}-Regular`,
54
70
  },
71
+ headerText: {
72
+ color: theme.palette.on_surface_high,
73
+ fontFamily: `${typography.font_family}-SemiBold`,
74
+ },
75
+ container: {
76
+ backgroundColor: theme.palette.surface_dim,
77
+ },
55
78
  }));
56
79
 
57
80
  const disableLaunchPoll =
58
- questions.length <= 0 ||
59
- questions.some(
60
- (question) =>
61
- !question.title ||
62
- !question.saved ||
63
- (Array.isArray(question.options) &&
64
- (question.options.length <= 1 ||
65
- question.options.some((option) => !option)))
66
- );
81
+ questions.length <= 0 || questions.some((question) => !question.saved);
67
82
 
68
83
  const launchPoll = async () => {
69
84
  try {
70
85
  const pollsData = reduxStore.getState().polls;
71
-
72
- if (
73
- !pollsData.pollName ||
74
- pollsData.questions.some(
75
- (question) =>
76
- !question.title ||
77
- (question.options && question.options.some((option) => !option))
78
- )
79
- ) {
86
+ if (!pollsData.pollName || disableLaunchPoll) {
80
87
  console.log('Incorrect data!');
81
88
  return;
82
89
  }
@@ -84,19 +91,32 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
84
91
 
85
92
  const result = await hmsInstance.interactivityCenter.startPoll({
86
93
  title: pollsData.pollName,
87
- type: HMSPollType.poll,
94
+ type: pollType,
88
95
  rolesThatCanViewResponses:
89
- pollsData.pollConfig.voteCountHidden && localPeerRole
96
+ pollType === HMSPollType.poll &&
97
+ pollsData.pollConfig.voteCountHidden &&
98
+ localPeerRole
90
99
  ? [localPeerRole]
91
100
  : undefined,
92
101
  // mode: HMSPollUserTrackingMode.customerUserID, // mode: null, // `pollsData.pollConfig.resultsAnonymous` Make results anonymous set user tracking mode to none
93
- questions: pollsData.questions.map((question) => ({
94
- skippable: question.skippable,
95
- once: !question.responseEditable,
96
- text: question.title,
97
- type: question.type,
98
- options: question.options?.map((option) => ({ text: option })),
99
- })),
102
+ questions: pollsData.questions.map((question) => {
103
+ const weight = parseInt(question.pointWeightage);
104
+ return {
105
+ skippable: question.skippable,
106
+ once: !question.responseEditable,
107
+ text: question.title,
108
+ type: question.type,
109
+ weight:
110
+ pollType === HMSPollType.quiz && !isNaN(weight)
111
+ ? weight
112
+ : undefined,
113
+ options: question.options?.map((option) =>
114
+ pollType === HMSPollType.quiz
115
+ ? { text: option[1], isCorrectAnswer: option[0] }
116
+ : { text: option[1] }
117
+ ),
118
+ };
119
+ }),
100
120
  });
101
121
 
102
122
  console.log('quickStartPoll result > ', result);
@@ -144,6 +164,10 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
144
164
  setPollQuestionType(questionIndex, value as HMSPollQuestionType)
145
165
  );
146
166
  break;
167
+ case 'pointWeightage':
168
+ const cleanNumber = (value as string).replace(/[^0-9]/g, '');
169
+ dispatch(setPollQuestionPointWeightage(questionIndex, cleanNumber));
170
+ break;
147
171
  }
148
172
  },
149
173
  []
@@ -170,57 +194,126 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
170
194
  []
171
195
  );
172
196
 
197
+ const handleSetPollQuestionCorrectOption = React.useCallback(
198
+ (questionIndex: number, optionIndex: number, corectOption: boolean) => {
199
+ dispatch(
200
+ setPollQuestionCorrectOption(questionIndex, optionIndex, corectOption)
201
+ );
202
+ },
203
+ []
204
+ );
205
+
206
+ const handleBackPress = () => {
207
+ Keyboard.dismiss();
208
+ if (typeof unmountScreenWithAnimation === 'function') {
209
+ unmountScreenWithAnimation(() => dispatch(popFromNavigationStack()));
210
+ } else {
211
+ dispatch(popFromNavigationStack());
212
+ }
213
+ };
214
+
215
+ const handleClosePress = () => {
216
+ Keyboard.dismiss();
217
+ dismissModal();
218
+ };
219
+
173
220
  return (
174
- <ScrollView
175
- style={styles.contentContainer}
176
- contentContainerStyle={{ paddingTop: 24 }}
177
- >
178
- {questions.map((pollQuestion, idx, arr) => {
179
- const isFirst = idx === 0;
180
- return (
181
- <React.Fragment key={idx}>
182
- {isFirst ? null : <View style={{ height: 16 }} />}
221
+ <View style={[styles.fullView, hmsRoomStyles.container]}>
222
+ {/* Header */}
223
+ <View style={styles.header}>
224
+ <View style={styles.headerControls}>
225
+ {currentIdx > 0 ? (
226
+ <TouchableOpacity
227
+ onPress={handleBackPress}
228
+ disabled={launchingPoll}
229
+ hitSlop={styles.closeIconHitSlop}
230
+ style={[styles.backIcon, launchingPoll ? { opacity: 0.4 } : null]}
231
+ >
232
+ <ChevronIcon direction="left" />
233
+ </TouchableOpacity>
234
+ ) : null}
183
235
 
184
- <PollQuestion
185
- totalQuestions={arr.length}
186
- currentQuestionIndex={idx}
187
- pollQuestion={pollQuestion}
188
- onAddPollQuestionOption={handleAddPollQuestionOption}
189
- onDeletePollQuestionOption={handleDeletePollQuestionOption}
190
- onEditPollQuestionOption={handleEditPollQuestionOption}
191
- onQuestionFieldChange={onQuestionFieldChange}
192
- onDelete={deleteQuestion}
193
- />
194
- </React.Fragment>
195
- );
196
- })}
236
+ <Text
237
+ numberOfLines={2}
238
+ style={[
239
+ styles.headerText,
240
+ { flexShrink: 1 },
241
+ hmsRoomStyles.headerText,
242
+ ]}
243
+ >
244
+ {headerTitle}
245
+ </Text>
246
+ </View>
197
247
 
198
- <View style={[styles.addOptionWrapper, { marginTop: 16 }]}>
199
248
  <TouchableOpacity
200
- onPress={addQuestion}
201
- disabled={launchingPoll}
202
- style={[
203
- styles.addOptionContainer,
204
- launchingPoll ? { opacity: 0.4 } : null,
205
- ]}
249
+ onPress={handleClosePress}
250
+ hitSlop={styles.closeIconHitSlop}
251
+ style={{ marginLeft: 16 }}
206
252
  >
207
- <View style={styles.addOptionIconWrapper}>
208
- <AddIcon type="circle" />
209
- </View>
210
- <Text style={[styles.smallText, hmsRoomStyles.regularMediumText]}>
211
- Add another question
212
- </Text>
253
+ <CloseIcon />
213
254
  </TouchableOpacity>
214
255
  </View>
215
256
 
216
- <HMSPrimaryButton
217
- disabled={disableLaunchPoll || launchingPoll}
218
- title="Launch Poll"
219
- loading={launchingPoll}
220
- onPress={launchPoll}
221
- style={{ marginTop: 16, marginBottom: 56, alignSelf: 'flex-end' }}
222
- />
223
- </ScrollView>
257
+ {/* Divider */}
258
+ <BottomSheet.Divider style={styles.halfDivider} />
259
+
260
+ <ScrollView
261
+ style={styles.contentContainer}
262
+ contentContainerStyle={{ paddingTop: 24 }}
263
+ >
264
+ {questions.map((pollQuestion, idx, arr) => {
265
+ const isFirst = idx === 0;
266
+ return (
267
+ <React.Fragment key={idx}>
268
+ {isFirst ? null : <View style={{ height: 16 }} />}
269
+
270
+ <PollQuestion
271
+ totalQuestions={arr.length}
272
+ currentQuestionIndex={idx}
273
+ pollQuestion={pollQuestion}
274
+ onAddPollQuestionOption={handleAddPollQuestionOption}
275
+ onDeletePollQuestionOption={handleDeletePollQuestionOption}
276
+ onEditPollQuestionOption={handleEditPollQuestionOption}
277
+ onSetPollQuestionCorrectOption={
278
+ handleSetPollQuestionCorrectOption
279
+ }
280
+ onQuestionFieldChange={onQuestionFieldChange}
281
+ onDelete={deleteQuestion}
282
+ />
283
+ </React.Fragment>
284
+ );
285
+ })}
286
+
287
+ <View style={[styles.addOptionWrapper, { marginTop: 16 }]}>
288
+ <TouchableOpacity
289
+ onPress={addQuestion}
290
+ disabled={launchingPoll}
291
+ style={[
292
+ styles.addOptionContainer,
293
+ launchingPoll ? { opacity: 0.4 } : null,
294
+ ]}
295
+ >
296
+ <View style={styles.addOptionIconWrapper}>
297
+ <AddIcon type="circle" />
298
+ </View>
299
+ <Text style={[styles.smallText, hmsRoomStyles.regularMediumText]}>
300
+ Add another question
301
+ </Text>
302
+ </TouchableOpacity>
303
+ </View>
304
+
305
+ <HMSPrimaryButton
306
+ disabled={disableLaunchPoll || launchingPoll}
307
+ title={`Launch ${pollType === HMSPollType.quiz ? 'Quiz' : 'Poll'}`}
308
+ loading={launchingPoll}
309
+ onPress={launchPoll}
310
+ style={{ marginTop: 16, marginBottom: 56, alignSelf: 'flex-end' }}
311
+ />
312
+ </ScrollView>
313
+
314
+ {/* Modal */}
315
+ <PollQDeleteConfirmationSheetView />
316
+ </View>
224
317
  );
225
318
  };
226
319
 
@@ -256,4 +349,51 @@ const styles = StyleSheet.create({
256
349
  marginRight: 8,
257
350
  padding: 8,
258
351
  },
352
+
353
+ // -------
354
+
355
+ // Utilities
356
+ fullView: {
357
+ flex: 1,
358
+ },
359
+ // Header
360
+ header: {
361
+ flexDirection: 'row',
362
+ alignItems: 'center',
363
+ justifyContent: 'space-between',
364
+ marginTop: 24,
365
+ marginHorizontal: 24,
366
+ },
367
+ headerControls: {
368
+ flexDirection: 'row',
369
+ alignItems: 'center',
370
+ flexShrink: 1,
371
+ },
372
+ headerText: {
373
+ fontSize: 20,
374
+ lineHeight: 24,
375
+ letterSpacing: 0.15,
376
+ marginRight: 12,
377
+ },
378
+ closeIconHitSlop: {
379
+ bottom: 16,
380
+ left: 16,
381
+ right: 16,
382
+ top: 16,
383
+ },
384
+ backIcon: {
385
+ marginRight: 8,
386
+ },
387
+ // Divider
388
+ halfDivider: {
389
+ marginHorizontal: 24,
390
+ marginVertical: 0,
391
+ marginTop: 24,
392
+ width: undefined,
393
+ },
394
+ divider: {
395
+ marginHorizontal: 24,
396
+ marginVertical: 24,
397
+ width: undefined,
398
+ },
259
399
  });
@@ -1,22 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import { Platform, StyleSheet } from 'react-native';
3
- import { useSelector } from 'react-redux';
3
+ import { useDispatch } from 'react-redux';
4
4
 
5
5
  import { BottomSheet } from './BottomSheet';
6
- import {
7
- useHMSRoomStyleSheet,
8
- useIsHLSViewer,
9
- useModalType,
10
- } from '../hooks-util';
6
+ import { useHMSRoomStyleSheet, useModalType } from '../hooks-util';
11
7
  import { useHeaderHeight } from './Header';
12
8
  import { useIsLandscapeOrientation } from '../utils/dimension';
13
9
  import { PollsAndQuizzesModalContent } from './PollsAndQuizzesModalContent';
14
10
  import { ModalTypes } from '../utils/types';
15
- import type { RootState } from '../redux';
16
- import { CreatePollStages } from '../redux/actionTypes';
17
- import { visiblePollsSelector } from '../utils/functions';
11
+ import { resetNavigationStack } from '../redux/actions';
18
12
 
19
13
  export const PollsAndQuizBottomSheet = () => {
14
+ const dispatch = useDispatch();
20
15
  const headerHeight = useHeaderHeight();
21
16
  const isLandscapeOrientation = useIsLandscapeOrientation();
22
17
  const {
@@ -24,40 +19,26 @@ export const PollsAndQuizBottomSheet = () => {
24
19
  handleModalVisibleType: setModalVisible,
25
20
  } = useModalType();
26
21
 
27
- const isPollQuestionStage = useSelector(
28
- (state: RootState) =>
29
- state.polls.stage === CreatePollStages.POLL_QUESTION_CONFIG
30
- );
31
- const isHLSViewer = useIsHLSViewer();
32
- const havePolls = useSelector(
33
- (state: RootState) =>
34
- visiblePollsSelector(
35
- Object.values(state.polls.polls),
36
- isHLSViewer,
37
- state.polls.cuedPollIds
38
- ).length > 0
39
- );
40
-
41
22
  const hmsRoomStyles = useHMSRoomStyleSheet((theme) => ({
42
23
  contentContainer: {
43
24
  backgroundColor: theme.palette.surface_dim,
44
25
  },
45
26
  }));
46
27
 
47
- const dismissModal = () => setModalVisible(ModalTypes.DEFAULT);
48
-
49
- const fullHeight = isPollQuestionStage || havePolls;
50
- const containerStyles = fullHeight
51
- ? [
52
- styles.bottomSheet,
53
- {
54
- marginTop: isLandscapeOrientation
55
- ? 0
56
- : headerHeight + (Platform.OS === 'android' ? 24 : 0),
57
- },
58
- hmsRoomStyles.contentContainer,
59
- ]
60
- : [hmsRoomStyles.contentContainer];
28
+ const dismissModal = () => {
29
+ setModalVisible(ModalTypes.DEFAULT);
30
+ dispatch(resetNavigationStack());
31
+ };
32
+
33
+ const containerStyles = [
34
+ styles.bottomSheet,
35
+ {
36
+ marginTop: isLandscapeOrientation
37
+ ? 0
38
+ : headerHeight + (Platform.OS === 'android' ? 24 : 0),
39
+ },
40
+ hmsRoomStyles.contentContainer,
41
+ ];
61
42
 
62
43
  return (
63
44
  <BottomSheet
@@ -66,12 +47,9 @@ export const PollsAndQuizBottomSheet = () => {
66
47
  isVisible={modalVisible === ModalTypes.POLLS_AND_QUIZZES}
67
48
  avoidKeyboard={true}
68
49
  containerStyle={containerStyles}
69
- bottomOffsetSpace={fullHeight ? 0 : undefined}
50
+ bottomOffsetSpace={0}
70
51
  >
71
- <PollsAndQuizzesModalContent
72
- fullHeight={fullHeight}
73
- dismissModal={dismissModal}
74
- />
52
+ <PollsAndQuizzesModalContent dismissModal={dismissModal} />
75
53
  </BottomSheet>
76
54
  );
77
55
  };
@@ -5,7 +5,7 @@ import type { HMSPoll } from '@100mslive/react-native-hms';
5
5
 
6
6
  import { useHMSRoomStyleSheet } from '../hooks-util';
7
7
  import { HMSPrimaryButton } from './HMSPrimaryButton';
8
- import { setPollStage, setSelectedPollId } from '../redux/actions';
8
+ import { pushToNavigationStack, setSelectedPollId } from '../redux/actions';
9
9
  import { CreatePollStages } from '../redux/actionTypes';
10
10
  import { PollAndQuizzStateLabel } from './PollAndQuizzStateLabel';
11
11
 
@@ -36,7 +36,7 @@ export const PollsAndQuizzesCard: React.FC<PollsAndQuizzesCardProps> = ({
36
36
 
37
37
  const viewPoll = () => {
38
38
  batch(() => {
39
- dispatch(setPollStage(CreatePollStages.POLL_VOTING));
39
+ dispatch(pushToNavigationStack(CreatePollStages.POLL_VOTING));
40
40
  dispatch(setSelectedPollId(poll.pollId));
41
41
  });
42
42
  };