|
| 1 | +import React, {Component} from 'react'; |
| 2 | +import {FlatList, StyleSheet} from 'react-native'; |
| 3 | +import {View as AnimatableView} from 'react-native-animatable'; |
| 4 | +import {View, Text, ListItem, Avatar, AnimatableManager, Card, Colors, Button} from 'react-native-ui-lib'; |
| 5 | + |
| 6 | +const posts = [ |
| 7 | + { |
| 8 | + height: 310, |
| 9 | + avatar: |
| 10 | + 'https://images.pexels.com/photos/3496994/pexels-photo-3496994.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260', |
| 11 | + name: 'Jack', |
| 12 | + nickname: '@jackywhite', |
| 13 | + description: 'Join our live webinar and discover the secrets of successful serverless monitoring.', |
| 14 | + time: '1h', |
| 15 | + link: { |
| 16 | + website: 'helloworld.com', |
| 17 | + description: 'Live Webinar: Secrets of Serverless monitoring. Register Now!', |
| 18 | + thumbnail: |
| 19 | + 'https://images.pexels.com/photos/3271010/pexels-photo-3271010.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500' |
| 20 | + }, |
| 21 | + icons: [ |
| 22 | + require('../../../assets/icons/video.png'), |
| 23 | + require('../../../assets/icons/tags.png'), |
| 24 | + require('../../../assets/icons/star.png'), |
| 25 | + require('../../../assets/icons/share.png') |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + height: 196, |
| 30 | + avatar: 'https://images.pexels.com/photos/3297502/pexels-photo-3297502.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500', |
| 31 | + name: 'Jessica Alba', |
| 32 | + nickname: '@jessicaalba', |
| 33 | + description: |
| 34 | + 'I am a Jessica Marie Alba, an American actress, model and businesswoman. I began my television and movie appearances at age 13 in Camp Nowhere and The Secret World of Alex Mack, but rose to prominence at age 19 as the lead actress of the television series Dark Angel, for which she received a Golden Globe nomination.', |
| 35 | + time: '47m', |
| 36 | + icons: [ |
| 37 | + require('../../../assets/icons/video.png'), |
| 38 | + require('../../../assets/icons/tags.png'), |
| 39 | + require('../../../assets/icons/star.png'), |
| 40 | + require('../../../assets/icons/share.png') |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + height: 310, |
| 45 | + avatar: |
| 46 | + 'https://images.pexels.com/photos/3323694/pexels-photo-3323694.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260', |
| 47 | + name: 'New York Times', |
| 48 | + nickname: '@NYTimesMagazine', |
| 49 | + description: 'Solar Power Mandate Approved for California Buildings', |
| 50 | + time: '1m', |
| 51 | + link: { |
| 52 | + website: 'newyorktimes.com', |
| 53 | + description: 'Californians have felt an urgency to move away from using fossil fuels as climate...', |
| 54 | + thumbnail: |
| 55 | + 'https://images.pexels.com/photos/3206153/pexels-photo-3206153.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500' |
| 56 | + }, |
| 57 | + icons: [ |
| 58 | + require('../../../assets/icons/video.png'), |
| 59 | + require('../../../assets/icons/tags.png'), |
| 60 | + require('../../../assets/icons/star.png'), |
| 61 | + require('../../../assets/icons/share.png') |
| 62 | + ] |
| 63 | + } |
| 64 | +]; |
| 65 | + |
| 66 | +class Twitter extends Component { |
| 67 | + keyExtractor = (item: any) => item.nickname; |
| 68 | + |
| 69 | + renderPost(post: any, id: number) { |
| 70 | + return ( |
| 71 | + <AnimatableView {...AnimatableManager.getEntranceByIndex(id, {})}> |
| 72 | + <ListItem key={id} height={post.height} containerStyle={styles.post}> |
| 73 | + <ListItem.Part left containerStyle={{justifyContent: 'space-between'}}> |
| 74 | + <Avatar source={post.avatar ? {uri: post.avatar} : undefined} containerStyle={styles.avatar}/> |
| 75 | + </ListItem.Part> |
| 76 | + <ListItem.Part middle column> |
| 77 | + <View row centerV> |
| 78 | + <Text text80M>{post.name} </Text> |
| 79 | + <Text dark40>{post.nickname}</Text> |
| 80 | + <Text dark40>{' • ' + post.time}</Text> |
| 81 | + </View> |
| 82 | + <Text>{post.description}</Text> |
| 83 | + {post.link ? ( |
| 84 | + <Card style={{marginTop: 10}} height={200}> |
| 85 | + <Card.Section imageSource={{uri: post.link.thumbnail}} imageStyle={{height: 120}}/> |
| 86 | + <View padding-s3> |
| 87 | + <Text dark40>{post.link.website}</Text> |
| 88 | + <Text>{post.link.description}</Text> |
| 89 | + </View> |
| 90 | + </Card> |
| 91 | + ) : null} |
| 92 | + <View row style={{justifyContent: 'space-between', marginVertical: 10}}> |
| 93 | + {post.icons |
| 94 | + ? post.icons.map((icnSource: any, index) => { |
| 95 | + return ( |
| 96 | + <Button |
| 97 | + key={index} |
| 98 | + iconSource={icnSource} |
| 99 | + iconStyle={styles.icon} |
| 100 | + backgroundColor={'transparent'} |
| 101 | + /> |
| 102 | + ); |
| 103 | + }) |
| 104 | + : null} |
| 105 | + </View> |
| 106 | + </ListItem.Part> |
| 107 | + </ListItem> |
| 108 | + </AnimatableView> |
| 109 | + ); |
| 110 | + } |
| 111 | + |
| 112 | + render() { |
| 113 | + return ( |
| 114 | + <FlatList |
| 115 | + data={posts} |
| 116 | + renderItem={({item, index}) => this.renderPost(item, index)} |
| 117 | + keyExtractor={this.keyExtractor} |
| 118 | + /> |
| 119 | + ); |
| 120 | + } |
| 121 | +} |
| 122 | + |
| 123 | +const styles = StyleSheet.create({ |
| 124 | + post: { |
| 125 | + marginTop: 10, |
| 126 | + marginBottom: 10, |
| 127 | + borderBottomWidth: 0.5, |
| 128 | + borderBottomColor: Colors.grey70, |
| 129 | + paddingHorizontal: 20 |
| 130 | + }, |
| 131 | + avatar: { |
| 132 | + alignSelf: 'flex-start', |
| 133 | + marginRight: 8, |
| 134 | + marginTop: 8 |
| 135 | + }, |
| 136 | + icon: { |
| 137 | + tintColor: Colors.dark40, |
| 138 | + width: 20, |
| 139 | + height: 20 |
| 140 | + } |
| 141 | +}); |
| 142 | + |
| 143 | +export default Twitter; |
0 commit comments