From 39483d92db90b69c8e1b47d82829d79651a69d25 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 20 Jul 2022 19:30:07 -0500 Subject: Factor out common styles; fixes and improvements to post-thread-view --- src/view/com/post-thread/PostThreadItem.tsx | 125 +++++++++++++++++----------- 1 file changed, 76 insertions(+), 49 deletions(-) (limited to 'src/view/com/post-thread/PostThreadItem.tsx') diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 33857f48a..985d11dfa 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -13,6 +13,8 @@ import moment from 'moment' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {OnNavigateContent} from '../../routes/types' import {PostThreadViewPostModel} from '../../../state/models/post-thread-view' +import {s} from '../../lib/styles' +import {pluralize} from '../../lib/strings' const IMAGES: Record = { 'alice.com': require('../../assets/alice.jpg'), @@ -20,6 +22,14 @@ const IMAGES: Record = { 'carla.com': require('../../assets/carla.jpg'), } +function iter(n: number, fn: (i: number) => T): Array { + const arr: T[] = [] + for (let i = 0; i < n; i++) { + arr.push(fn(i)) + } + return arr +} + export const PostThreadItem = observer(function PostThreadItem({ item, // onNavigateContent, }: { @@ -27,12 +37,16 @@ export const PostThreadItem = observer(function PostThreadItem({ onNavigateContent: OnNavigateContent }) { const record = item.record as unknown as bsky.Post.Record + const hasEngagement = item.likeCount || item.repostCount const onPressOuter = () => { // TODO onNavigateContent } return ( + {iter(item._depth, () => ( + + ))} - + {item.author.displayName} - + @{item.author.name} - + · {moment(item.indexedAt).fromNow(true)} - {record.text} + + {record.text} + + {item._isHighlightedPost && hasEngagement ? ( + + {item.repostCount ? ( + + {item.repostCount}{' '} + {pluralize(item.repostCount, 'repost')} + + ) : ( + <> + )} + {item.likeCount ? ( + + {item.likeCount}{' '} + {pluralize(item.likeCount, 'like')} + + ) : ( + <> + )} + + ) : ( + <> + )} {item.replyCount} @@ -70,14 +114,14 @@ export const PostThreadItem = observer(function PostThreadItem({ {item.likeCount} @@ -93,26 +137,20 @@ const styles = StyleSheet.create({ borderTopWidth: 1, borderTopColor: '#e8e8e8', backgroundColor: '#fff', - padding: 10, }, - repostedBy: { + layout: { flexDirection: 'row', - paddingLeft: 70, }, - repostedByIcon: { + replyBar: { + width: 5, + backgroundColor: '#d4f0ff', marginRight: 2, - color: 'gray', - }, - repostedByText: { - color: 'gray', - fontWeight: 'bold', - fontSize: 13, - }, - layout: { - flexDirection: 'row', }, layoutAvi: { - width: 70, + width: 80, + paddingLeft: 10, + paddingTop: 10, + paddingBottom: 10, }, avi: { width: 60, @@ -122,6 +160,9 @@ const styles = StyleSheet.create({ }, layoutContent: { flex: 1, + paddingRight: 10, + paddingTop: 10, + paddingBottom: 10, }, meta: { flexDirection: 'row', @@ -131,22 +172,21 @@ const styles = StyleSheet.create({ metaItem: { paddingRight: 5, }, - metaDisplayName: { - fontSize: 15, - fontWeight: 'bold', - }, - metaName: { - fontSize: 14, - color: 'gray', - }, - metaDate: { - fontSize: 14, - color: 'gray', - }, postText: { - fontSize: 15, paddingBottom: 5, }, + expandedInfo: { + flexDirection: 'row', + padding: 10, + borderColor: '#e8e8e8', + borderTopWidth: 1, + borderBottomWidth: 1, + marginTop: 5, + marginBottom: 10, + }, + expandedInfoItem: { + marginRight: 10, + }, ctrls: { flexDirection: 'row', }, @@ -157,20 +197,7 @@ const styles = StyleSheet.create({ paddingLeft: 4, paddingRight: 4, }, - ctrlReplyIcon: { - marginRight: 5, - color: 'gray', - }, - ctrlRepostIcon: { - marginRight: 5, - color: 'gray', - }, - ctrlLikeIcon: { - marginRight: 5, - color: 'gray', - }, - ctrlShareIcon: { + ctrlIcon: { marginRight: 5, - color: 'gray', }, }) -- cgit 1.4.1