|
| 1 | +import React, { Component } from 'react'; |
| 2 | +import { StyleSheet, SafeAreaView, Text, View, Dimensions } from 'react-native'; |
| 3 | +import { getRandomComments } from './getRandomComment'; |
| 4 | + |
| 5 | +const { width: POST_SIZE } = Dimensions.get('window'); |
| 6 | + |
| 7 | +const styles = StyleSheet.create({ |
| 8 | + container: { |
| 9 | + flex: 1, |
| 10 | + backgroundColor: 'white', |
| 11 | + }, |
| 12 | + header: { |
| 13 | + padding: 8, |
| 14 | + flexDirection: 'row', |
| 15 | + }, |
| 16 | + avatar: { |
| 17 | + width: 32, |
| 18 | + height: 32, |
| 19 | + borderRadius: 16, |
| 20 | + justifyContent: 'center', |
| 21 | + alignItems: 'center', |
| 22 | + }, |
| 23 | + info: { |
| 24 | + paddingVertical: 8, |
| 25 | + marginLeft: 8, |
| 26 | + flex: 1, |
| 27 | + }, |
| 28 | + post: { |
| 29 | + height: POST_SIZE, |
| 30 | + justifyContent: 'center', |
| 31 | + alignItems: 'center', |
| 32 | + }, |
| 33 | + emoji: { |
| 34 | + fontSize: 24, |
| 35 | + }, |
| 36 | + postEmoji: { |
| 37 | + fontSize: POST_SIZE, |
| 38 | + }, |
| 39 | + comment: { |
| 40 | + padding: 8, |
| 41 | + flexDirection: 'row', |
| 42 | + alignItems: 'center', |
| 43 | + }, |
| 44 | + commentAuthor: { |
| 45 | + fontWeight: 'bold', |
| 46 | + }, |
| 47 | + commentComment: { |
| 48 | + flexDirection: 'row', |
| 49 | + marginLeft: 8, |
| 50 | + }, |
| 51 | + commentCommentComment: { |
| 52 | + marginLeft: 8, |
| 53 | + }, |
| 54 | +}); |
| 55 | + |
| 56 | +interface Props { |
| 57 | + user: any; |
| 58 | + post: any; |
| 59 | +} |
| 60 | + |
| 61 | +export class PostPage extends Component<Props> { |
| 62 | + render() { |
| 63 | + const { user, post } = this.props; |
| 64 | + |
| 65 | + const comments = getRandomComments(); |
| 66 | + |
| 67 | + return ( |
| 68 | + <SafeAreaView style={styles.container}> |
| 69 | + <View style={styles.header}> |
| 70 | + <View style={[styles.avatar, { backgroundColor: user.color }]}> |
| 71 | + <Text style={styles.emoji}>{user.emoji}</Text> |
| 72 | + </View> |
| 73 | + <View style={styles.info}> |
| 74 | + <Text>{user.name}</Text> |
| 75 | + </View> |
| 76 | + </View> |
| 77 | + <View style={[styles.post, { backgroundColor: post.color }]} key={post.id}> |
| 78 | + <Text style={styles.postEmoji}>{post.emoji}</Text> |
| 79 | + </View> |
| 80 | + {comments.map(comment => ( |
| 81 | + <View style={styles.comment} key={comment.id}> |
| 82 | + <View style={[styles.avatar, { backgroundColor: comment.author.color }]}> |
| 83 | + <Text style={styles.emoji}>{comment.author.emoji}</Text> |
| 84 | + </View> |
| 85 | + <View style={styles.commentComment}> |
| 86 | + <Text style={styles.commentAuthor}>{comment.author.name}</Text> |
| 87 | + <Text style={styles.commentCommentComment}>{comment.comment}</Text> |
| 88 | + </View> |
| 89 | + </View> |
| 90 | + ))} |
| 91 | + </SafeAreaView> |
| 92 | + ); |
| 93 | + } |
| 94 | +} |
0 commit comments