UNPKG

@fruits-chain/react-native-xiaoshu

Version:
47 lines (44 loc) 1.73 kB
import isNil from 'lodash/isNil'; import React, { memo } from 'react'; import { View, TouchableWithoutFeedback } from 'react-native'; import Divider from '../divider'; import { renderTextLikeJSX } from '../helpers'; import Theme from '../theme'; import { varCreator } from './style'; import { styleCreator } from './style.group'; /** * CellGroup 单元格组 * @description 一组单元格,可以设置一个标题。 */ const CellGroup = _ref => { let { children, title, extra, style, titleTextStyle, bodyStyle, bodyTopDivider = false, bodyBottomDivider = false, bodyPaddingHorizontal = false, onPressTitle, onPressTitleText } = _ref; const TOKENS = Theme.useThemeTokens(); const CV = Theme.createVar(TOKENS, varCreator); const STYLES = Theme.createStyle(CV, styleCreator); /** 标题 可能是自定义 JSX */ const titleJSX = renderTextLikeJSX(title, [STYLES.text, titleTextStyle], { onPress: onPressTitleText }); const groupNameJSX = /*#__PURE__*/React.createElement(View, { style: [STYLES.title, style] }, titleJSX, extra); return /*#__PURE__*/React.createElement(React.Fragment, null, titleJSX || !isNil(extra) ? !isNil(onPressTitle) ? /*#__PURE__*/React.createElement(TouchableWithoutFeedback, { onPress: onPressTitle }, groupNameJSX) : groupNameJSX : null, /*#__PURE__*/React.createElement(View, { style: [bodyPaddingHorizontal ? STYLES.body_padding_horizontal : null, bodyStyle] }, bodyTopDivider ? /*#__PURE__*/React.createElement(Divider, null) : null, children, bodyBottomDivider ? /*#__PURE__*/React.createElement(Divider, null) : null)); }; export default /*#__PURE__*/memo(CellGroup); //# sourceMappingURL=cell-group.js.map