import React from 'react'; import { View, Text, Pressable, StyleProp, ViewStyle } from 'react-native'; import { Tabs, MaterialTabBar } from 'react-native-collapsible-tab-view'; import { styles } from './styles'; import { Colors } from 'src/theme'; import MarkToUpIcon from '../../../assets/icons/mark-to-up.svg'; import BanIcon from 'assets/icons/messages/ban.svg'; import MessagesDot from '../MessagesDot'; interface Route { key: string; title?: string; icon?: string; } type Props = { index: number; setIndex: React.Dispatch>; routes: Route[]; renderScene: (props: { route: any }) => React.ReactNode; withMark?: boolean; lazy?: boolean; withNotification?: number; maxTabHeight?: number; tabBarStyle?: StyleProp; sceneStyles?: StyleProp; }; export const HorizontalTabView: React.FC = ({ index, setIndex, routes, renderScene, withMark, lazy = false, withNotification = 0, maxTabHeight, tabBarStyle = {}, sceneStyles = {} }) => { const TabItemComponent = ({ name, index: tabIndex, onPress, label, style, onLayout }: any) => { const fullRoute = routes.find((r) => r.key === name); return ( onPress(name)} onLayout={onLayout} style={[styles.tabLabelWrapper, style, withNotification > 0 ? { marginTop: 3 } : {}]} > {fullRoute?.icon === 'ban' ? ( ) : ( {fullRoute?.title ?? label} )} {withMark ? ( ) : null} {withNotification > 0 && fullRoute?.key === 'received' ? ( ) : null} ); }; return ( ( )} onIndexChange={setIndex} initialTabName={routes[index]?.key} lazy={lazy} headerHeight={0} headerContainerStyle={styles.tabBar} containerStyle={[tabBarStyle]} tabBarHeight={40} > {routes.map((route) => ( {renderScene({ route })} ))} ); };