@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
58 lines (50 loc) • 1.73 kB
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from 'react';
import { TouchableWithoutFeedback, View } from 'react-native';
import { attachPropertiesToComponent } from '../helpers';
import FlexItem from './flex-item';
const Flex = props => {
const {
style,
direction = 'row',
wrap = 'nowrap',
justify = 'start',
align = 'center',
children,
...restProps
} = props;
const transferConst = [justify, align];
const transferConstStyle = transferConst.map(tc => {
switch (tc) {
case 'start':
return 'flex-start';
case 'end':
return 'flex-end';
case 'between':
return 'space-between';
case 'around':
return 'space-around';
default:
return tc;
}
});
const flexStyle = {
flexDirection: direction,
flexWrap: wrap,
justifyContent: transferConstStyle[0],
alignItems: transferConstStyle[1]
};
const inner = /*#__PURE__*/React.createElement(View, _extends({
style: [flexStyle, style]
}, restProps), children);
const shouldWrapInTouchableComponent = restProps.onPress || restProps.onLongPress || restProps.onPressIn || restProps.onPressOut;
if (shouldWrapInTouchableComponent) {
return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, restProps, inner);
} else {
return inner;
}
};
export default attachPropertiesToComponent(Flex, {
Item: FlexItem
});
//# sourceMappingURL=index.js.map