From 490a3bb751d95ccb7313a0805baf78ab6e62d944 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 28 Nov 2022 09:49:41 -0600 Subject: [PATCH] Tune post-thread expanded view: add reply prompt, fix spacing and sizing --- src/view/com/composer/Prompt.tsx | 40 ++-- src/view/com/post-thread/PostThreadItem.tsx | 205 ++++++++++---------- src/view/com/util/PostCtrls.tsx | 62 +++--- 3 files changed, 172 insertions(+), 135 deletions(-) diff --git a/src/view/com/composer/Prompt.tsx b/src/view/com/composer/Prompt.tsx index f9fd7e7d..7805e00d 100644 --- a/src/view/com/composer/Prompt.tsx +++ b/src/view/com/composer/Prompt.tsx @@ -1,29 +1,42 @@ import React from 'react' import {StyleSheet, Text, TouchableOpacity, View} from 'react-native' -import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {colors} from '../../lib/styles' import {useStores} from '../../../state' import {UserAvatar} from '../util/UserAvatar' -export function ComposePrompt({onPressCompose}: {onPressCompose: () => void}) { +export function ComposePrompt({ + noAvi = false, + text = "What's up?", + btn = 'Post', + onPressCompose, +}: { + noAvi?: boolean + text?: string + btn?: string + onPressCompose: () => void +}) { const store = useStores() const onPressAvatar = () => { store.nav.navigate(`/profile/${store.me.handle}`) } return ( - - - - + + {!noAvi ? ( + + + + ) : undefined} - What's up? + {text} - Post + {btn} ) @@ -40,6 +53,9 @@ const styles = StyleSheet.create({ alignItems: 'center', backgroundColor: colors.white, }, + noAviContainer: { + paddingVertical: 14, + }, avatar: { width: 50, }, diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 8a2d5068..3eefeae9 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -16,6 +16,7 @@ import {useStores} from '../../../state' import {PostMeta} from '../util/PostMeta' import {PostEmbeds} from '../util/PostEmbeds' import {PostCtrls} from '../util/PostCtrls' +import {ComposePrompt} from '../composer/Prompt' const PARENT_REPLY_LINE_LENGTH = 8 const REPLYING_TO_LINE_LENGTH = 6 @@ -93,116 +94,122 @@ export const PostThreadItem = observer(function PostThreadItem({ if (item._isHighlightedPost) { return ( - - - - - - - - - - - - {item.author.displayName || item.author.handle} - - - - · {ago(item.indexedAt)} - - - - + + + + + - - - - - - @{item.author.handle} - - - - - - - - - {item._isHighlightedPost && hasEngagement ? ( - - {item.repostCount ? ( + + - - - {item.repostCount} - {' '} - {pluralize(item.repostCount, 'repost')} + style={styles.metaItem} + href={authorHref} + title={authorTitle}> + + {item.author.displayName || item.author.handle} - ) : ( - <> - )} - {item.upvoteCount ? ( + + · {ago(item.indexedAt)} + + + + + + + - - - {item.upvoteCount} - {' '} - {pluralize(item.upvoteCount, 'upvote')} + style={styles.metaItem} + href={authorHref} + title={authorTitle}> + + @{item.author.handle} - ) : ( - <> - )} + + + + + + + + + {item._isHighlightedPost && hasEngagement ? ( + + {item.repostCount ? ( + + + + {item.repostCount} + {' '} + {pluralize(item.repostCount, 'repost')} + + + ) : ( + <> + )} + {item.upvoteCount ? ( + + + + {item.upvoteCount} + {' '} + {pluralize(item.upvoteCount, 'upvote')} + + + ) : ( + <> + )} + + ) : ( + <> + )} + + - ) : ( - <> - )} - - - + + ) } else { return ( @@ -371,7 +378,7 @@ const styles = StyleSheet.create({ borderTopWidth: 1, borderBottomWidth: 1, marginTop: 5, - marginBottom: 10, + marginBottom: 15, }, expandedInfoItem: { marginRight: 10, diff --git a/src/view/com/util/PostCtrls.tsx b/src/view/com/util/PostCtrls.tsx index a316d895..36a67b53 100644 --- a/src/view/com/util/PostCtrls.tsx +++ b/src/view/com/util/PostCtrls.tsx @@ -12,9 +12,10 @@ import {UpIcon, UpIconSolid} from '../../lib/icons' import {s, colors} from '../../lib/styles' interface PostCtrlsOpts { - replyCount: number - repostCount: number - upvoteCount: number + big?: boolean + replyCount?: number + repostCount?: number + upvoteCount?: number isReposted: boolean isUpvoted: boolean onPressReply: () => void @@ -62,9 +63,11 @@ export function PostCtrls(opts: PostCtrlsOpts) { - {opts.replyCount} + {typeof opts.replyCount !== 'undefined' ? ( + {opts.replyCount} + ) : undefined} @@ -77,17 +80,19 @@ export function PostCtrls(opts: PostCtrlsOpts) { opts.isReposted ? styles.ctrlIconReposted : styles.ctrlIcon } icon="retweet" - size={18} + size={opts.big ? 22 : 18} /> - - {opts.repostCount} - + {typeof opts.repostCount !== 'undefined' ? ( + + {opts.repostCount} + + ) : undefined} @@ -96,19 +101,28 @@ export function PostCtrls(opts: PostCtrlsOpts) { onPress={onPressToggleUpvoteWrapper}> {opts.isUpvoted ? ( - + ) : ( - + )} - - {opts.upvoteCount} - + {typeof opts.upvoteCount !== 'undefined' ? ( + + {opts.upvoteCount} + + ) : undefined}