forked from jacklam718/react-native-card-view
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact-native-card-view.js
130 lines (120 loc) · 2.31 KB
/
react-native-card-view.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* Author: Jack Lam - [email protected]
* GitHub: https://github.com/jacklam718
* License: MIT
*/
import React, {Component} from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native'
class Card extends Component {
render() {
const newStyles = this.props.styles || {};
return (
<View style={[styles.container, styles.card, newStyles.card]}>
{this.props.children}
</View>
);
}
}
class CardImage extends Component {
render () {
const newStyles = this.props.styles || {};
return (
<View style={[styles.cardImage, newStyles.cardImage]}>
{this.props.children}
</View>
);
}
}
class CardTitle extends Component {
render () {
const newStyles = this.props.styles || {};
return (
<View style={[styles.cardTitle, newStyles.cardTitle]}>
{this.props.children}
</View>
);
}
}
class CardContent extends Component {
render () {
const newStyles = this.props.styles || {};
return (
<View style={[styles.cardContent, newStyles.cardContent]}>
{this.props.children}
</View>
);
}
}
class CardAction extends Component {
render () {
const newStyles = this.props.styles || {};
return (
<View>
{this.props.separator ? <Separator /> : null}
<View style={[styles.cardAction, newStyles.cardAction]}>
{this.props.children}
</View>
</View>
);
}
}
class Separator extends Component {
render () {
return <View style={styles.separator} />
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#F5FCFF',
margin: 5
},
card: {
backgroundColor: "#fff",
borderRadius: 2,
shadowColor: "#000000",
shadowOpacity: 0.3,
shadowRadius: 1,
shadowOffset: {
height: 1,
width: 0.3,
}
},
cardImage: {
flex: 1
},
cardTitle: {
flex: 1,
flexDirection: 'row',
padding: 16
},
cardContent: {
paddingRight: 16,
paddingLeft: 16,
paddingTop: 16,
paddingBottom: 16,
},
cardAction: {
margin: 8,
flexDirection: 'row',
alignItems: 'center',
},
separator: {
flex: 1,
height: 1,
backgroundColor: '#E9E9E9'
}
});
export {
Card,
CardTitle,
CardAction,
CardContent,
CardImage,
Separator
}