import React, { FC, memo } from 'react'; import { View, StyleSheet, Text } from 'react-native'; import type { ViewStyle } from 'react-native'; import Dash from '../Dash'; import { useThemeFactory } from '../Theme'; import { createStyle } from './style'; import type { DividerProps } from './interface'; const Divider: FC = props => { const { children, textStyle, lineStyle, style, dashed = false, hairline = true, contentPosition = 'center', } = props; const { styles } = useThemeFactory(createStyle, { dashed, hairline, contentPosition }); const styleSummary: ViewStyle = StyleSheet.flatten([styles.divider, style]); const renderLine = (extraStyle: ViewStyle = {}) => { const styleFlatten = StyleSheet.flatten([styles.line, extraStyle, lineStyle]); return dashed ? ( ) : ( ); }; if (children) { return ( {renderLine(styles.lineLeft)} {children} {renderLine(styles.lineRight)} ); } return {renderLine()}; }; export default memo(Divider);