-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
75 lines (71 loc) · 1.54 KB
/
App.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
import React from 'react';
import {
StyleSheet,
Image,
Text,
View,
ScrollView,
SafeAreaView,
} from 'react-native';
const PostCard = ({ post }) => {
const { username, avatarUrl, imageUrl, description } = post;
return (
<View>
<View style={styles.userHeader}>
<Image source={{ uri: avatarUrl }} style={styles.avatar} />
<Text style={styles.username}>{username}</Text>
</View>
<Image source={{ uri: imageUrl }} style={[styles.box]} />
<Text style={styles.description}>
<Text style={styles.username}>{username} </Text>
{description}
</Text>
</View>
);
};
export default class App extends React.Component {
render() {
const post = {
username: 'joe',
avatarUrl: 'https://loremflickr.com/320/240/me?lock=1',
imageUrl: 'https://loremflickr.com/320/240?lock=42',
description: 'Cute cat!!!',
};
return (
<ScrollView style={styles.container}>
<SafeAreaView>
<PostCard post={post} />
<PostCard post={post} />
<PostCard post={post} />
</SafeAreaView>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
box: {
width: '100%',
aspectRatio: 1,
backgroundColor: '#ccc',
},
description: {
margin: 10,
},
username: {
fontWeight: '700',
},
avatar: {
width: 50,
aspectRatio: 1,
borderRadius: 25,
margin: 10,
},
userHeader: {
flexDirection: 'row',
alignItems: 'center',
},
});