import * as React from 'react'; import { View } from 'react-native'; import { useColors } from '../../hook'; import { usePaletteContext } from '../../theme'; import { gDotHeaderHeight } from './TabPage.const'; import type { TabPageHeaderProps } from './types'; export function TabPageDotHeader(props: TabPageHeaderProps) { const { propRef, onClicked, titles, containerStyle, content, initIndex } = props; const { colors } = usePaletteContext(); const { getColor } = useColors({ selected: { light: colors.neutral[5], dark: colors.neutral[5], }, no_selected: { light: colors.neutral[9], dark: colors.neutral[9], }, }); const [currentIndex, setCurrentIndex] = React.useState(initIndex ?? 0); if (propRef.current) { propRef.current.toLeft = (movedCount: number) => { if (movedCount === 0) return; const cur = currentIndex - movedCount; setCurrentIndex(cur); }; propRef.current.toRight = (movedCount: number) => { if (movedCount === 0) return; const cur = currentIndex + movedCount; setCurrentIndex(cur); }; } return ( {titles.map((_, i) => { return ( { onClicked?.(i); }} /> ); })} ); } export type TabPageDotHeaderComponent = typeof TabPageDotHeader;