UNPKG

@fruits-chain/react-native-xiaoshu

Version:
56 lines (54 loc) • 1.82 kB
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 './line'; import { varCreator, styleCreator } from './style'; /** * Divider 分割线 * @description 用于将内容分隔为多个区域。 */ const Divider = _ref => { let { children, style, textStyle, type = 'light', direction = 'horizontal', dashed = false, color, contentPosition = 'center' } = _ref; const TOKENS = Theme.useThemeTokens(); const CV = Theme.createVar(TOKENS, varCreator); const STYLES = Theme.createStyle(CV, styleCreator); const isVertical = direction === 'vertical'; color = getDefaultValue(color, type === 'dark' ? CV.divider_color_dark : CV.divider_color_light); return /*#__PURE__*/React.createElement(View, { style: [STYLES.divider, isVertical ? STYLES.divider_vertical : null, style] }, isVertical ? /*#__PURE__*/React.createElement(DividerLine, { color: color, dashed: dashed, position: "center", direction: direction }) : !isNil(children) ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DividerLine, { color: color, dashed: dashed, position: "left", adaptive: contentPosition !== 'left' }), /*#__PURE__*/React.createElement(Text, { style: [STYLES.text, textStyle] }, children), /*#__PURE__*/React.createElement(DividerLine, { color: color, dashed: dashed, position: "right", adaptive: contentPosition !== 'right' })) : /*#__PURE__*/React.createElement(DividerLine, { color: color, dashed: dashed, position: "center" })); }; export default /*#__PURE__*/memo(Divider); //# sourceMappingURL=index.js.map