Skip to content

Commit

Permalink
add card view
Browse files Browse the repository at this point in the history
  • Loading branch information
FuYaoDe committed Jan 5, 2017
1 parent 67af0a8 commit 30d464d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/components/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React, { PropTypes } from 'react';
import {
Text,
Image,
StyleSheet,
View
} from 'react-native';

const defaultProps = {
title: '',
subTitle: '',
image: '',
imagePosition: 'left',
backgroundColor: 'rgb(238, 219, 214)'
};

const propTypes = {
title: PropTypes.string,
image: PropTypes.object,
subTitle: PropTypes.string,
imagePosition: PropTypes.string,
};

const styles = StyleSheet.create({
container: {
height: 200,
},
img: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
// height: 200,
},
desc: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
title: {
fontSize: 20,
fontFamily: 'Cochin',
fontWeight: 'bold',
color: '#2c2c2c',
textDecorationLine: 'underline',
marginBottom: 10,
},
subTitle: {
fontSize: 14,
fontFamily: 'Cochin',
fontWeight: 'bold',
color: '#2c2c2c'
}
});

const Card = (props) => {
let flexDirection = props.imagePosition === 'left' ? 'row' : 'row-reverse';
return(
<View style={[styles.container, { flexDirection }]}>
<Image source={props.image} style={styles.img} />
<View style={[styles.desc, { backgroundColor: props.backgroundColor }]}>
<Text style={styles.title}>{props.title}</Text>
<Text style={styles.subTitle}>{props.subTitle}</Text>
</View>
</View>
);
}


Card.propTypes = propTypes;
Card.defaultProps = defaultProps;

export default Card;
13 changes: 13 additions & 0 deletions src/containers/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
View,
} from 'react-native';
import Banner from '../components/Banner'
import Card from '../components/Card'

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -32,6 +33,18 @@ export default class Login extends Component {
return (
<View style={styles.container}>
<Banner data={ad} />
<Card
title={'Beautiful wave'}
image={{ uri: 'https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/AOOC3CJARN.jpg' }}
subTitle={'Curated looks for creatives, pioneers, and individuals!'}
backgroundColor={'#fff'}
/>
<Card
title={'Beautiful wave'}
image={{ uri: 'https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/B23METEB9K.jpg' }}
subTitle={'Curated looks for creatives, pioneers, and individuals!'}
imagePosition={'right'}
/>
</View>
);
}
Expand Down

0 comments on commit 30d464d

Please sign in to comment.