|
| 1 | +import IconCommentlinesFill from '@/assets/iconfont/IconCommentlinesFill'; |
| 2 | +import IconLove from '@/assets/iconfont/IconLove'; |
| 3 | +import IconShare1 from '@/assets/iconfont/IconShare1'; |
| 4 | +import IconStar from '@/assets/iconfont/IconStar'; |
| 5 | +import {Item, Tag} from '@/model/Daily'; |
| 6 | +import {ITopicDetailItem} from '@/model/TopicDetail'; |
| 7 | +import {FeedHeight, formatDateMsByYMD, navigate, share} from '@/utils/Utils'; |
| 8 | +import React from 'react'; |
| 9 | +import {StyleSheet, Text, View} from 'react-native'; |
| 10 | +import FastImage from 'react-native-fast-image'; |
| 11 | +import {TouchableWithoutFeedback} from 'react-native-gesture-handler'; |
| 12 | + |
| 13 | +interface IProps { |
| 14 | + item: ITopicDetailItem; |
| 15 | +} |
| 16 | + |
| 17 | +class TopicDetailItem extends React.Component<IProps> { |
| 18 | + go2VideoDetail = (item: Item) => { |
| 19 | + navigate('VideoDetail', {item: item}); |
| 20 | + }; |
| 21 | + |
| 22 | + tagItem = (value: Tag) => { |
| 23 | + return ( |
| 24 | + <View key={value.name} style={styles.tag}> |
| 25 | + <Text style={styles.tagText}>{value.name}</Text> |
| 26 | + </View> |
| 27 | + ); |
| 28 | + }; |
| 29 | + |
| 30 | + render() { |
| 31 | + const {item} = this.props; |
| 32 | + return ( |
| 33 | + <View style={styles.container}> |
| 34 | + <View style={styles.headContainer}> |
| 35 | + <FastImage |
| 36 | + style={styles.icon} |
| 37 | + source={{ |
| 38 | + uri: item.data.header.icon, |
| 39 | + }} |
| 40 | + /> |
| 41 | + <View style={styles.headLeftContainer}> |
| 42 | + <Text style={styles.issuerName}>{item.data.header.issuerName}</Text> |
| 43 | + <View style={styles.headBottomContainer}> |
| 44 | + <Text style={styles.time}> |
| 45 | + {formatDateMsByYMD(item.data.header.time)}发布: |
| 46 | + </Text> |
| 47 | + <Text numberOfLines={1} style={styles.title}> |
| 48 | + {item.data.content.data.title} |
| 49 | + </Text> |
| 50 | + </View> |
| 51 | + </View> |
| 52 | + </View> |
| 53 | + <Text numberOfLines={2} style={styles.description}> |
| 54 | + {item.data.content.data.description} |
| 55 | + </Text> |
| 56 | + |
| 57 | + <View style={styles.tagContainer}> |
| 58 | + {item.data.content.data.tags.length > 3 |
| 59 | + ? item.data.content.data.tags |
| 60 | + .slice(0, 3) |
| 61 | + .map((value) => this.tagItem(value)) |
| 62 | + : item.data.content.data.tags.map((value) => this.tagItem(value))} |
| 63 | + </View> |
| 64 | + <TouchableWithoutFeedback |
| 65 | + onPress={() => this.go2VideoDetail(item.data.content)}> |
| 66 | + <FastImage |
| 67 | + style={styles.feed} |
| 68 | + source={{ |
| 69 | + uri: item.data.content.data.cover.feed, |
| 70 | + }} |
| 71 | + /> |
| 72 | + </TouchableWithoutFeedback> |
| 73 | + <View style={styles.consumeContainer}> |
| 74 | + <View style={styles.consumeItem}> |
| 75 | + <IconLove size={22} color="#9a9a9a" /> |
| 76 | + <Text style={styles.consumeText}> |
| 77 | + {item.data.content.data.consumption.collectionCount} |
| 78 | + </Text> |
| 79 | + </View> |
| 80 | + <View style={styles.consumeItem}> |
| 81 | + <IconCommentlinesFill size={16} color="#9a9a9a" /> |
| 82 | + <Text style={styles.consumeText}> |
| 83 | + {item.data.content.data.consumption.replyCount} |
| 84 | + </Text> |
| 85 | + </View> |
| 86 | + <View style={styles.consumeItem}> |
| 87 | + <IconStar color="#9a9a9a" /> |
| 88 | + <Text style={styles.consumeText}>收藏</Text> |
| 89 | + </View> |
| 90 | + <IconShare1 |
| 91 | + color="#9a9a9a" |
| 92 | + onPress={() => |
| 93 | + share( |
| 94 | + item.data.content.data.title, |
| 95 | + item.data.content.data.playUrl, |
| 96 | + ) |
| 97 | + } |
| 98 | + /> |
| 99 | + </View> |
| 100 | + <View style={styles.line} /> |
| 101 | + </View> |
| 102 | + ); |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +const styles = StyleSheet.create({ |
| 107 | + container: { |
| 108 | + marginLeft: 20, |
| 109 | + marginRight: 20, |
| 110 | + }, |
| 111 | + headContainer: { |
| 112 | + flexDirection: 'row', |
| 113 | + justifyContent: 'center', |
| 114 | + alignItems: 'center', |
| 115 | + }, |
| 116 | + icon: { |
| 117 | + width: 44, |
| 118 | + height: 44, |
| 119 | + borderRadius: 22, |
| 120 | + marginTop: 20, |
| 121 | + marginRight: 10, |
| 122 | + }, |
| 123 | + headLeftContainer: { |
| 124 | + flex: 1, |
| 125 | + marginTop: 20, |
| 126 | + }, |
| 127 | + issuerName: { |
| 128 | + color: '#000', |
| 129 | + fontSize: 14, |
| 130 | + fontWeight: 'bold', |
| 131 | + }, |
| 132 | + headBottomContainer: { |
| 133 | + flexDirection: 'row', |
| 134 | + marginTop: 3, |
| 135 | + }, |
| 136 | + time: { |
| 137 | + fontSize: 12, |
| 138 | + color: '#9a9a9a', |
| 139 | + }, |
| 140 | + title: { |
| 141 | + flex: 1, |
| 142 | + color: '#000', |
| 143 | + fontSize: 12, |
| 144 | + marginStart: 3, |
| 145 | + }, |
| 146 | + description: { |
| 147 | + fontSize: 14, |
| 148 | + color: '#333333', |
| 149 | + marginTop: 10, |
| 150 | + }, |
| 151 | + tagContainer: { |
| 152 | + flexDirection: 'row', |
| 153 | + marginTop: 10, |
| 154 | + }, |
| 155 | + tag: { |
| 156 | + borderRadius: 4, |
| 157 | + backgroundColor: '#89b1e933', |
| 158 | + justifyContent: 'center', |
| 159 | + alignItems: 'center', |
| 160 | + marginRight: 5, |
| 161 | + }, |
| 162 | + tagText: { |
| 163 | + color: '#42A5F5', |
| 164 | + fontSize: 12, |
| 165 | + padding: 5, |
| 166 | + }, |
| 167 | + feed: { |
| 168 | + width: '100%', |
| 169 | + height: FeedHeight, |
| 170 | + borderRadius: 4, |
| 171 | + marginTop: 10, |
| 172 | + }, |
| 173 | + consumeContainer: { |
| 174 | + flexDirection: 'row', |
| 175 | + marginTop: 15, |
| 176 | + }, |
| 177 | + consumeItem: { |
| 178 | + flexDirection: 'row', |
| 179 | + alignContent: 'flex-start', |
| 180 | + flex: 1, |
| 181 | + alignItems: 'center', |
| 182 | + }, |
| 183 | + consumeText: { |
| 184 | + color: '#9a9a9a', |
| 185 | + fontSize: 12, |
| 186 | + marginLeft: 10, |
| 187 | + }, |
| 188 | + line: { |
| 189 | + marginTop: 15, |
| 190 | + height: StyleSheet.hairlineWidth, |
| 191 | + backgroundColor: '#0000001F', |
| 192 | + }, |
| 193 | +}); |
| 194 | + |
| 195 | +export default TopicDetailItem; |
0 commit comments