forked from sidevesh/react-native-material-cards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardAction.js
55 lines (50 loc) · 1.31 KB
/
CardAction.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, {Component} from 'react';
import {
StyleSheet,
View
} from 'react-native';
export default class CardAction extends Component {
renderChildren() {
let returnChildren = this.props.children;
if(this.props.inColumn===true) {
returnChildren = React.Children.map(returnChildren, (child) => {
if(child.type.name==="CardButton") {
return React.cloneElement(child, {
inColumn: true
});
}
else {
return child;
}
})
}
return returnChildren;
}
render () {
const newStyle = this.props.style || {};
let directionStyle = this.props.inColumn===true ? styles.cardActionInColumn : styles.cardActionInRow;
return (
<View style={(this.props.separator)&&(!this.props.isDark) ? [directionStyle, styles.separatorAdd, newStyle] : [directionStyle, newStyle]}>
{this.renderChildren()}
</View>
);
}
}
const styles = StyleSheet.create({
cardActionInRow: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
alignSelf: 'stretch'
},
cardActionInColumn: {
flexDirection: 'column',
alignItems: 'stretch',
justifyContent: 'flex-start',
alignSelf: 'stretch'
},
separatorAdd: {
borderTopColor: '#E9E9E9',
borderTopWidth: 1
}
});