import isNil from 'lodash/isNil'; import React, { memo } from 'react'; import { View, Text } from 'react-native'; import { getDefaultValue } from '../helpers'; import Theme from '../theme'; import DividerLine from './divider-line'; import DividerLineDashed from './divider-line-dashed'; import type { DividerProps } from './interface'; import { varCreator, styleCreator } from './style'; /** * Divider 分割线 * @description 用于将内容分隔为多个区域。 */ const Divider: React.FC = ({ children, style, textStyle, type = 'light', direction = 'horizontal', dashed = false, color, contentPosition = 'center', }) => { const TOKENS = Theme.useThemeTokens(); const CV = Theme.createVar(TOKENS, varCreator); // @ts-ignore const STYLES = Theme.createStyle(CV, styleCreator); const isVertical = direction === 'vertical'; const Line = dashed ? DividerLineDashed : DividerLine; color = getDefaultValue( color, type === 'dark' ? CV.divider_color_dark : CV.divider_color_light ); return ( {isVertical ? ( // @ts-ignore ) : !isNil(children) ? ( <> {children} ) : ( // @ts-ignore )} ); }; export default memo(Divider);