import { Pressable, View } from 'react-native'; import type { IconNameType } from '../../assets'; import { useConfigContext } from '../../config'; import { getElement, useColors } from '../../hook'; import { useI18nContext } from '../../i18n'; import { usePaletteContext } from '../../theme'; import { IconButton } from '../../ui/Button'; import { Icon } from '../../ui/Image'; import { SingleLineText } from '../../ui/Text'; import { BackButton } from '../Back'; import type { TopNavigationBarProps } from './types'; /** * Top Navigation Bar Component. * * This component is usually displayed at the top of the page-level component, with a left-center-right layout. It generally provides a return button on the left, a title in the middle, and an expand button on the right. */ export function TopNavigationBar( props: TopNavigationBarProps ) { const { containerStyle, Title, Left, Right, LeftProps, RightProps } = props; const { getColor } = useColors(); return ( {getElement(Left as any, LeftProps)} {Title} {getElement(Right as any, RightProps)} ); } /** * The component on the right side of the navigation bar. */ export function TopNavigationBarRight({ onClicked, iconName, }: { onClicked?: () => void; iconName: IconNameType; }) { const { colors } = usePaletteContext(); const { getColor } = useColors({ fg2: { light: colors.neutral[3], dark: colors.neutral[95], }, }); return ( ); } export function TopNavigationBarRightTextList({ onClickedList, textList, }: { onClickedList?: (() => void)[]; textList: string[]; }) { const { colors } = usePaletteContext(); const { getColor } = useColors({ fg2: { light: colors.primary[5], dark: colors.primary[6], }, }); return ( {textList[0]} ); } export function TopNavigationBarRightList({ onClickedList, iconNameList, }: { onClickedList: (() => void)[]; iconNameList: IconNameType[]; }) { const { colors } = usePaletteContext(); const { getColor } = useColors({ fg2: { light: colors.neutral[3], dark: colors.neutral[95], }, }); return ( {iconNameList.map((name, index) => { return ( ); })} ); } /** * The component on the middle side of the navigation bar. */ export function TopNavigationBarTitle({ text }: { text: string }) { const { tr } = useI18nContext(); const { headerFontFamily } = useConfigContext(); const { colors } = usePaletteContext(); const { getColor } = useColors({ title: { light: colors.primary[5], dark: colors.primary[6], }, }); return ( {tr(text)} ); } type TopNavigationBarLeftProps = { onBack?: () => void; content: string; }; export function TopNavigationBarLeft(props: TopNavigationBarLeftProps) { const { onBack, content } = props; const { getColor } = useColors(); return ( {content} ); }