Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More narrow treeview and borders to separate new subthreads #1494

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions src/view/com/post-thread/PostThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ export const PostThread = observer(function PostThread({
return []
}, [view.isLoadingFromCache, view.thread, maxVisible])
const highlightedPostIndex = posts.findIndex(post => post._isHighlightedPost)
const showBottomBorder =
!treeView ||
// in the treeview, only show the bottom border
// if there are replies under the highlighted posts
posts.findLast(v => v instanceof PostThreadItemModel) !==
posts[highlightedPostIndex]
useSetTitle(
view.thread?.postRecord &&
`${sanitizeDisplayName(
Expand Down Expand Up @@ -194,10 +188,7 @@ export const PostThread = observer(function PostThread({
)
} else if (item === REPLY_PROMPT) {
return (
<View
style={
treeView && [pal.border, {borderBottomWidth: 1, marginBottom: 6}]
}>
<View>
{isDesktopWeb && <ComposePrompt onPressCompose={onPressReply} />}
</View>
)
Expand Down Expand Up @@ -242,14 +233,11 @@ export const PostThread = observer(function PostThread({
// -prf
return (
<View
style={[
{height: 400},
showBottomBorder && {
borderTopWidth: 1,
borderColor: pal.colors.border,
},
treeView && {marginTop: 10},
]}
style={{
height: 400,
borderTopWidth: 1,
borderColor: pal.colors.border,
}}
/>
)
} else if (item === CHILD_SPINNER) {
Expand All @@ -273,7 +261,7 @@ export const PostThread = observer(function PostThread({
}
return <></>
},
[onRefresh, onPressReply, pal, posts, isTablet, treeView, showBottomBorder],
[onRefresh, onPressReply, pal, posts, isTablet, treeView],
)

// loading
Expand Down
80 changes: 47 additions & 33 deletions src/view/com/post-thread/PostThreadItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const PostThreadItem = observer(function PostThreadItem({
return (
<>
{item.rootUri !== item.uri && (
<View style={{paddingLeft: 18, flexDirection: 'row', height: 16}}>
<View style={{paddingLeft: 16, flexDirection: 'row', height: 16}}>
<View style={{width: 52}}>
<View
style={[
Expand Down Expand Up @@ -432,40 +432,48 @@ export const PostThreadItem = observer(function PostThreadItem({
style={[
styles.layout,
{
paddingBottom: item._showChildReplyLine ? 0 : 8,
paddingBottom:
item._showChildReplyLine && !isThreadedChild ? 0 : 8,
},
]}>
<View style={styles.layoutAvi}>
<PreviewableUserAvatar
size={isThreadedChild ? 24 : 52}
did={item.post.author.did}
handle={item.post.author.handle}
avatar={item.post.author.avatar}
moderation={item.moderation.avatar}
/>

{item._showChildReplyLine && (
<View
style={[
styles.replyLine,
{
flexGrow: 1,
backgroundColor: isThreadedChild
? pal.colors.border
: pal.colors.replyLine,
marginTop: 4,
},
]}
{!isThreadedChild && (
<View style={styles.layoutAvi}>
<PreviewableUserAvatar
size={isThreadedChild ? 36 : 52}
did={item.post.author.did}
handle={item.post.author.handle}
avatar={item.post.author.avatar}
moderation={item.moderation.avatar}
/>
)}
</View>

{item._showChildReplyLine && (
<View
style={[
styles.replyLine,
{
flexGrow: 1,
backgroundColor: isThreadedChild
? pal.colors.border
: pal.colors.replyLine,
marginTop: 4,
},
]}
/>
)}
</View>
)}

<View style={styles.layoutContent}>
<PostMeta
author={item.post.author}
authorHasWarning={!!item.post.author.labels?.length}
timestamp={item.post.indexedAt}
postHref={itemHref}
showAvatar={isThreadedChild}
avatarSize={26}
displayNameType="md-bold"
displayNameStyle={s.ml2}
style={isThreadedChild && s.mb5}
/>
<PostAlerts
moderation={item.moderation.content}
Expand All @@ -475,7 +483,7 @@ export const PostThreadItem = observer(function PostThreadItem({
<View
style={[
styles.postTextContainer,
isThreadedChild && {paddingTop: 2},
// isThreadedChild && {paddingTop: 2},
]}>
<RichText
type="post-text"
Expand Down Expand Up @@ -525,7 +533,7 @@ export const PostThreadItem = observer(function PostThreadItem({
style={[
styles.loadMore,
{
paddingLeft: treeView ? 44 : 70,
paddingLeft: treeView ? 8 : 70,
paddingTop: 0,
paddingBottom: treeView ? 4 : 12,
},
Expand Down Expand Up @@ -566,17 +574,23 @@ function PostOuterWrapper({
<View
style={[
pal.view,
pal.border,
styles.cursor,
{flexDirection: 'row', paddingLeft: 10},
{
flexDirection: 'row',
paddingLeft: 10,
borderTopWidth: item._depth === 1 ? 1 : 0,
paddingTop: item._depth === 1 ? 8 : 0,
},
]}>
{Array.from(Array(item._depth - 1)).map((_, n: number) => (
<View
key={`${item.uri}-padding-${n}`}
style={{
borderLeftWidth: 2,
borderLeftColor: pal.colors.border,
marginLeft: 19,
paddingLeft: isMobile ? 0 : 4,
marginLeft: isMobile ? 6 : 14,
paddingLeft: isMobile ? 6 : 12,
}}
/>
))}
Expand Down Expand Up @@ -626,12 +640,12 @@ function ExpandedPostDetails({
const styles = StyleSheet.create({
outer: {
borderTopWidth: 1,
paddingLeft: 10,
paddingLeft: 8,
},
outerHighlighted: {
paddingTop: 16,
paddingLeft: 10,
paddingRight: 10,
paddingLeft: 8,
paddingRight: 8,
},
noTopBorder: {
borderTopWidth: 0,
Expand Down
24 changes: 15 additions & 9 deletions src/view/com/util/PostMeta.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react'
import {StyleSheet, View} from 'react-native'
import {StyleProp, StyleSheet, TextStyle, View, ViewStyle} from 'react-native'
import {Text} from './text/Text'
import {DesktopWebTextLink} from './Link'
import {niceDate} from 'lib/strings/time'
import {usePalette} from 'lib/hooks/usePalette'
import {TypographyVariant} from 'lib/ThemeContext'
import {UserAvatar} from './UserAvatar'
import {observer} from 'mobx-react-lite'
import {sanitizeDisplayName} from 'lib/strings/display-names'
Expand All @@ -19,10 +20,14 @@ interface PostMetaOpts {
handle: string
displayName?: string | undefined
}
showAvatar?: boolean
authorHasWarning: boolean
postHref: string
timestamp: string
showAvatar?: boolean
avatarSize?: number
displayNameType?: TypographyVariant
displayNameStyle?: StyleProp<TextStyle>
style?: StyleProp<ViewStyle>
}

export const PostMeta = observer(function PostMetaImpl(opts: PostMetaOpts) {
Expand All @@ -31,20 +36,20 @@ export const PostMeta = observer(function PostMetaImpl(opts: PostMetaOpts) {
const handle = opts.author.handle

return (
<View style={styles.metaOneLine}>
{opts.showAvatar && typeof opts.author.avatar !== 'undefined' && (
<View style={[styles.container, opts.style]}>
{opts.showAvatar && (
<View style={styles.avatar}>
<UserAvatar
avatar={opts.author.avatar}
size={16}
size={opts.avatarSize || 16}
// TODO moderation
/>
</View>
)}
<View style={styles.maxWidth}>
<DesktopWebTextLink
type="lg-bold"
style={pal.text}
type={opts.displayNameType || 'lg-bold'}
style={[pal.text, opts.displayNameStyle]}
numberOfLines={1}
lineHeight={1.2}
text={
Expand Down Expand Up @@ -90,12 +95,13 @@ export const PostMeta = observer(function PostMetaImpl(opts: PostMetaOpts) {
})

const styles = StyleSheet.create({
metaOneLine: {
container: {
flexDirection: 'row',
alignItems: isAndroid ? 'center' : 'baseline',
alignItems: 'center',
paddingBottom: 2,
gap: 4,
zIndex: 1,
flex: 1,
},
avatar: {
alignSelf: 'center',
Expand Down