@100mslive/react-native-room-kit 1.1.2 → 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.
- package/lib/commonjs/HMSRoomSetup.js +13 -1
- package/lib/commonjs/HMSRoomSetup.js.map +1 -1
- package/lib/commonjs/Icons/Clock/assets/clock-vector.png +0 -0
- package/lib/commonjs/Icons/Clock/assets/clock-vector@2x.png +0 -0
- package/lib/commonjs/Icons/Clock/assets/clock-vector@3x.png +0 -0
- package/lib/commonjs/Icons/Clock/assets/clock.png +0 -0
- package/lib/commonjs/Icons/Clock/assets/clock@2x.png +0 -0
- package/lib/commonjs/Icons/Clock/assets/clock@3x.png +0 -0
- package/lib/commonjs/Icons/Clock/index.js +7 -2
- package/lib/commonjs/Icons/Clock/index.js.map +1 -1
- package/lib/commonjs/components/CreatePoll.js +3 -2
- package/lib/commonjs/components/CreatePoll.js.map +1 -1
- package/lib/commonjs/components/HLSView.js +15 -1
- package/lib/commonjs/components/HLSView.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/LeaderboardEntry.js +135 -0
- package/lib/commonjs/components/LeaderboardEntry.js.map +1 -0
- package/lib/commonjs/components/PollAndQuizSheetScreen.js +69 -0
- package/lib/commonjs/components/PollAndQuizSheetScreen.js.map +1 -0
- package/lib/commonjs/components/PollAndQuizVoting.js +133 -4
- package/lib/commonjs/components/PollAndQuizVoting.js.map +1 -1
- package/lib/commonjs/components/PollQuestions.js +104 -4
- package/lib/commonjs/components/PollQuestions.js.map +1 -1
- package/lib/commonjs/components/PollsAndQuizBottomSheet.js +9 -11
- package/lib/commonjs/components/PollsAndQuizBottomSheet.js.map +1 -1
- package/lib/commonjs/components/PollsAndQuizzesCard.js +1 -1
- package/lib/commonjs/components/PollsAndQuizzesCard.js.map +1 -1
- package/lib/commonjs/components/PollsAndQuizzesModalContent.js +26 -120
- package/lib/commonjs/components/PollsAndQuizzesModalContent.js.map +1 -1
- package/lib/commonjs/components/PollsConfigAndList.js +81 -4
- package/lib/commonjs/components/PollsConfigAndList.js.map +1 -1
- package/lib/commonjs/components/PreviousPollsAndQuizzesList.js +7 -15
- package/lib/commonjs/components/PreviousPollsAndQuizzesList.js.map +1 -1
- package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js +284 -0
- package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js.map +1 -0
- package/lib/commonjs/components/QuizLeaderboardScreen.js +279 -0
- package/lib/commonjs/components/QuizLeaderboardScreen.js.map +1 -0
- package/lib/commonjs/components/QuizLeaderboardSummary.js +195 -0
- package/lib/commonjs/components/QuizLeaderboardSummary.js.map +1 -0
- package/lib/commonjs/components/VoterParticipationSummary.js +46 -0
- package/lib/commonjs/components/VoterParticipationSummary.js.map +1 -0
- package/lib/commonjs/redux/actionTypes.js +7 -1
- package/lib/commonjs/redux/actionTypes.js.map +1 -1
- package/lib/commonjs/redux/actions/index.js +25 -5
- package/lib/commonjs/redux/actions/index.js.map +1 -1
- package/lib/commonjs/redux/reducers/polls.js +65 -5
- package/lib/commonjs/redux/reducers/polls.js.map +1 -1
- package/lib/commonjs/utils/hooks.js +107 -2
- package/lib/commonjs/utils/hooks.js.map +1 -1
- package/lib/module/HMSRoomSetup.js +13 -1
- package/lib/module/HMSRoomSetup.js.map +1 -1
- package/lib/module/Icons/Clock/assets/clock-vector.png +0 -0
- package/lib/module/Icons/Clock/assets/clock-vector@2x.png +0 -0
- package/lib/module/Icons/Clock/assets/clock-vector@3x.png +0 -0
- package/lib/module/Icons/Clock/assets/clock.png +0 -0
- package/lib/module/Icons/Clock/assets/clock@2x.png +0 -0
- package/lib/module/Icons/Clock/assets/clock@3x.png +0 -0
- package/lib/module/Icons/Clock/index.js +7 -2
- package/lib/module/Icons/Clock/index.js.map +1 -1
- package/lib/module/components/CreatePoll.js +4 -3
- package/lib/module/components/CreatePoll.js.map +1 -1
- package/lib/module/components/HLSView.js +17 -3
- package/lib/module/components/HLSView.js.map +1 -1
- package/lib/module/components/HMSPollsQuizzesNotification.js +2 -2
- package/lib/module/components/HMSPollsQuizzesNotification.js.map +1 -1
- package/lib/module/components/LeaderboardEntry.js +126 -0
- package/lib/module/components/LeaderboardEntry.js.map +1 -0
- package/lib/module/components/PollAndQuizSheetScreen.js +60 -0
- package/lib/module/components/PollAndQuizSheetScreen.js.map +1 -0
- package/lib/module/components/PollAndQuizVoting.js +135 -6
- package/lib/module/components/PollAndQuizVoting.js.map +1 -1
- package/lib/module/components/PollQuestions.js +107 -7
- package/lib/module/components/PollQuestions.js.map +1 -1
- package/lib/module/components/PollsAndQuizBottomSheet.js +11 -13
- package/lib/module/components/PollsAndQuizBottomSheet.js.map +1 -1
- package/lib/module/components/PollsAndQuizzesCard.js +2 -2
- package/lib/module/components/PollsAndQuizzesCard.js.map +1 -1
- package/lib/module/components/PollsAndQuizzesModalContent.js +28 -122
- package/lib/module/components/PollsAndQuizzesModalContent.js.map +1 -1
- package/lib/module/components/PollsConfigAndList.js +82 -5
- package/lib/module/components/PollsConfigAndList.js.map +1 -1
- package/lib/module/components/PreviousPollsAndQuizzesList.js +7 -15
- package/lib/module/components/PreviousPollsAndQuizzesList.js.map +1 -1
- package/lib/module/components/QuizLeaderboardEntriesScreen.js +275 -0
- package/lib/module/components/QuizLeaderboardEntriesScreen.js.map +1 -0
- package/lib/module/components/QuizLeaderboardScreen.js +270 -0
- package/lib/module/components/QuizLeaderboardScreen.js.map +1 -0
- package/lib/module/components/QuizLeaderboardSummary.js +186 -0
- package/lib/module/components/QuizLeaderboardSummary.js.map +1 -0
- package/lib/module/components/VoterParticipationSummary.js +37 -0
- package/lib/module/components/VoterParticipationSummary.js.map +1 -0
- package/lib/module/redux/actionTypes.js +7 -1
- package/lib/module/redux/actionTypes.js.map +1 -1
- package/lib/module/redux/actions/index.js +18 -3
- package/lib/module/redux/actions/index.js.map +1 -1
- package/lib/module/redux/reducers/polls.js +65 -5
- package/lib/module/redux/reducers/polls.js.map +1 -1
- package/lib/module/utils/hooks.js +105 -2
- package/lib/module/utils/hooks.js.map +1 -1
- package/lib/typescript/HMSRoomSetup.d.ts.map +1 -1
- package/lib/typescript/Icons/Clock/index.d.ts +1 -0
- package/lib/typescript/Icons/Clock/index.d.ts.map +1 -1
- package/lib/typescript/components/CreatePoll.d.ts.map +1 -1
- package/lib/typescript/components/HLSView.d.ts.map +1 -1
- package/lib/typescript/components/LeaderboardEntry.d.ts +11 -0
- package/lib/typescript/components/LeaderboardEntry.d.ts.map +1 -0
- package/lib/typescript/components/PollAndQuizSheetScreen.d.ts +8 -0
- package/lib/typescript/components/PollAndQuizSheetScreen.d.ts.map +1 -0
- package/lib/typescript/components/PollAndQuizVoting.d.ts +2 -0
- package/lib/typescript/components/PollAndQuizVoting.d.ts.map +1 -1
- package/lib/typescript/components/PollQuestions.d.ts +2 -0
- package/lib/typescript/components/PollQuestions.d.ts.map +1 -1
- package/lib/typescript/components/PollsAndQuizBottomSheet.d.ts.map +1 -1
- package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts +0 -1
- package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts.map +1 -1
- package/lib/typescript/components/PollsConfigAndList.d.ts +1 -0
- package/lib/typescript/components/PollsConfigAndList.d.ts.map +1 -1
- package/lib/typescript/components/PreviousPollsAndQuizzesList.d.ts.map +1 -1
- package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts +8 -0
- package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts.map +1 -0
- package/lib/typescript/components/QuizLeaderboardScreen.d.ts +8 -0
- package/lib/typescript/components/QuizLeaderboardScreen.d.ts.map +1 -0
- package/lib/typescript/components/QuizLeaderboardSummary.d.ts +9 -0
- package/lib/typescript/components/QuizLeaderboardSummary.d.ts.map +1 -0
- package/lib/typescript/components/VoterParticipationSummary.d.ts +7 -0
- package/lib/typescript/components/VoterParticipationSummary.d.ts.map +1 -0
- package/lib/typescript/redux/actionTypes.d.ts +29 -8
- package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
- package/lib/typescript/redux/actions/index.d.ts +6 -2
- package/lib/typescript/redux/actions/index.d.ts.map +1 -1
- package/lib/typescript/redux/index.d.ts +2 -1
- package/lib/typescript/redux/index.d.ts.map +1 -1
- package/lib/typescript/redux/reducers/index.d.ts +2 -1
- package/lib/typescript/redux/reducers/index.d.ts.map +1 -1
- package/lib/typescript/redux/reducers/polls.d.ts +3 -2
- package/lib/typescript/redux/reducers/polls.d.ts.map +1 -1
- package/lib/typescript/utils/hooks.d.ts +6 -0
- package/lib/typescript/utils/hooks.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/HMSRoomSetup.tsx +19 -1
- package/src/Icons/Clock/assets/clock-vector.png +0 -0
- package/src/Icons/Clock/assets/clock-vector@2x.png +0 -0
- package/src/Icons/Clock/assets/clock-vector@3x.png +0 -0
- package/src/Icons/Clock/assets/clock.png +0 -0
- package/src/Icons/Clock/assets/clock@2x.png +0 -0
- package/src/Icons/Clock/assets/clock@3x.png +0 -0
- package/src/Icons/Clock/index.tsx +16 -3
- package/src/components/CreatePoll.tsx +7 -2
- package/src/components/HLSView.tsx +27 -1
- package/src/components/HMSPollsQuizzesNotification.tsx +2 -2
- package/src/components/LeaderboardEntry.tsx +172 -0
- package/src/components/PollAndQuizSheetScreen.tsx +85 -0
- package/src/components/PollAndQuizVoting.tsx +181 -7
- package/src/components/PollQuestions.tsx +171 -49
- package/src/components/PollsAndQuizBottomSheet.tsx +20 -42
- package/src/components/PollsAndQuizzesCard.tsx +2 -2
- package/src/components/PollsAndQuizzesModalContent.tsx +40 -163
- package/src/components/PollsConfigAndList.tsx +107 -11
- package/src/components/PreviousPollsAndQuizzesList.tsx +33 -40
- package/src/components/QuizLeaderboardEntriesScreen.tsx +323 -0
- package/src/components/QuizLeaderboardScreen.tsx +342 -0
- package/src/components/QuizLeaderboardSummary.tsx +207 -0
- package/src/components/VoterParticipationSummary.tsx +67 -0
- package/src/redux/actionTypes.ts +35 -5
- package/src/redux/actions/index.ts +34 -6
- package/src/redux/reducers/polls.ts +84 -6
- package/src/utils/hooks.ts +190 -3
|
@@ -6,22 +6,42 @@ import {
|
|
|
6
6
|
findNodeHandle,
|
|
7
7
|
UIManager,
|
|
8
8
|
View,
|
|
9
|
+
Keyboard,
|
|
10
|
+
TouchableOpacity,
|
|
9
11
|
} from 'react-native';
|
|
10
|
-
import { useSelector } from 'react-redux';
|
|
12
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
11
13
|
import { HMSPollState, HMSPollType } from '@100mslive/react-native-hms';
|
|
12
14
|
|
|
13
15
|
import { useHMSInstance, useHMSRoomStyleSheet } from '../hooks-util';
|
|
14
16
|
import type { RootState } from '../redux';
|
|
15
17
|
import { HMSDangerButton } from './HMSDangerButton';
|
|
16
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';
|
|
17
29
|
|
|
18
30
|
export interface PollAndQuizVotingProps {
|
|
31
|
+
currentIdx: number;
|
|
19
32
|
dismissModal(): void;
|
|
33
|
+
unmountScreenWithAnimation?(cb: Function): void;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = (
|
|
36
|
+
export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = ({
|
|
37
|
+
currentIdx,
|
|
38
|
+
dismissModal,
|
|
39
|
+
unmountScreenWithAnimation,
|
|
40
|
+
}) => {
|
|
23
41
|
const scrollViewRef = React.useRef<ScrollView>(null);
|
|
24
42
|
const hmsInstance = useHMSInstance();
|
|
43
|
+
const dispatch = useDispatch();
|
|
44
|
+
|
|
25
45
|
const selectedPoll = useSelector((state: RootState) => {
|
|
26
46
|
const pollsData = state.polls;
|
|
27
47
|
if (pollsData.selectedPollId !== null) {
|
|
@@ -33,16 +53,34 @@ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
|
|
|
33
53
|
const permissions = state.hmsStates.localPeer?.role?.permissions;
|
|
34
54
|
return permissions?.pollWrite;
|
|
35
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
|
+
});
|
|
36
63
|
|
|
37
64
|
const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
|
|
38
65
|
regularMediumText: {
|
|
39
66
|
color: theme.palette.on_surface_medium,
|
|
40
67
|
fontFamily: `${typography.font_family}-Regular`,
|
|
41
68
|
},
|
|
69
|
+
semiBoldHighText: {
|
|
70
|
+
color: theme.palette.on_surface_high,
|
|
71
|
+
fontFamily: `${typography.font_family}-SemiBold`,
|
|
72
|
+
},
|
|
42
73
|
semiBoldMediumText: {
|
|
43
74
|
color: theme.palette.on_surface_medium,
|
|
44
75
|
fontFamily: `${typography.font_family}-SemiBold`,
|
|
45
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
|
+
},
|
|
46
84
|
}));
|
|
47
85
|
|
|
48
86
|
const endPoll = async () => {
|
|
@@ -79,17 +117,90 @@ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
|
|
|
79
117
|
);
|
|
80
118
|
};
|
|
81
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
|
+
|
|
82
138
|
return (
|
|
83
|
-
<View style={
|
|
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 */}
|
|
84
182
|
<ScrollView
|
|
85
183
|
ref={scrollViewRef}
|
|
86
184
|
style={styles.contentContainer}
|
|
87
185
|
contentContainerStyle={{ flexGrow: 1, paddingVertical: 24 }}
|
|
88
186
|
>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
)}
|
|
93
204
|
|
|
94
205
|
{selectedPoll ? (
|
|
95
206
|
<PollAndQuizQuestionResponseCards
|
|
@@ -117,6 +228,22 @@ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
|
|
|
117
228
|
}}
|
|
118
229
|
/>
|
|
119
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
|
+
}}
|
|
245
|
+
/>
|
|
246
|
+
) : null}
|
|
120
247
|
</View>
|
|
121
248
|
);
|
|
122
249
|
};
|
|
@@ -158,4 +285,51 @@ const styles = StyleSheet.create({
|
|
|
158
285
|
marginRight: 8,
|
|
159
286
|
padding: 8,
|
|
160
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
|
+
},
|
|
161
335
|
});
|
|
@@ -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,6 +21,7 @@ import {
|
|
|
20
21
|
cleaPollFormState,
|
|
21
22
|
deletePollQuestionOption,
|
|
22
23
|
editPollQuestionOption,
|
|
24
|
+
popFromNavigationStack,
|
|
23
25
|
setLaunchingPoll,
|
|
24
26
|
setPollQDeleteConfirmationVisible,
|
|
25
27
|
setPollQuestionCorrectOption,
|
|
@@ -32,12 +34,20 @@ import {
|
|
|
32
34
|
setSelectedPollQuestionIndex,
|
|
33
35
|
} from '../redux/actions';
|
|
34
36
|
import type { PollQuestionUI } from '../redux/actionTypes';
|
|
37
|
+
import { PollQDeleteConfirmationSheetView } from './PollQDeleteConfirmationSheetView';
|
|
38
|
+
import { BottomSheet } from './BottomSheet';
|
|
35
39
|
|
|
36
40
|
export interface PollQuestionsProps {
|
|
41
|
+
currentIdx: number;
|
|
37
42
|
dismissModal(): void;
|
|
43
|
+
unmountScreenWithAnimation?: (cb: Function) => void;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
export const PollQuestions: React.FC<PollQuestionsProps> = ({
|
|
46
|
+
export const PollQuestions: React.FC<PollQuestionsProps> = ({
|
|
47
|
+
currentIdx,
|
|
48
|
+
dismissModal,
|
|
49
|
+
unmountScreenWithAnimation,
|
|
50
|
+
}) => {
|
|
41
51
|
const dispatch = useDispatch();
|
|
42
52
|
const hmsInstance = useHMSInstance();
|
|
43
53
|
const reduxStore = useStore<RootState>();
|
|
@@ -50,6 +60,7 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
|
|
|
50
60
|
const pollType = useSelector(
|
|
51
61
|
(state: RootState) => state.polls.pollConfig.type
|
|
52
62
|
);
|
|
63
|
+
const headerTitle = useSelector((state: RootState) => state.polls.pollName);
|
|
53
64
|
const questions = useSelector((state: RootState) => state.polls.questions);
|
|
54
65
|
|
|
55
66
|
const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
|
|
@@ -57,6 +68,13 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
|
|
|
57
68
|
color: theme.palette.on_surface_medium,
|
|
58
69
|
fontFamily: `${typography.font_family}-Regular`,
|
|
59
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
|
+
},
|
|
60
78
|
}));
|
|
61
79
|
|
|
62
80
|
const disableLaunchPoll =
|
|
@@ -185,60 +203,117 @@ export const PollQuestions: React.FC<PollQuestionsProps> = ({}) => {
|
|
|
185
203
|
[]
|
|
186
204
|
);
|
|
187
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
|
+
|
|
188
220
|
return (
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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}
|
|
198
235
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
onDelete={deleteQuestion}
|
|
211
|
-
/>
|
|
212
|
-
</React.Fragment>
|
|
213
|
-
);
|
|
214
|
-
})}
|
|
236
|
+
<Text
|
|
237
|
+
numberOfLines={2}
|
|
238
|
+
style={[
|
|
239
|
+
styles.headerText,
|
|
240
|
+
{ flexShrink: 1 },
|
|
241
|
+
hmsRoomStyles.headerText,
|
|
242
|
+
]}
|
|
243
|
+
>
|
|
244
|
+
{headerTitle}
|
|
245
|
+
</Text>
|
|
246
|
+
</View>
|
|
215
247
|
|
|
216
|
-
<View style={[styles.addOptionWrapper, { marginTop: 16 }]}>
|
|
217
248
|
<TouchableOpacity
|
|
218
|
-
onPress={
|
|
219
|
-
|
|
220
|
-
style={
|
|
221
|
-
styles.addOptionContainer,
|
|
222
|
-
launchingPoll ? { opacity: 0.4 } : null,
|
|
223
|
-
]}
|
|
249
|
+
onPress={handleClosePress}
|
|
250
|
+
hitSlop={styles.closeIconHitSlop}
|
|
251
|
+
style={{ marginLeft: 16 }}
|
|
224
252
|
>
|
|
225
|
-
<
|
|
226
|
-
<AddIcon type="circle" />
|
|
227
|
-
</View>
|
|
228
|
-
<Text style={[styles.smallText, hmsRoomStyles.regularMediumText]}>
|
|
229
|
-
Add another question
|
|
230
|
-
</Text>
|
|
253
|
+
<CloseIcon />
|
|
231
254
|
</TouchableOpacity>
|
|
232
255
|
</View>
|
|
233
256
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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>
|
|
242
317
|
);
|
|
243
318
|
};
|
|
244
319
|
|
|
@@ -274,4 +349,51 @@ const styles = StyleSheet.create({
|
|
|
274
349
|
marginRight: 8,
|
|
275
350
|
padding: 8,
|
|
276
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
|
+
},
|
|
277
399
|
});
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Platform, StyleSheet } from 'react-native';
|
|
3
|
-
import {
|
|
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
|
|
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 = () =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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={
|
|
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 {
|
|
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(
|
|
39
|
+
dispatch(pushToNavigationStack(CreatePollStages.POLL_VOTING));
|
|
40
40
|
dispatch(setSelectedPollId(poll.pollId));
|
|
41
41
|
});
|
|
42
42
|
};
|