@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
55 lines (53 loc) • 1.37 kB
JavaScript
import React, { useMemo, memo } from 'react';
import { View } from 'react-native';
import Theme from "../theme/index.js";
import { varCreator } from "./style.js";
/**
* 分割线
*/
import { jsx as _jsx } from "react/jsx-runtime";
const DividerLine = ({
theme,
color,
position,
adaptive = true,
direction = 'horizontal'
}) => {
const isVertical = direction === 'vertical';
const [CV] = Theme.useStyle({
varCreator,
theme
});
const viewStyle = useMemo(() => {
if (isVertical) {
return {
flex: 1,
width: 1,
height: '100%',
backgroundColor: color
};
}
const s = {
flex: 1,
maxWidth: 'auto',
height: 1,
backgroundColor: color
};
if (position === 'left') {
s.marginRight = CV.divider_margin_horizontal;
}
if (position === 'right') {
s.marginLeft = CV.divider_margin_horizontal;
}
if (!adaptive) {
s.maxWidth = position === 'left' ? CV.divider_content_left_width : CV.divider_content_right_width;
}
return s;
}, [adaptive, color, isVertical, position, CV.divider_margin_horizontal, CV.divider_content_left_width, CV.divider_content_right_width]);
return /*#__PURE__*/_jsx(View, {
style: viewStyle
});
};
export default /*#__PURE__*/memo(DividerLine);
//# sourceMappingURL=divider-line.js.map
;