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

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 (147) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/HMSRoomSetup.js +3 -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/components/CreatePoll.js +98 -52
  12. package/lib/commonjs/components/CreatePoll.js.map +1 -1
  13. package/lib/commonjs/components/GridView.js +4 -8
  14. package/lib/commonjs/components/GridView.js.map +1 -1
  15. package/lib/commonjs/components/HMSPollsQuizzesNotification.js +1 -1
  16. package/lib/commonjs/components/HMSPollsQuizzesNotification.js.map +1 -1
  17. package/lib/commonjs/components/PollAndQuizQuestionResponseCard.js +80 -32
  18. package/lib/commonjs/components/PollAndQuizQuestionResponseCard.js.map +1 -1
  19. package/lib/commonjs/components/PollAndQuizQuestionResponseCards.js +53 -0
  20. package/lib/commonjs/components/PollAndQuizQuestionResponseCards.js.map +1 -0
  21. package/lib/commonjs/components/PollAndQuizVoting.js +14 -15
  22. package/lib/commonjs/components/PollAndQuizVoting.js.map +1 -1
  23. package/lib/commonjs/components/PollQuestion.js +70 -14
  24. package/lib/commonjs/components/PollQuestion.js.map +1 -1
  25. package/lib/commonjs/components/PollQuestions.js +22 -8
  26. package/lib/commonjs/components/PollQuestions.js.map +1 -1
  27. package/lib/commonjs/components/PollsAndQuizzesModalContent.js +1 -1
  28. package/lib/commonjs/components/PollsAndQuizzesModalContent.js.map +1 -1
  29. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js +2 -2
  30. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js.map +1 -1
  31. package/lib/commonjs/components/QuizEndOptionsView.js +63 -0
  32. package/lib/commonjs/components/QuizEndOptionsView.js.map +1 -0
  33. package/lib/commonjs/components/RadioInput.js +9 -2
  34. package/lib/commonjs/components/RadioInput.js.map +1 -1
  35. package/lib/commonjs/components/RoomSettingsModalContent.js +1 -1
  36. package/lib/commonjs/components/RoomSettingsModalContent.js.map +1 -1
  37. package/lib/commonjs/components/TilesContainer.js +3 -4
  38. package/lib/commonjs/components/TilesContainer.js.map +1 -1
  39. package/lib/commonjs/hooks-util.js +1 -1
  40. package/lib/commonjs/hooks-util.js.map +1 -1
  41. package/lib/commonjs/redux/actionTypes.js +2 -0
  42. package/lib/commonjs/redux/actionTypes.js.map +1 -1
  43. package/lib/commonjs/redux/actions/index.js +14 -1
  44. package/lib/commonjs/redux/actions/index.js.map +1 -1
  45. package/lib/commonjs/redux/reducers/polls.js +30 -3
  46. package/lib/commonjs/redux/reducers/polls.js.map +1 -1
  47. package/lib/commonjs/utils/functions.js +48 -3
  48. package/lib/commonjs/utils/functions.js.map +1 -1
  49. package/lib/module/HMSRoomSetup.js +4 -6
  50. package/lib/module/HMSRoomSetup.js.map +1 -1
  51. package/lib/module/Icons/Check/assets/check-in-circle.png +0 -0
  52. package/lib/module/Icons/Check/assets/check-in-circle@2x.png +0 -0
  53. package/lib/module/Icons/Check/assets/check-in-circle@3x.png +0 -0
  54. package/lib/module/Icons/Check/index.js +2 -1
  55. package/lib/module/Icons/Check/index.js.map +1 -1
  56. package/lib/module/Icons/CheckBox/index.js +9 -2
  57. package/lib/module/Icons/CheckBox/index.js.map +1 -1
  58. package/lib/module/components/CreatePoll.js +99 -54
  59. package/lib/module/components/CreatePoll.js.map +1 -1
  60. package/lib/module/components/GridView.js +5 -9
  61. package/lib/module/components/GridView.js.map +1 -1
  62. package/lib/module/components/HMSPollsQuizzesNotification.js +1 -1
  63. package/lib/module/components/HMSPollsQuizzesNotification.js.map +1 -1
  64. package/lib/module/components/PollAndQuizQuestionResponseCard.js +81 -33
  65. package/lib/module/components/PollAndQuizQuestionResponseCard.js.map +1 -1
  66. package/lib/module/components/PollAndQuizQuestionResponseCards.js +44 -0
  67. package/lib/module/components/PollAndQuizQuestionResponseCards.js.map +1 -0
  68. package/lib/module/components/PollAndQuizVoting.js +16 -17
  69. package/lib/module/components/PollAndQuizVoting.js.map +1 -1
  70. package/lib/module/components/PollQuestion.js +73 -17
  71. package/lib/module/components/PollQuestion.js.map +1 -1
  72. package/lib/module/components/PollQuestions.js +23 -9
  73. package/lib/module/components/PollQuestions.js.map +1 -1
  74. package/lib/module/components/PollsAndQuizzesModalContent.js +1 -1
  75. package/lib/module/components/PollsAndQuizzesModalContent.js.map +1 -1
  76. package/lib/module/components/PreviousPollsAndQuizzesList.js +2 -2
  77. package/lib/module/components/PreviousPollsAndQuizzesList.js.map +1 -1
  78. package/lib/module/components/QuizEndOptionsView.js +54 -0
  79. package/lib/module/components/QuizEndOptionsView.js.map +1 -0
  80. package/lib/module/components/RadioInput.js +10 -3
  81. package/lib/module/components/RadioInput.js.map +1 -1
  82. package/lib/module/components/RoomSettingsModalContent.js +1 -1
  83. package/lib/module/components/RoomSettingsModalContent.js.map +1 -1
  84. package/lib/module/components/TilesContainer.js +5 -6
  85. package/lib/module/components/TilesContainer.js.map +1 -1
  86. package/lib/module/hooks-util.js +2 -4
  87. package/lib/module/hooks-util.js.map +1 -1
  88. package/lib/module/redux/actionTypes.js +2 -0
  89. package/lib/module/redux/actionTypes.js.map +1 -1
  90. package/lib/module/redux/actions/index.js +11 -0
  91. package/lib/module/redux/actions/index.js.map +1 -1
  92. package/lib/module/redux/reducers/polls.js +31 -4
  93. package/lib/module/redux/reducers/polls.js.map +1 -1
  94. package/lib/module/utils/functions.js +43 -3
  95. package/lib/module/utils/functions.js.map +1 -1
  96. package/lib/typescript/HMSRoomSetup.d.ts.map +1 -1
  97. package/lib/typescript/Icons/Check/index.d.ts +1 -0
  98. package/lib/typescript/Icons/Check/index.d.ts.map +1 -1
  99. package/lib/typescript/Icons/CheckBox/index.d.ts +1 -0
  100. package/lib/typescript/Icons/CheckBox/index.d.ts.map +1 -1
  101. package/lib/typescript/components/CreatePoll.d.ts.map +1 -1
  102. package/lib/typescript/components/GridView.d.ts.map +1 -1
  103. package/lib/typescript/components/PollAndQuizQuestionResponseCard.d.ts.map +1 -1
  104. package/lib/typescript/components/PollAndQuizQuestionResponseCards.d.ts +9 -0
  105. package/lib/typescript/components/PollAndQuizQuestionResponseCards.d.ts.map +1 -0
  106. package/lib/typescript/components/PollAndQuizVoting.d.ts.map +1 -1
  107. package/lib/typescript/components/PollQuestion.d.ts +1 -0
  108. package/lib/typescript/components/PollQuestion.d.ts.map +1 -1
  109. package/lib/typescript/components/PollQuestions.d.ts.map +1 -1
  110. package/lib/typescript/components/QuizEndOptionsView.d.ts +10 -0
  111. package/lib/typescript/components/QuizEndOptionsView.d.ts.map +1 -0
  112. package/lib/typescript/components/RadioInput.d.ts +1 -0
  113. package/lib/typescript/components/RadioInput.d.ts.map +1 -1
  114. package/lib/typescript/hooks-util.d.ts.map +1 -1
  115. package/lib/typescript/redux/actionTypes.d.ts +18 -3
  116. package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
  117. package/lib/typescript/redux/actions/index.d.ts +3 -1
  118. package/lib/typescript/redux/actions/index.d.ts.map +1 -1
  119. package/lib/typescript/redux/reducers/polls.d.ts.map +1 -1
  120. package/lib/typescript/utils/functions.d.ts +6 -2
  121. package/lib/typescript/utils/functions.d.ts.map +1 -1
  122. package/package.json +2 -2
  123. package/src/HMSRoomSetup.tsx +7 -6
  124. package/src/Icons/Check/assets/check-in-circle.png +0 -0
  125. package/src/Icons/Check/assets/check-in-circle@2x.png +0 -0
  126. package/src/Icons/Check/assets/check-in-circle@3x.png +0 -0
  127. package/src/Icons/Check/index.tsx +9 -2
  128. package/src/Icons/CheckBox/index.tsx +16 -2
  129. package/src/components/CreatePoll.tsx +143 -70
  130. package/src/components/GridView.tsx +4 -14
  131. package/src/components/HMSPollsQuizzesNotification.tsx +1 -1
  132. package/src/components/PollAndQuizQuestionResponseCard.tsx +151 -48
  133. package/src/components/PollAndQuizQuestionResponseCards.tsx +62 -0
  134. package/src/components/PollAndQuizVoting.tsx +29 -25
  135. package/src/components/PollQuestion.tsx +140 -25
  136. package/src/components/PollQuestions.tsx +47 -29
  137. package/src/components/PollsAndQuizzesModalContent.tsx +1 -1
  138. package/src/components/PreviousPollsAndQuizzesList.tsx +2 -2
  139. package/src/components/QuizEndOptionsView.tsx +71 -0
  140. package/src/components/RadioInput.tsx +14 -2
  141. package/src/components/RoomSettingsModalContent.tsx +1 -1
  142. package/src/components/TilesContainer.tsx +4 -4
  143. package/src/hooks-util.ts +1 -3
  144. package/src/redux/actionTypes.ts +21 -1
  145. package/src/redux/actions/index.ts +22 -0
  146. package/src/redux/reducers/polls.ts +55 -5
  147. package/src/utils/functions.ts +90 -6
@@ -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,
@@ -22,6 +22,8 @@ import {
22
22
  editPollQuestionOption,
23
23
  setLaunchingPoll,
24
24
  setPollQDeleteConfirmationVisible,
25
+ setPollQuestionCorrectOption,
26
+ setPollQuestionPointWeightage,
25
27
  setPollQuestionResponseEditable,
26
28
  setPollQuestionSaved,
27
29
  setPollQuestionSkippable,
@@ -29,7 +31,7 @@ import {
29
31
  setPollQuestionType,
30
32
  setSelectedPollQuestionIndex,
31
33
  } from '../redux/actions';
32
- import type { PollQuestionUI } from 'src/redux/actionTypes';
34
+ import type { PollQuestionUI } from '../redux/actionTypes';
33
35
 
34
36
  export interface PollQuestionsProps {
35
37
  dismissModal(): void;
@@ -45,6 +47,9 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
45
47
  const launchingPoll = useSelector(
46
48
  (state: RootState) => state.polls.launchingPoll
47
49
  );
50
+ const pollType = useSelector(
51
+ (state: RootState) => state.polls.pollConfig.type
52
+ );
48
53
  const questions = useSelector((state: RootState) => state.polls.questions);
49
54
 
50
55
  const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
@@ -55,28 +60,12 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
55
60
  }));
56
61
 
57
62
  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
- );
63
+ questions.length <= 0 || questions.some((question) => !question.saved);
67
64
 
68
65
  const launchPoll = async () => {
69
66
  try {
70
67
  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
- ) {
68
+ if (!pollsData.pollName || disableLaunchPoll) {
80
69
  console.log('Incorrect data!');
81
70
  return;
82
71
  }
@@ -84,19 +73,32 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
84
73
 
85
74
  const result = await hmsInstance.interactivityCenter.startPoll({
86
75
  title: pollsData.pollName,
87
- type: HMSPollType.poll,
76
+ type: pollType,
88
77
  rolesThatCanViewResponses:
89
- pollsData.pollConfig.voteCountHidden && localPeerRole
78
+ pollType === HMSPollType.poll &&
79
+ pollsData.pollConfig.voteCountHidden &&
80
+ localPeerRole
90
81
  ? [localPeerRole]
91
82
  : undefined,
92
83
  // 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
- })),
84
+ questions: pollsData.questions.map((question) => {
85
+ const weight = parseInt(question.pointWeightage);
86
+ return {
87
+ skippable: question.skippable,
88
+ once: !question.responseEditable,
89
+ text: question.title,
90
+ type: question.type,
91
+ weight:
92
+ pollType === HMSPollType.quiz && !isNaN(weight)
93
+ ? weight
94
+ : undefined,
95
+ options: question.options?.map((option) =>
96
+ pollType === HMSPollType.quiz
97
+ ? { text: option[1], isCorrectAnswer: option[0] }
98
+ : { text: option[1] }
99
+ ),
100
+ };
101
+ }),
100
102
  });
101
103
 
102
104
  console.log('quickStartPoll result > ', result);
@@ -144,6 +146,10 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
144
146
  setPollQuestionType(questionIndex, value as HMSPollQuestionType)
145
147
  );
146
148
  break;
149
+ case 'pointWeightage':
150
+ const cleanNumber = (value as string).replace(/[^0-9]/g, '');
151
+ dispatch(setPollQuestionPointWeightage(questionIndex, cleanNumber));
152
+ break;
147
153
  }
148
154
  },
149
155
  []
@@ -170,6 +176,15 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
170
176
  []
171
177
  );
172
178
 
179
+ const handleSetPollQuestionCorrectOption = React.useCallback(
180
+ (questionIndex: number, optionIndex: number, corectOption: boolean) => {
181
+ dispatch(
182
+ setPollQuestionCorrectOption(questionIndex, optionIndex, corectOption)
183
+ );
184
+ },
185
+ []
186
+ );
187
+
173
188
  return (
174
189
  <ScrollView
175
190
  style={styles.contentContainer}
@@ -188,6 +203,9 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
188
203
  onAddPollQuestionOption={handleAddPollQuestionOption}
189
204
  onDeletePollQuestionOption={handleDeletePollQuestionOption}
190
205
  onEditPollQuestionOption={handleEditPollQuestionOption}
206
+ onSetPollQuestionCorrectOption={
207
+ handleSetPollQuestionCorrectOption
208
+ }
191
209
  onQuestionFieldChange={onQuestionFieldChange}
192
210
  onDelete={deleteQuestion}
193
211
  />
@@ -215,7 +233,7 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
215
233
 
216
234
  <HMSPrimaryButton
217
235
  disabled={disableLaunchPoll || launchingPoll}
218
- title="Launch Poll"
236
+ title={`Launch ${pollType === HMSPollType.quiz ? 'Quiz' : 'Poll'}`}
219
237
  loading={launchingPoll}
220
238
  onPress={launchPoll}
221
239
  style={{ marginTop: 16, marginBottom: 56, alignSelf: 'flex-end' }}
@@ -108,7 +108,7 @@ export const PollsAndQuizzesModalContent: React.FC<
108
108
  hmsRoomStyles.headerText,
109
109
  ]}
110
110
  >
111
- {headerTitle ?? ('Polls' || 'Polls and Quizzes')}
111
+ {headerTitle ?? 'Polls and Quizzes'}
112
112
  </Text>
113
113
 
114
114
  {selectedPoll?.state ? (
@@ -50,7 +50,7 @@ export const PreviousPollsAndQuizzesList: React.FC<
50
50
  styles.emptyList,
51
51
  ]}
52
52
  >
53
- No Polls to show
53
+ No Polls or Quizzes to show
54
54
  </Text>
55
55
  </View>
56
56
  );
@@ -60,7 +60,7 @@ export const PreviousPollsAndQuizzesList: React.FC<
60
60
  <View style={styles.contentContainer}>
61
61
  {pollsList.length > 0 && (
62
62
  <Text style={[styles.title, hmsRoomStyles.surfaceHighSemiBoldText]}>
63
- Previous Polls
63
+ Previous Polls And Quizzes
64
64
  </Text>
65
65
  )}
66
66
 
@@ -0,0 +1,71 @@
1
+ import * as React from 'react';
2
+ import type { HMSPollQuestionOption } from '@100mslive/react-native-hms';
3
+ import { StyleSheet, Text, View } from 'react-native';
4
+
5
+ import { useHMSRoomStyleSheet } from '../hooks-util';
6
+ import { CheckIcon } from '../Icons';
7
+
8
+ interface QuizEndOptionsViewProps {
9
+ option: HMSPollQuestionOption;
10
+ isSelected: boolean;
11
+ isCorrect: boolean;
12
+ }
13
+
14
+ export const QuizEndOptionsView: React.FC<QuizEndOptionsViewProps> = ({
15
+ option,
16
+ isSelected,
17
+ isCorrect,
18
+ }) => {
19
+ const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
20
+ surfaceHighRegularText: {
21
+ color: theme.palette.on_surface_high,
22
+ fontFamily: `${typography.font_family}-Regular`,
23
+ },
24
+ surfaceMediumRegularText: {
25
+ color: theme.palette.on_surface_medium,
26
+ fontFamily: `${typography.font_family}-Regular`,
27
+ },
28
+ }));
29
+
30
+ return (
31
+ <View style={styles.container}>
32
+ <View style={styles.textWrapper}>
33
+ {isCorrect ? <CheckIcon style={styles.icon} type="in-circle" /> : null}
34
+
35
+ <Text style={[styles.smallText, hmsRoomStyles.surfaceHighRegularText]}>
36
+ {option.text}
37
+ </Text>
38
+ </View>
39
+
40
+ {isSelected ? (
41
+ <Text
42
+ style={[styles.smallText, hmsRoomStyles.surfaceMediumRegularText]}
43
+ >
44
+ Your Answer
45
+ </Text>
46
+ ) : null}
47
+ </View>
48
+ );
49
+ };
50
+
51
+ const styles = StyleSheet.create({
52
+ container: {
53
+ marginBottom: 16,
54
+ flexDirection: 'row',
55
+ alignItems: 'center',
56
+ justifyContent: 'space-between',
57
+ },
58
+ textWrapper: {
59
+ flexDirection: 'row',
60
+ alignItems: 'center',
61
+ },
62
+ icon: {
63
+ width: 20,
64
+ height: 20,
65
+ marginRight: 8,
66
+ },
67
+ smallText: {
68
+ fontSize: 14,
69
+ lineHeight: 20,
70
+ },
71
+ });
@@ -1,17 +1,19 @@
1
1
  import React from 'react';
2
- import { View, StyleSheet } from 'react-native';
2
+ import { View, StyleSheet, TouchableOpacity } from 'react-native';
3
3
  import type { ColorValue } from 'react-native';
4
4
 
5
5
  export interface RadioInputProps {
6
6
  selected: boolean;
7
7
  size?: number;
8
8
  color?: ColorValue;
9
+ onChange?: (selected: boolean) => void;
9
10
  }
10
11
 
11
12
  export const RadioInput: React.FC<RadioInputProps> = ({
12
13
  selected,
13
14
  size = 24,
14
15
  color = 'white',
16
+ onChange,
15
17
  }) => {
16
18
  const outerCircleStyle = {
17
19
  width: size,
@@ -28,11 +30,21 @@ export const RadioInput: React.FC<RadioInputProps> = ({
28
30
  backgroundColor: color,
29
31
  };
30
32
 
31
- return (
33
+ const radio = (
32
34
  <View style={[styles.outerCircle, outerCircleStyle]}>
33
35
  {selected ? <View style={innerCircleStyle} /> : null}
34
36
  </View>
35
37
  );
38
+
39
+ if (typeof onChange !== 'function') {
40
+ return radio;
41
+ }
42
+
43
+ return (
44
+ <TouchableOpacity onPress={() => onChange(!selected)}>
45
+ {radio}
46
+ </TouchableOpacity>
47
+ );
36
48
  };
37
49
 
38
50
  const styles = StyleSheet.create({
@@ -316,7 +316,7 @@ export const RoomSettingsModalContent: React.FC<
316
316
  {
317
317
  id: 'polls-and-quizes',
318
318
  icon: <PollVoteIcon style={{ width: 20, height: 20 }} />,
319
- label: 'Polls',
319
+ label: 'Polls and Quizzes',
320
320
  pressHandler: openPollsQuizzesModal,
321
321
  isActive: false,
322
322
  hide: !canReadOrWritePoll,
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { View, Dimensions } from 'react-native';
2
+ import { View } from 'react-native';
3
3
  import { useSelector } from 'react-redux';
4
4
  import type { ViewStyle } from 'react-native';
5
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
+ import { useSafeAreaFrame } from 'react-native-safe-area-context';
6
6
  import type { HMSView } from '@100mslive/react-native-hms';
7
7
 
8
8
  import { Tile } from './Tile';
@@ -22,7 +22,7 @@ const _TilesContainer: React.FC<TilesContainerProps> = ({
22
22
  setHmsViewRefs,
23
23
  onPeerTileMorePress,
24
24
  }) => {
25
- const { left, right } = useSafeAreaInsets();
25
+ const { width: safeWidth } = useSafeAreaFrame();
26
26
  const isLandscapeOrientation = useIsLandscapeOrientation();
27
27
 
28
28
  const screenshareTilesAvailable = useSelector(
@@ -55,7 +55,7 @@ const _TilesContainer: React.FC<TilesContainerProps> = ({
55
55
  ? 'row'
56
56
  : 'column',
57
57
  },
58
- { width: Dimensions.get('window').width + left + right },
58
+ { width: safeWidth },
59
59
  ]}
60
60
  >
61
61
  {peerTrackNodes.length <= 3 ? (
package/src/hooks-util.ts CHANGED
@@ -24,8 +24,6 @@ import {
24
24
  WindowController,
25
25
  useHMSHLSPlayerCue,
26
26
  HMSPollUpdateType,
27
- HMSPollType,
28
- // useHMSPeerUpdates,
29
27
  } from '@100mslive/react-native-hms';
30
28
  import type { Chat as ChatConfig } from '@100mslive/types-prebuilt/elements/chat';
31
29
  import { SoftInputModes } from '@100mslive/react-native-hms';
@@ -2572,7 +2570,7 @@ export const useHLSCuedPolls = () => {
2572
2570
  ? store.getState().polls.polls[pollId]
2573
2571
  : null;
2574
2572
 
2575
- if (poll && poll.type === HMSPollType.poll) {
2573
+ if (poll) {
2576
2574
  console.log('HLS Cued Poll ID: ', pollId);
2577
2575
  dispatch(addCuedPollId(poll.pollId));
2578
2576
  dispatch(
@@ -2,6 +2,7 @@ import type {
2
2
  HMSPoll,
3
3
  HMSPollQuestion,
4
4
  HMSPollQuestionType,
5
+ HMSPollType,
5
6
  } from '@100mslive/react-native-hms';
6
7
 
7
8
  const createRequests = (base: String) => {
@@ -197,6 +198,7 @@ export enum CreatePollStages {
197
198
  }
198
199
 
199
200
  export type PollConfig = {
201
+ type: HMSPollType;
200
202
  voteCountHidden: boolean;
201
203
  resultsAnonymous: boolean;
202
204
  };
@@ -206,7 +208,8 @@ export type PollQuestionUI = {
206
208
  title: string;
207
209
  skippable: boolean;
208
210
  responseEditable: boolean;
209
- options?: string[];
211
+ pointWeightage: string;
212
+ options?: [boolean, string][];
210
213
  saved: boolean;
211
214
  };
212
215
 
@@ -220,9 +223,11 @@ export type PollsActionType =
220
223
  | SetSelectedQuestionIndexAction
221
224
  | SetQuestionTypeAction
222
225
  | SetQuestionTitleAction
226
+ | SetQuestionPointWeightageAction
223
227
  | AddQuestionOptionAction
224
228
  | DeleteQuestionOptionAction
225
229
  | EditQuestionOptionAction
230
+ | SetQuestionCorrectOptionAction
226
231
  | SetQuestionSkippable
227
232
  | SetQuestionResponseEditable
228
233
  | SetQuestionSavedAction
@@ -287,6 +292,12 @@ export type SetQuestionTitleAction = {
287
292
  title: string;
288
293
  };
289
294
 
295
+ export type SetQuestionPointWeightageAction = {
296
+ type: PollsStateActionTypes.SET_POINT_WEIGHTAGE;
297
+ questionIndex: number;
298
+ pointWeightage: string;
299
+ };
300
+
290
301
  export type AddQuestionOptionAction = {
291
302
  type: PollsStateActionTypes.ADD_QUESTION_OPTION;
292
303
  questionIndex: number;
@@ -305,6 +316,13 @@ export type EditQuestionOptionAction = {
305
316
  option: string;
306
317
  };
307
318
 
319
+ export type SetQuestionCorrectOptionAction = {
320
+ type: PollsStateActionTypes.SET_QUESTION_CORRECT_OPTION;
321
+ questionIndex: number;
322
+ optionIndex: number;
323
+ correctOption: boolean;
324
+ };
325
+
308
326
  export type SetQuestionSkippable = {
309
327
  type: PollsStateActionTypes.SET_QUESTION_SKIPPABLE;
310
328
  questionIndex: number;
@@ -384,9 +402,11 @@ export enum PollsStateActionTypes {
384
402
  SET_SELECTED_QUESTION_INDEX = 'SET_SELECTED_QUESTION_INDEX',
385
403
  SET_QUESTION_TYPE = 'SET_QUESTION_TYPE',
386
404
  SET_QUESTION_TITLE = 'SET_QUESTION_TITLE',
405
+ SET_POINT_WEIGHTAGE = 'SET_POINT_WEIGHTAGE',
387
406
  ADD_QUESTION_OPTION = 'ADD_QUESTION_OPTION',
388
407
  DELETE_QUESTION_OPTION = 'DELETE_QUESTION_OPTION',
389
408
  EDIT_QUESTION_OPTION = 'EDIT_QUESTION_OPTION',
409
+ SET_QUESTION_CORRECT_OPTION = 'SET_QUESTION_CORRECT_OPTION',
390
410
  SET_QUESTION_SKIPPABLE = 'SET_QUESTION_SKIPPABLE',
391
411
  SET_QUESTION_RES_EDITABLE = 'SET_QUESTION_RES_EDITABLE',
392
412
  SET_QUESTION_SAVED = 'SET_QUESTION_SAVED',