More treeview UI tweaks (#2093)

* Improve tree-view spacing consistency and always include one reply bar level

* Reduce expanded post avi size
zio/stable
Paul Frazee 2023-12-05 18:18:53 -08:00 committed by GitHub
parent 511d5d999b
commit 2ad0d059ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 8 deletions

View File

@ -280,6 +280,9 @@ function PostThreadLoaded({
const prev = isThreadPost(posts[index - 1]) const prev = isThreadPost(posts[index - 1])
? (posts[index - 1] as ThreadPost) ? (posts[index - 1] as ThreadPost)
: undefined : undefined
const next = isThreadPost(posts[index - 1])
? (posts[index - 1] as ThreadPost)
: undefined
return ( return (
<View <View
ref={item.ctx.isHighlightedPost ? highlightedPostRef : undefined}> ref={item.ctx.isHighlightedPost ? highlightedPostRef : undefined}>
@ -288,6 +291,8 @@ function PostThreadLoaded({
record={item.record} record={item.record}
treeView={threadViewPrefs.lab_treeViewEnabled || false} treeView={threadViewPrefs.lab_treeViewEnabled || false}
depth={item.ctx.depth} depth={item.ctx.depth}
prevPost={prev}
nextPost={next}
isHighlightedPost={item.ctx.isHighlightedPost} isHighlightedPost={item.ctx.isHighlightedPost}
hasMore={item.ctx.hasMore} hasMore={item.ctx.hasMore}
showChildReplyLine={item.ctx.showChildReplyLine} showChildReplyLine={item.ctx.showChildReplyLine}

View File

@ -41,12 +41,15 @@ import {useLanguagePrefs} from '#/state/preferences'
import {useComposerControls} from '#/state/shell/composer' import {useComposerControls} from '#/state/shell/composer'
import {useModerationOpts} from '#/state/queries/preferences' import {useModerationOpts} from '#/state/queries/preferences'
import {Shadow, usePostShadow, POST_TOMBSTONE} from '#/state/cache/post-shadow' import {Shadow, usePostShadow, POST_TOMBSTONE} from '#/state/cache/post-shadow'
import {ThreadPost} from '#/state/queries/post-thread'
export function PostThreadItem({ export function PostThreadItem({
post, post,
record, record,
treeView, treeView,
depth, depth,
prevPost,
nextPost,
isHighlightedPost, isHighlightedPost,
hasMore, hasMore,
showChildReplyLine, showChildReplyLine,
@ -58,6 +61,8 @@ export function PostThreadItem({
record: AppBskyFeedPost.Record record: AppBskyFeedPost.Record
treeView: boolean treeView: boolean
depth: number depth: number
prevPost: ThreadPost | undefined
nextPost: ThreadPost | undefined
isHighlightedPost?: boolean isHighlightedPost?: boolean
hasMore?: boolean hasMore?: boolean
showChildReplyLine?: boolean showChildReplyLine?: boolean
@ -87,6 +92,8 @@ export function PostThreadItem({
return ( return (
<PostThreadItemLoaded <PostThreadItemLoaded
post={postShadowed} post={postShadowed}
prevPost={prevPost}
nextPost={nextPost}
record={record} record={record}
richText={richText} richText={richText}
moderation={moderation} moderation={moderation}
@ -124,6 +131,8 @@ let PostThreadItemLoaded = ({
moderation, moderation,
treeView, treeView,
depth, depth,
prevPost,
nextPost,
isHighlightedPost, isHighlightedPost,
hasMore, hasMore,
showChildReplyLine, showChildReplyLine,
@ -137,6 +146,8 @@ let PostThreadItemLoaded = ({
moderation: PostModeration moderation: PostModeration
treeView: boolean treeView: boolean
depth: number depth: number
prevPost: ThreadPost | undefined
nextPost: ThreadPost | undefined
isHighlightedPost?: boolean isHighlightedPost?: boolean
hasMore?: boolean hasMore?: boolean
showChildReplyLine?: boolean showChildReplyLine?: boolean
@ -238,7 +249,7 @@ let PostThreadItemLoaded = ({
<View style={styles.layout}> <View style={styles.layout}>
<View style={[styles.layoutAvi, {paddingBottom: 8}]}> <View style={[styles.layoutAvi, {paddingBottom: 8}]}>
<PreviewableUserAvatar <PreviewableUserAvatar
size={52} size={42}
did={post.author.did} did={post.author.did}
handle={post.author.handle} handle={post.author.handle}
avatar={post.author.avatar} avatar={post.author.avatar}
@ -424,9 +435,14 @@ let PostThreadItemLoaded = ({
) )
} else { } else {
const isThreadedChild = treeView && depth > 0 const isThreadedChild = treeView && depth > 0
const isThreadedChildAdjacentTop =
isThreadedChild && prevPost?.ctx.depth === depth
const isThreadedChildAdjacentBot =
isThreadedChild && nextPost?.ctx.depth === depth
return ( return (
<PostOuterWrapper <PostOuterWrapper
post={post} post={post}
prevPost={prevPost}
depth={depth} depth={depth}
showParentReplyLine={!!showParentReplyLine} showParentReplyLine={!!showParentReplyLine}
treeView={treeView} treeView={treeView}
@ -447,7 +463,7 @@ let PostThreadItemLoaded = ({
flexDirection: 'row', flexDirection: 'row',
gap: 10, gap: 10,
paddingLeft: 8, paddingLeft: 8,
height: isThreadedChild ? 8 : 16, height: isThreadedChildAdjacentTop ? 8 : 16,
}}> }}>
<View style={{width: 38}}> <View style={{width: 38}}>
{!isThreadedChild && showParentReplyLine && ( {!isThreadedChild && showParentReplyLine && (
@ -469,7 +485,12 @@ let PostThreadItemLoaded = ({
style={[ style={[
styles.layout, styles.layout,
{ {
paddingBottom: showChildReplyLine && !isThreadedChild ? 0 : 8, paddingBottom:
showChildReplyLine && !isThreadedChild
? 0
: isThreadedChildAdjacentBot
? 4
: 8,
}, },
]}> ]}>
{!isThreadedChild && ( {!isThreadedChild && (
@ -585,6 +606,7 @@ PostThreadItemLoaded = memo(PostThreadItemLoaded)
function PostOuterWrapper({ function PostOuterWrapper({
post, post,
prevPost,
treeView, treeView,
depth, depth,
showParentReplyLine, showParentReplyLine,
@ -592,6 +614,7 @@ function PostOuterWrapper({
children, children,
}: React.PropsWithChildren<{ }: React.PropsWithChildren<{
post: AppBskyFeedDefs.PostView post: AppBskyFeedDefs.PostView
prevPost: ThreadPost | undefined
treeView: boolean treeView: boolean
depth: number depth: number
showParentReplyLine: boolean showParentReplyLine: boolean
@ -609,12 +632,11 @@ function PostOuterWrapper({
styles.cursor, styles.cursor,
{ {
flexDirection: 'row', flexDirection: 'row',
paddingLeft: depth === 1 ? 10 : 20, paddingLeft: isMobile ? 10 : 6,
borderTopWidth: depth === 1 ? 1 : 0, borderTopWidth: !prevPost ? 1 : 0,
paddingTop: depth === 1 ? 6 : 0,
}, },
]}> ]}>
{Array.from(Array(depth - 1)).map((_, n: number) => ( {Array.from(Array(depth)).map((_, n: number) => (
<View <View
key={`${post.uri}-padding-${n}`} key={`${post.uri}-padding-${n}`}
style={{ style={{
@ -702,7 +724,7 @@ const useStyles = () => {
paddingBottom: 2, paddingBottom: 2,
}, },
metaExpandedLine1: { metaExpandedLine1: {
paddingTop: 5, paddingTop: 0,
paddingBottom: 0, paddingBottom: 0,
}, },
metaItem: { metaItem: {