-
Notifications
You must be signed in to change notification settings - Fork 5
/
Row.js
40 lines (31 loc) · 1.12 KB
/
Row.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import { View } from 'react-native';
import shorthandStyles from './shorthandStyles'
const Row = (props) => {
const {
dial = 0,
flex: _flex,
spaceBetween,
spaceAround,
stretch,
margin,
padding,
style,
reverse,
...otherProps,
} = props;
const _dial = dial > 0 && dial < 10 ? dial : 0;
const flex = typeof(_flex) === "number" ? _flex : !_flex ? null : 1
const _shorthandStyles = shorthandStyles(margin, padding)
const justifyContent = spaceBetween ? 'space-between' : spaceAround ? 'space-around' : _dial === 0 ? null : _dial % 3 === 0 ? 'flex-end' :
_dial % 3 === 2 ? 'center' : 'flex-start';
const alignItems = stretch ? 'stretch' : _dial === 0 ? null : _dial > 6 ? 'flex-end' :
_dial > 3 ? 'center' : 'flex-start';
const flexDirection = reverse ? 'row-reverse' : 'row';
return (
<View style={[{flexDirection, justifyContent, alignItems, flex}, _shorthandStyles, style]} {...otherProps} >
{props.children}
</View>
);
};
export default Row