@100mslive/react-native-room-kit
Version:
100ms Room Kit provides simple & easy to use UI components to build Live Streaming & Video Conferencing experiences in your apps.
59 lines • 2.4 kB
JavaScript
import * as React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { useSelector } from 'react-redux';
import { useHMSRoomStyleSheet, useIsHLSViewer } from '../hooks-util';
import { PollsAndQuizzesCard } from './PollsAndQuizzesCard';
import { visiblePollsSelector } from '../utils/functions';
export const PreviousPollsAndQuizzesList = ({}) => {
const isHLSViewer = useIsHLSViewer();
const polls = useSelector(state => state.polls.polls);
const hlsCuedPollIds = useSelector(state => state.polls.cuedPollIds);
const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
surfaceHighSemiBoldText: {
color: theme.palette.on_surface_high,
fontFamily: `${typography.font_family}-SemiBold`
},
surfaceHighRegularText: {
color: theme.palette.on_surface_high,
fontFamily: `${typography.font_family}-Regular`
}
}));
const pollsList = visiblePollsSelector(Object.values(polls), isHLSViewer, hlsCuedPollIds);
return /*#__PURE__*/React.createElement(View, {
style: styles.contentContainer
}, /*#__PURE__*/React.createElement(Text, {
style: [styles.title, hmsRoomStyles.surfaceHighSemiBoldText]
}, "Previous Polls And Quizzes"), pollsList.length <= 0 ? /*#__PURE__*/React.createElement(View, {
style: styles.contentContainer
}, /*#__PURE__*/React.createElement(Text, {
style: [styles.subtitle, hmsRoomStyles.surfaceHighRegularText, styles.emptyList]
}, "No Polls or Quizzes to show")) : /*#__PURE__*/React.createElement(React.Fragment, null, pollsList.sort((a, b) => {
return a.state === b.state // If polls have same state, then sort as per startedAt
? a.startedAt !== undefined && b.startedAt !== undefined ? b.startedAt.getTime() - a.startedAt.getTime() : 0 :
// If polls have different state, then sort as per state
a.state !== undefined && b.state !== undefined ? a.state - b.state : 0;
}).map(poll => /*#__PURE__*/React.createElement(PollsAndQuizzesCard, {
key: poll.pollId,
poll: poll
}))));
};
const styles = StyleSheet.create({
contentContainer: {
marginHorizontal: 24
},
title: {
fontSize: 20,
lineHeight: 24,
letterSpacing: 0.15,
marginVertical: 24
},
subtitle: {
fontSize: 16,
lineHeight: 20,
marginVertical: 24
},
emptyList: {
textAlign: 'center'
}
});
//# sourceMappingURL=PreviousPollsAndQuizzesList.js.map