@100mslive/react-native-room-kit 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/commonjs/HMSRoomSetup.js +15 -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/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 +100 -53
- 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/HLSView.js +15 -1
- package/lib/commonjs/components/HLSView.js.map +1 -1
- package/lib/commonjs/components/HMSPollsQuizzesNotification.js +2 -2
- 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/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/PollAndQuizSheetScreen.js +69 -0
- package/lib/commonjs/components/PollAndQuizSheetScreen.js.map +1 -0
- package/lib/commonjs/components/PollAndQuizVoting.js +145 -17
- 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 +126 -12
- 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/QuizEndOptionsView.js +63 -0
- package/lib/commonjs/components/QuizEndOptionsView.js.map +1 -0
- 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/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/components/VoterParticipationSummary.js +46 -0
- package/lib/commonjs/components/VoterParticipationSummary.js.map +1 -0
- package/lib/commonjs/hooks-util.js +1 -1
- package/lib/commonjs/hooks-util.js.map +1 -1
- package/lib/commonjs/redux/actionTypes.js +9 -1
- package/lib/commonjs/redux/actionTypes.js.map +1 -1
- package/lib/commonjs/redux/actions/index.js +38 -5
- package/lib/commonjs/redux/actions/index.js.map +1 -1
- package/lib/commonjs/redux/reducers/polls.js +95 -8
- 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/commonjs/utils/hooks.js +107 -2
- package/lib/commonjs/utils/hooks.js.map +1 -1
- package/lib/module/HMSRoomSetup.js +16 -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/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 +102 -56
- 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/HLSView.js +17 -3
- package/lib/module/components/HLSView.js.map +1 -1
- package/lib/module/components/HMSPollsQuizzesNotification.js +3 -3
- 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/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/PollAndQuizSheetScreen.js +60 -0
- package/lib/module/components/PollAndQuizSheetScreen.js.map +1 -0
- package/lib/module/components/PollAndQuizVoting.js +148 -20
- 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 +129 -15
- 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/QuizEndOptionsView.js +54 -0
- package/lib/module/components/QuizEndOptionsView.js.map +1 -0
- 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/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/components/VoterParticipationSummary.js +37 -0
- package/lib/module/components/VoterParticipationSummary.js.map +1 -0
- package/lib/module/hooks-util.js +2 -4
- package/lib/module/hooks-util.js.map +1 -1
- package/lib/module/redux/actionTypes.js +9 -1
- package/lib/module/redux/actionTypes.js.map +1 -1
- package/lib/module/redux/actions/index.js +29 -3
- package/lib/module/redux/actions/index.js.map +1 -1
- package/lib/module/redux/reducers/polls.js +96 -9
- 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/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/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/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/GridView.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/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/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/PollQuestion.d.ts +1 -0
- package/lib/typescript/components/PollQuestion.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/QuizEndOptionsView.d.ts +10 -0
- package/lib/typescript/components/QuizEndOptionsView.d.ts.map +1 -0
- 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/RadioInput.d.ts +1 -0
- package/lib/typescript/components/RadioInput.d.ts.map +1 -1
- package/lib/typescript/components/VoterParticipationSummary.d.ts +7 -0
- package/lib/typescript/components/VoterParticipationSummary.d.ts.map +1 -0
- package/lib/typescript/hooks-util.d.ts.map +1 -1
- package/lib/typescript/redux/actionTypes.d.ts +45 -9
- package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
- package/lib/typescript/redux/actions/index.d.ts +8 -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/functions.d.ts +6 -2
- package/lib/typescript/utils/functions.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 +25 -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/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 +150 -72
- package/src/components/GridView.tsx +4 -14
- package/src/components/HLSView.tsx +27 -1
- package/src/components/HMSPollsQuizzesNotification.tsx +3 -3
- package/src/components/LeaderboardEntry.tsx +172 -0
- package/src/components/PollAndQuizQuestionResponseCard.tsx +151 -48
- package/src/components/PollAndQuizQuestionResponseCards.tsx +62 -0
- package/src/components/PollAndQuizSheetScreen.tsx +85 -0
- package/src/components/PollAndQuizVoting.tsx +206 -28
- package/src/components/PollQuestion.tsx +140 -25
- package/src/components/PollQuestions.tsx +214 -74
- 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/QuizEndOptionsView.tsx +71 -0
- package/src/components/QuizLeaderboardEntriesScreen.tsx +323 -0
- package/src/components/QuizLeaderboardScreen.tsx +342 -0
- package/src/components/QuizLeaderboardSummary.tsx +207 -0
- package/src/components/RadioInput.tsx +14 -2
- package/src/components/RoomSettingsModalContent.tsx +1 -1
- package/src/components/TilesContainer.tsx +4 -4
- package/src/components/VoterParticipationSummary.tsx +67 -0
- package/src/hooks-util.ts +1 -3
- package/src/redux/actionTypes.ts +56 -6
- package/src/redux/actions/index.ts +56 -6
- package/src/redux/reducers/polls.ts +139 -11
- package/src/utils/functions.ts +90 -6
- package/src/utils/hooks.ts +190 -3
|
@@ -5,22 +5,43 @@ import {
|
|
|
5
5
|
ScrollView,
|
|
6
6
|
findNodeHandle,
|
|
7
7
|
UIManager,
|
|
8
|
+
View,
|
|
9
|
+
Keyboard,
|
|
10
|
+
TouchableOpacity,
|
|
8
11
|
} from 'react-native';
|
|
9
|
-
import { useSelector } from 'react-redux';
|
|
10
|
-
import { HMSPollState } from '@100mslive/react-native-hms';
|
|
12
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
13
|
+
import { HMSPollState, HMSPollType } from '@100mslive/react-native-hms';
|
|
11
14
|
|
|
12
15
|
import { useHMSInstance, useHMSRoomStyleSheet } from '../hooks-util';
|
|
13
16
|
import type { RootState } from '../redux';
|
|
14
|
-
import { PollAndQuizQuestionResponseCard } from './PollAndQuizQuestionResponseCard';
|
|
15
17
|
import { HMSDangerButton } from './HMSDangerButton';
|
|
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';
|
|
16
29
|
|
|
17
30
|
export interface PollAndQuizVotingProps {
|
|
31
|
+
currentIdx: number;
|
|
18
32
|
dismissModal(): void;
|
|
33
|
+
unmountScreenWithAnimation?(cb: Function): void;
|
|
19
34
|
}
|
|
20
35
|
|
|
21
|
-
export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = (
|
|
36
|
+
export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = ({
|
|
37
|
+
currentIdx,
|
|
38
|
+
dismissModal,
|
|
39
|
+
unmountScreenWithAnimation,
|
|
40
|
+
}) => {
|
|
22
41
|
const scrollViewRef = React.useRef<ScrollView>(null);
|
|
23
42
|
const hmsInstance = useHMSInstance();
|
|
43
|
+
const dispatch = useDispatch();
|
|
44
|
+
|
|
24
45
|
const selectedPoll = useSelector((state: RootState) => {
|
|
25
46
|
const pollsData = state.polls;
|
|
26
47
|
if (pollsData.selectedPollId !== null) {
|
|
@@ -32,16 +53,34 @@ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
|
|
|
32
53
|
const permissions = state.hmsStates.localPeer?.role?.permissions;
|
|
33
54
|
return permissions?.pollWrite;
|
|
34
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
|
+
});
|
|
35
63
|
|
|
36
64
|
const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
|
|
37
65
|
regularMediumText: {
|
|
38
66
|
color: theme.palette.on_surface_medium,
|
|
39
67
|
fontFamily: `${typography.font_family}-Regular`,
|
|
40
68
|
},
|
|
69
|
+
semiBoldHighText: {
|
|
70
|
+
color: theme.palette.on_surface_high,
|
|
71
|
+
fontFamily: `${typography.font_family}-SemiBold`,
|
|
72
|
+
},
|
|
41
73
|
semiBoldMediumText: {
|
|
42
74
|
color: theme.palette.on_surface_medium,
|
|
43
75
|
fontFamily: `${typography.font_family}-SemiBold`,
|
|
44
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
|
+
},
|
|
45
84
|
}));
|
|
46
85
|
|
|
47
86
|
const endPoll = async () => {
|
|
@@ -78,42 +117,134 @@ export const PollAndQuizVoting: React.FC<PollAndQuizVotingProps> = () => {
|
|
|
78
117
|
);
|
|
79
118
|
};
|
|
80
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
|
+
|
|
81
138
|
return (
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
style={styles.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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 */}
|
|
182
|
+
<ScrollView
|
|
183
|
+
ref={scrollViewRef}
|
|
184
|
+
style={styles.contentContainer}
|
|
185
|
+
contentContainerStyle={{ flexGrow: 1, paddingVertical: 24 }}
|
|
186
|
+
>
|
|
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
|
+
)}
|
|
204
|
+
|
|
205
|
+
{selectedPoll ? (
|
|
206
|
+
<PollAndQuizQuestionResponseCards
|
|
207
|
+
poll={selectedPoll}
|
|
208
|
+
onVote={handleVote}
|
|
102
209
|
/>
|
|
103
|
-
)
|
|
210
|
+
) : null}
|
|
211
|
+
</ScrollView>
|
|
104
212
|
|
|
105
213
|
{selectedPoll &&
|
|
106
214
|
selectedPoll.state === HMSPollState.started &&
|
|
107
215
|
canCreateOrEndPoll ? (
|
|
108
216
|
<HMSDangerButton
|
|
109
217
|
disabled={!selectedPoll}
|
|
110
|
-
title=
|
|
218
|
+
title={
|
|
219
|
+
selectedPoll?.type === HMSPollType.quiz ? 'End Quiz' : 'End Poll'
|
|
220
|
+
}
|
|
111
221
|
loading={false}
|
|
112
222
|
onPress={endPoll}
|
|
113
|
-
style={{
|
|
223
|
+
style={{
|
|
224
|
+
marginTop: 16,
|
|
225
|
+
marginBottom: 16,
|
|
226
|
+
marginRight: 24,
|
|
227
|
+
alignSelf: 'flex-end',
|
|
228
|
+
}}
|
|
229
|
+
/>
|
|
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
|
+
}}
|
|
114
245
|
/>
|
|
115
246
|
) : null}
|
|
116
|
-
</
|
|
247
|
+
</View>
|
|
117
248
|
);
|
|
118
249
|
};
|
|
119
250
|
|
|
@@ -154,4 +285,51 @@ const styles = StyleSheet.create({
|
|
|
154
285
|
marginRight: 8,
|
|
155
286
|
padding: 8,
|
|
156
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
|
+
},
|
|
157
335
|
});
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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.
|
|
169
|
-
hmsRoomStyles.
|
|
170
|
-
{
|
|
191
|
+
styles.smallerText,
|
|
192
|
+
hmsRoomStyles.regularMediumText,
|
|
193
|
+
{ marginTop: 4 },
|
|
171
194
|
]}
|
|
172
195
|
>
|
|
173
|
-
{pollQuestion.
|
|
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={{
|
|
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,
|