import React, { useCallback, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { FlatList, TextStyle, View, ViewStyle } from 'react-native';
import { Text } from 'react-native-paper';
import { useSelector } from 'react-redux';
import { IReduxState } from '../../../app/types';
import Icon from '../../../base/icons/components/Icon';
import { IconMessage } from '../../../base/icons/svg';
import BaseTheme from '../../../base/ui/components/BaseTheme.native';
import PollItem from './PollItem';
import { pollsStyles } from './styles';
interface IPollListProps {
setCreateMode: (mode: boolean) => void;
}
const PollsList = ({ setCreateMode }: IPollListProps) => {
const polls = useSelector((state: IReduxState) => state['features/polls'].polls);
const { t } = useTranslation();
const listPolls = Object.keys(polls);
const renderItem = useCallback(({ item }) => (
)
, []);
const flatlistRef = useRef(null);
const scrollToBottom = () => {
flatlistRef.current?.scrollToEnd({ animated: true });
};
useEffect(() => {
scrollToBottom();
}, [ polls ]);
return (
<>
{
listPolls.length === 0
&&
{
t('polls.results.empty')
}
}
index.toString() }
ref = { flatlistRef }
renderItem = { renderItem } />
>
);
};
export default PollsList;