import { ArrowLeftOutline } from '@fruits-chain/icons-react-native'; import isNil from 'lodash/isNil'; import React, { memo } from 'react'; import { View, TouchableOpacity } from 'react-native'; import { varCreator as varCreatorButton } from '../button/style'; import Divider from '../divider'; import { getDefaultValue, renderTextLikeJSX } from '../helpers'; import Theme from '../theme'; import type { NavBarProps } from './interface'; import { varCreator, styleCreator } from './style'; const BACK_ARROW_HIT_SLOP = { left: 10, right: 10, // top: 0, // bottom: 0, }; /** * NavBar 导航栏 */ const NavBar: React.FC = ({ style, leftStyle, rightStyle, titleTextStyle, title, leftExtra, rightExtra, showBackArrow = true, backArrowColor, backArrowSize, divider = true, onPressBackArrow, }) => { const TOKENS = Theme.useThemeTokens(); const CV = Theme.createVar(TOKENS, varCreator); const CV_BUTTON = Theme.createVar(TOKENS, varCreatorButton); // @ts-ignore const STYLES = Theme.createStyle(CV, styleCreator); backArrowColor = getDefaultValue(backArrowColor, CV.nav_bar_icon_color); backArrowSize = getDefaultValue(backArrowSize, CV.nav_bar_arrow_size); const titleJSX = renderTextLikeJSX(title, [ STYLES.title_text, titleTextStyle, ]); return ( <> {showBackArrow || !isNil(leftExtra) ? ( {showBackArrow ? ( ) : null} {leftExtra} ) : null} {!isNil(rightExtra) ? ( {rightExtra} ) : null} {titleJSX} {divider ? : null} ); }; export default memo(NavBar);