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