fix thread spacing and reply lines

This commit is contained in:
Eric Bailey 2023-08-08 11:29:38 -05:00
parent f7a0ea3e13
commit 8cb076f5fd
2 changed files with 218 additions and 177 deletions

View file

@ -107,7 +107,7 @@ export class PostThreadItemModel {
const itemModel = new PostThreadItemModel(this.rootStore, item) const itemModel = new PostThreadItemModel(this.rootStore, item)
itemModel._depth = this._depth + 1 itemModel._depth = this._depth + 1
itemModel._showParentReplyLine = itemModel._showParentReplyLine =
itemModel.parentUri !== highlightedPostUri && replies.length === 0 itemModel.parentUri !== highlightedPostUri
if (item.replies?.length) { if (item.replies?.length) {
itemModel._showChildReplyLine = true itemModel._showChildReplyLine = true
itemModel.assignTreeModels(item, highlightedPostUri, false, true) itemModel.assignTreeModels(item, highlightedPostUri, false, true)

View file

@ -159,6 +159,23 @@ export const PostThreadItem = observer(function PostThreadItem({
if (item._isHighlightedPost) { if (item._isHighlightedPost) {
return ( return (
<>
{item.rootUri !== item.uri && (
<View style={{paddingLeft: 18, flexDirection: 'row', height: 16}}>
<View style={{width: 52}}>
<View
style={[
styles.replyLine,
{
flexGrow: 1,
backgroundColor: pal.colors.replyLine,
},
]}
/>
</View>
</View>
)}
<Link <Link
testID={`postThreadItem-by-${item.post.author.handle}`} testID={`postThreadItem-by-${item.post.author.handle}`}
style={[styles.outer, styles.outerHighlighted, pal.border, pal.view]} style={[styles.outer, styles.outerHighlighted, pal.border, pal.view]}
@ -166,7 +183,7 @@ export const PostThreadItem = observer(function PostThreadItem({
accessible={false}> accessible={false}>
<PostSandboxWarning /> <PostSandboxWarning />
<View style={styles.layout}> <View style={styles.layout}>
<View style={styles.layoutAvi}> <View style={[styles.layoutAvi, {paddingBottom: 8}]}>
<PreviewableUserAvatar <PreviewableUserAvatar
size={52} size={52}
did={item.post.author.did} did={item.post.author.did}
@ -324,6 +341,7 @@ export const PostThreadItem = observer(function PostThreadItem({
</View> </View>
</View> </View>
</Link> </Link>
</>
) )
} else { } else {
return ( return (
@ -336,26 +354,36 @@ export const PostThreadItem = observer(function PostThreadItem({
pal.border, pal.border,
pal.view, pal.view,
item._showParentReplyLine && styles.noTopBorder, item._showParentReplyLine && styles.noTopBorder,
!item._showChildReplyLine && {borderBottomWidth: 1},
]} ]}
moderation={item.moderation.content}> moderation={item.moderation.content}>
<PostSandboxWarning />
<View
style={{flexDirection: 'row', gap: 10, paddingLeft: 8, height: 16}}>
<View style={{width: 52}}>
{item._showParentReplyLine && ( {item._showParentReplyLine && (
<View <View
style={[ style={[
styles.parentReplyLine, styles.replyLine,
{borderColor: pal.colors.replyLine}, {
flexGrow: 1,
backgroundColor: pal.colors.replyLine,
marginBottom: 4,
},
]} ]}
/> />
)} )}
{item._showChildReplyLine && ( </View>
</View>
<View <View
style={[ style={[
styles.childReplyLine, styles.layout,
{borderColor: pal.colors.replyLine}, {
]} paddingBottom: item._showChildReplyLine ? 0 : 16,
/> },
)} ]}>
<PostSandboxWarning />
<View style={styles.layout}>
<View style={styles.layoutAvi}> <View style={styles.layoutAvi}>
<PreviewableUserAvatar <PreviewableUserAvatar
size={52} size={52}
@ -364,7 +392,21 @@ export const PostThreadItem = observer(function PostThreadItem({
avatar={item.post.author.avatar} avatar={item.post.author.avatar}
moderation={item.moderation.avatar} moderation={item.moderation.avatar}
/> />
{item._showChildReplyLine && (
<View
style={[
styles.replyLine,
{
flexGrow: 1,
backgroundColor: pal.colors.replyLine,
marginTop: 4,
},
]}
/>
)}
</View> </View>
<View style={styles.layoutContent}> <View style={styles.layoutContent}>
<PostMeta <PostMeta
author={item.post.author} author={item.post.author}
@ -430,7 +472,7 @@ export const PostThreadItem = observer(function PostThreadItem({
<Link <Link
style={[ style={[
styles.loadMore, styles.loadMore,
{borderTopColor: pal.colors.border}, {borderBottomColor: pal.colors.border},
pal.view, pal.view,
]} ]}
href={itemHref} href={itemHref}
@ -480,9 +522,9 @@ const styles = StyleSheet.create({
paddingLeft: 10, paddingLeft: 10,
}, },
outerHighlighted: { outerHighlighted: {
paddingTop: 2, paddingTop: 16,
paddingLeft: 6, paddingLeft: 10,
paddingRight: 6, paddingRight: 10,
}, },
noTopBorder: { noTopBorder: {
borderTopWidth: 0, borderTopWidth: 0,
@ -503,18 +545,13 @@ const styles = StyleSheet.create({
}, },
layout: { layout: {
flexDirection: 'row', flexDirection: 'row',
gap: 10,
paddingLeft: 8,
}, },
layoutAvi: { layoutAvi: {},
paddingLeft: 10,
paddingTop: 10,
paddingBottom: 10,
marginRight: 10,
},
layoutContent: { layoutContent: {
flex: 1, flex: 1,
paddingRight: 10, paddingRight: 10,
paddingTop: 10,
paddingBottom: 10,
}, },
meta: { meta: {
flexDirection: 'row', flexDirection: 'row',
@ -567,10 +604,14 @@ const styles = StyleSheet.create({
loadMore: { loadMore: {
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'space-between', justifyContent: 'space-between',
borderTopWidth: 1, borderBottomWidth: 1,
paddingLeft: 80, paddingLeft: 80,
paddingRight: 20, paddingRight: 20,
paddingVertical: 10, paddingVertical: 12,
marginBottom: 8, },
replyLine: {
width: 2,
marginLeft: 'auto',
marginRight: 'auto',
}, },
}) })