@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.
Files changed (168) hide show
  1. package/lib/commonjs/HMSRoomSetup.js +13 -1
  2. package/lib/commonjs/HMSRoomSetup.js.map +1 -1
  3. package/lib/commonjs/Icons/Clock/assets/clock-vector.png +0 -0
  4. package/lib/commonjs/Icons/Clock/assets/clock-vector@2x.png +0 -0
  5. package/lib/commonjs/Icons/Clock/assets/clock-vector@3x.png +0 -0
  6. package/lib/commonjs/Icons/Clock/assets/clock.png +0 -0
  7. package/lib/commonjs/Icons/Clock/assets/clock@2x.png +0 -0
  8. package/lib/commonjs/Icons/Clock/assets/clock@3x.png +0 -0
  9. package/lib/commonjs/Icons/Clock/index.js +7 -2
  10. package/lib/commonjs/Icons/Clock/index.js.map +1 -1
  11. package/lib/commonjs/components/CreatePoll.js +3 -2
  12. package/lib/commonjs/components/CreatePoll.js.map +1 -1
  13. package/lib/commonjs/components/HLSView.js +15 -1
  14. package/lib/commonjs/components/HLSView.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/LeaderboardEntry.js +135 -0
  18. package/lib/commonjs/components/LeaderboardEntry.js.map +1 -0
  19. package/lib/commonjs/components/PollAndQuizSheetScreen.js +69 -0
  20. package/lib/commonjs/components/PollAndQuizSheetScreen.js.map +1 -0
  21. package/lib/commonjs/components/PollAndQuizVoting.js +133 -4
  22. package/lib/commonjs/components/PollAndQuizVoting.js.map +1 -1
  23. package/lib/commonjs/components/PollQuestions.js +104 -4
  24. package/lib/commonjs/components/PollQuestions.js.map +1 -1
  25. package/lib/commonjs/components/PollsAndQuizBottomSheet.js +9 -11
  26. package/lib/commonjs/components/PollsAndQuizBottomSheet.js.map +1 -1
  27. package/lib/commonjs/components/PollsAndQuizzesCard.js +1 -1
  28. package/lib/commonjs/components/PollsAndQuizzesCard.js.map +1 -1
  29. package/lib/commonjs/components/PollsAndQuizzesModalContent.js +26 -120
  30. package/lib/commonjs/components/PollsAndQuizzesModalContent.js.map +1 -1
  31. package/lib/commonjs/components/PollsConfigAndList.js +81 -4
  32. package/lib/commonjs/components/PollsConfigAndList.js.map +1 -1
  33. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js +7 -15
  34. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js.map +1 -1
  35. package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js +284 -0
  36. package/lib/commonjs/components/QuizLeaderboardEntriesScreen.js.map +1 -0
  37. package/lib/commonjs/components/QuizLeaderboardScreen.js +279 -0
  38. package/lib/commonjs/components/QuizLeaderboardScreen.js.map +1 -0
  39. package/lib/commonjs/components/QuizLeaderboardSummary.js +195 -0
  40. package/lib/commonjs/components/QuizLeaderboardSummary.js.map +1 -0
  41. package/lib/commonjs/components/VoterParticipationSummary.js +46 -0
  42. package/lib/commonjs/components/VoterParticipationSummary.js.map +1 -0
  43. package/lib/commonjs/redux/actionTypes.js +7 -1
  44. package/lib/commonjs/redux/actionTypes.js.map +1 -1
  45. package/lib/commonjs/redux/actions/index.js +25 -5
  46. package/lib/commonjs/redux/actions/index.js.map +1 -1
  47. package/lib/commonjs/redux/reducers/polls.js +65 -5
  48. package/lib/commonjs/redux/reducers/polls.js.map +1 -1
  49. package/lib/commonjs/utils/hooks.js +107 -2
  50. package/lib/commonjs/utils/hooks.js.map +1 -1
  51. package/lib/module/HMSRoomSetup.js +13 -1
  52. package/lib/module/HMSRoomSetup.js.map +1 -1
  53. package/lib/module/Icons/Clock/assets/clock-vector.png +0 -0
  54. package/lib/module/Icons/Clock/assets/clock-vector@2x.png +0 -0
  55. package/lib/module/Icons/Clock/assets/clock-vector@3x.png +0 -0
  56. package/lib/module/Icons/Clock/assets/clock.png +0 -0
  57. package/lib/module/Icons/Clock/assets/clock@2x.png +0 -0
  58. package/lib/module/Icons/Clock/assets/clock@3x.png +0 -0
  59. package/lib/module/Icons/Clock/index.js +7 -2
  60. package/lib/module/Icons/Clock/index.js.map +1 -1
  61. package/lib/module/components/CreatePoll.js +4 -3
  62. package/lib/module/components/CreatePoll.js.map +1 -1
  63. package/lib/module/components/HLSView.js +17 -3
  64. package/lib/module/components/HLSView.js.map +1 -1
  65. package/lib/module/components/HMSPollsQuizzesNotification.js +2 -2
  66. package/lib/module/components/HMSPollsQuizzesNotification.js.map +1 -1
  67. package/lib/module/components/LeaderboardEntry.js +126 -0
  68. package/lib/module/components/LeaderboardEntry.js.map +1 -0
  69. package/lib/module/components/PollAndQuizSheetScreen.js +60 -0
  70. package/lib/module/components/PollAndQuizSheetScreen.js.map +1 -0
  71. package/lib/module/components/PollAndQuizVoting.js +135 -6
  72. package/lib/module/components/PollAndQuizVoting.js.map +1 -1
  73. package/lib/module/components/PollQuestions.js +107 -7
  74. package/lib/module/components/PollQuestions.js.map +1 -1
  75. package/lib/module/components/PollsAndQuizBottomSheet.js +11 -13
  76. package/lib/module/components/PollsAndQuizBottomSheet.js.map +1 -1
  77. package/lib/module/components/PollsAndQuizzesCard.js +2 -2
  78. package/lib/module/components/PollsAndQuizzesCard.js.map +1 -1
  79. package/lib/module/components/PollsAndQuizzesModalContent.js +28 -122
  80. package/lib/module/components/PollsAndQuizzesModalContent.js.map +1 -1
  81. package/lib/module/components/PollsConfigAndList.js +82 -5
  82. package/lib/module/components/PollsConfigAndList.js.map +1 -1
  83. package/lib/module/components/PreviousPollsAndQuizzesList.js +7 -15
  84. package/lib/module/components/PreviousPollsAndQuizzesList.js.map +1 -1
  85. package/lib/module/components/QuizLeaderboardEntriesScreen.js +275 -0
  86. package/lib/module/components/QuizLeaderboardEntriesScreen.js.map +1 -0
  87. package/lib/module/components/QuizLeaderboardScreen.js +270 -0
  88. package/lib/module/components/QuizLeaderboardScreen.js.map +1 -0
  89. package/lib/module/components/QuizLeaderboardSummary.js +186 -0
  90. package/lib/module/components/QuizLeaderboardSummary.js.map +1 -0
  91. package/lib/module/components/VoterParticipationSummary.js +37 -0
  92. package/lib/module/components/VoterParticipationSummary.js.map +1 -0
  93. package/lib/module/redux/actionTypes.js +7 -1
  94. package/lib/module/redux/actionTypes.js.map +1 -1
  95. package/lib/module/redux/actions/index.js +18 -3
  96. package/lib/module/redux/actions/index.js.map +1 -1
  97. package/lib/module/redux/reducers/polls.js +65 -5
  98. package/lib/module/redux/reducers/polls.js.map +1 -1
  99. package/lib/module/utils/hooks.js +105 -2
  100. package/lib/module/utils/hooks.js.map +1 -1
  101. package/lib/typescript/HMSRoomSetup.d.ts.map +1 -1
  102. package/lib/typescript/Icons/Clock/index.d.ts +1 -0
  103. package/lib/typescript/Icons/Clock/index.d.ts.map +1 -1
  104. package/lib/typescript/components/CreatePoll.d.ts.map +1 -1
  105. package/lib/typescript/components/HLSView.d.ts.map +1 -1
  106. package/lib/typescript/components/LeaderboardEntry.d.ts +11 -0
  107. package/lib/typescript/components/LeaderboardEntry.d.ts.map +1 -0
  108. package/lib/typescript/components/PollAndQuizSheetScreen.d.ts +8 -0
  109. package/lib/typescript/components/PollAndQuizSheetScreen.d.ts.map +1 -0
  110. package/lib/typescript/components/PollAndQuizVoting.d.ts +2 -0
  111. package/lib/typescript/components/PollAndQuizVoting.d.ts.map +1 -1
  112. package/lib/typescript/components/PollQuestions.d.ts +2 -0
  113. package/lib/typescript/components/PollQuestions.d.ts.map +1 -1
  114. package/lib/typescript/components/PollsAndQuizBottomSheet.d.ts.map +1 -1
  115. package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts +0 -1
  116. package/lib/typescript/components/PollsAndQuizzesModalContent.d.ts.map +1 -1
  117. package/lib/typescript/components/PollsConfigAndList.d.ts +1 -0
  118. package/lib/typescript/components/PollsConfigAndList.d.ts.map +1 -1
  119. package/lib/typescript/components/PreviousPollsAndQuizzesList.d.ts.map +1 -1
  120. package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts +8 -0
  121. package/lib/typescript/components/QuizLeaderboardEntriesScreen.d.ts.map +1 -0
  122. package/lib/typescript/components/QuizLeaderboardScreen.d.ts +8 -0
  123. package/lib/typescript/components/QuizLeaderboardScreen.d.ts.map +1 -0
  124. package/lib/typescript/components/QuizLeaderboardSummary.d.ts +9 -0
  125. package/lib/typescript/components/QuizLeaderboardSummary.d.ts.map +1 -0
  126. package/lib/typescript/components/VoterParticipationSummary.d.ts +7 -0
  127. package/lib/typescript/components/VoterParticipationSummary.d.ts.map +1 -0
  128. package/lib/typescript/redux/actionTypes.d.ts +29 -8
  129. package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
  130. package/lib/typescript/redux/actions/index.d.ts +6 -2
  131. package/lib/typescript/redux/actions/index.d.ts.map +1 -1
  132. package/lib/typescript/redux/index.d.ts +2 -1
  133. package/lib/typescript/redux/index.d.ts.map +1 -1
  134. package/lib/typescript/redux/reducers/index.d.ts +2 -1
  135. package/lib/typescript/redux/reducers/index.d.ts.map +1 -1
  136. package/lib/typescript/redux/reducers/polls.d.ts +3 -2
  137. package/lib/typescript/redux/reducers/polls.d.ts.map +1 -1
  138. package/lib/typescript/utils/hooks.d.ts +6 -0
  139. package/lib/typescript/utils/hooks.d.ts.map +1 -1
  140. package/package.json +3 -3
  141. package/src/HMSRoomSetup.tsx +19 -1
  142. package/src/Icons/Clock/assets/clock-vector.png +0 -0
  143. package/src/Icons/Clock/assets/clock-vector@2x.png +0 -0
  144. package/src/Icons/Clock/assets/clock-vector@3x.png +0 -0
  145. package/src/Icons/Clock/assets/clock.png +0 -0
  146. package/src/Icons/Clock/assets/clock@2x.png +0 -0
  147. package/src/Icons/Clock/assets/clock@3x.png +0 -0
  148. package/src/Icons/Clock/index.tsx +16 -3
  149. package/src/components/CreatePoll.tsx +7 -2
  150. package/src/components/HLSView.tsx +27 -1
  151. package/src/components/HMSPollsQuizzesNotification.tsx +2 -2
  152. package/src/components/LeaderboardEntry.tsx +172 -0
  153. package/src/components/PollAndQuizSheetScreen.tsx +85 -0
  154. package/src/components/PollAndQuizVoting.tsx +181 -7
  155. package/src/components/PollQuestions.tsx +171 -49
  156. package/src/components/PollsAndQuizBottomSheet.tsx +20 -42
  157. package/src/components/PollsAndQuizzesCard.tsx +2 -2
  158. package/src/components/PollsAndQuizzesModalContent.tsx +40 -163
  159. package/src/components/PollsConfigAndList.tsx +107 -11
  160. package/src/components/PreviousPollsAndQuizzesList.tsx +33 -40
  161. package/src/components/QuizLeaderboardEntriesScreen.tsx +323 -0
  162. package/src/components/QuizLeaderboardScreen.tsx +342 -0
  163. package/src/components/QuizLeaderboardSummary.tsx +207 -0
  164. package/src/components/VoterParticipationSummary.tsx +67 -0
  165. package/src/redux/actionTypes.ts +35 -5
  166. package/src/redux/actions/index.ts +34 -6
  167. package/src/redux/reducers/polls.ts +84 -6
  168. 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={{ flex: 1 }}>
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
- <Text style={[styles.normalText, hmsRoomStyles.semiBoldMediumText]}>
90
- {selectedPoll?.createdBy?.name} started a{' '}
91
- {selectedPoll?.type === HMSPollType.quiz ? 'quiz' : 'poll'}
92
- </Text>
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
- <ScrollView
190
- style={styles.contentContainer}
191
- contentContainerStyle={{ paddingTop: 24 }}
192
- >
193
- {questions.map((pollQuestion, idx, arr) => {
194
- const isFirst = idx === 0;
195
- return (
196
- <React.Fragment key={idx}>
197
- {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}
198
235
 
199
- <PollQuestion
200
- totalQuestions={arr.length}
201
- currentQuestionIndex={idx}
202
- pollQuestion={pollQuestion}
203
- onAddPollQuestionOption={handleAddPollQuestionOption}
204
- onDeletePollQuestionOption={handleDeletePollQuestionOption}
205
- onEditPollQuestionOption={handleEditPollQuestionOption}
206
- onSetPollQuestionCorrectOption={
207
- handleSetPollQuestionCorrectOption
208
- }
209
- onQuestionFieldChange={onQuestionFieldChange}
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={addQuestion}
219
- disabled={launchingPoll}
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
- <View style={styles.addOptionIconWrapper}>
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
- <HMSPrimaryButton
235
- disabled={disableLaunchPoll || launchingPoll}
236
- title={`Launch ${pollType === HMSPollType.quiz ? 'Quiz' : 'Poll'}`}
237
- loading={launchingPoll}
238
- onPress={launchPoll}
239
- style={{ marginTop: 16, marginBottom: 56, alignSelf: 'flex-end' }}
240
- />
241
- </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>
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 { 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
  };