import React from 'react'; import { Text, Pressable, View, ScrollView } from 'react-native'; import Emoji from '../message/Emoji'; import { useTheme } from '../../theme'; import { IReaction } from '../../definitions'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import I18n from '../../i18n'; import styles, { MIN_TAB_WIDTH } from './styles'; import { useDimensions, useOrientation } from '../../dimensions'; interface ITabBarItem { getCustomEmoji: TGetCustomEmoji; tab: IReaction; index: number; goToPage?: (index: number) => void; } interface IReactionsTabBar { getCustomEmoji: TGetCustomEmoji; activeTab?: number; tabs?: IReaction[]; goToPage?: (index: number) => void; } const TabBarItem = ({ tab, index, goToPage, getCustomEmoji }: ITabBarItem) => { const { colors } = useTheme(); return ( { goToPage?.(index); }} style={({ pressed }: { pressed: boolean }) => ({ opacity: pressed ? 0.7 : 1 })} testID={`tabBarItem-${tab.emoji}`} > {tab._id === 'All' ? ( {I18n.t('All')} ) : ( <> {tab.usernames.length} )} ); }; const ReactionsTabBar = ({ tabs, activeTab, goToPage, getCustomEmoji }: IReactionsTabBar): React.ReactElement => { const { isLandscape } = useOrientation(); const { width } = useDimensions(); const reactionsListWidth = isLandscape ? width / 2 : width; const tabWidth = tabs && Math.max(reactionsListWidth / tabs.length, MIN_TAB_WIDTH); const { colors } = useTheme(); return ( {tabs?.map((tab, index) => { const isActiveTab = activeTab === index; return ( ); })} ); }; export default ReactionsTabBar;