Some linear mode cleanup
This commit is contained in:
@@ -4,7 +4,12 @@ import {useLingui} from '@lingui/react'
|
|||||||
|
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {type PostThreadParams, type Slice} from '#/state/queries/usePostThread'
|
import {type PostThreadParams, type Slice} from '#/state/queries/usePostThread'
|
||||||
import {TREE_AVI_WIDTH, TREE_INDENT} from '#/screens/PostThread/const'
|
import {
|
||||||
|
LINEAR_AVI_WIDTH,
|
||||||
|
REPLY_LINE_WIDTH,
|
||||||
|
TREE_AVI_WIDTH,
|
||||||
|
TREE_INDENT,
|
||||||
|
} from '#/screens/PostThread/const'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {CirclePlus_Stroke2_Corner0_Rounded as CirclePlus} from '#/components/icons/CirclePlus'
|
import {CirclePlus_Stroke2_Corner0_Rounded as CirclePlus} from '#/components/icons/CirclePlus'
|
||||||
import {Link} from '#/components/Link'
|
import {Link} from '#/components/Link'
|
||||||
@@ -20,46 +25,39 @@ export function ReadMore({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const isTreeView = view === 'tree'
|
const isTreeView = view === 'tree'
|
||||||
const indentCount = Math.max(0, item.indent - 1)
|
const indent = Math.max(0, item.indent - 1)
|
||||||
|
|
||||||
const treeIndents = isTreeView ? (
|
const spacers = isTreeView
|
||||||
Array.from(Array(indentCount)).map((_, n: number) => (
|
? Array.from(Array(indent)).map((_, n: number) => (
|
||||||
<View
|
<View
|
||||||
key={`${item.key}-padding-${n}`}
|
key={`${item.key}-padding-${n}`}
|
||||||
style={[
|
style={[
|
||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
{
|
{
|
||||||
borderRightWidth: 2,
|
borderRightWidth: REPLY_LINE_WIDTH,
|
||||||
width: TREE_INDENT + TREE_AVI_WIDTH / 2,
|
width: TREE_INDENT + TREE_AVI_WIDTH / 2,
|
||||||
left: 1,
|
left: 1,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : indentCount > 0 ? (
|
: null
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
// avi width minus border, divided by 2
|
|
||||||
{width: (42 - 2) / 2},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[a.flex_row]}>
|
<View style={[a.flex_row]}>
|
||||||
{treeIndents}
|
{spacers}
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
{
|
{
|
||||||
marginLeft: isTreeView
|
marginLeft: isTreeView
|
||||||
? TREE_INDENT + TREE_AVI_WIDTH / 2 - 1
|
? TREE_INDENT + TREE_AVI_WIDTH / 2 - 1
|
||||||
: TREE_INDENT,
|
: (LINEAR_AVI_WIDTH - REPLY_LINE_WIDTH) / 2 + 16,
|
||||||
borderLeftWidth: 2,
|
borderLeftWidth: 2,
|
||||||
borderBottomWidth: 2,
|
borderBottomWidth: 2,
|
||||||
borderBottomLeftRadius: a.rounded_sm.borderRadius,
|
borderBottomLeftRadius: a.rounded_sm.borderRadius,
|
||||||
height: '50%',
|
height: '50%',
|
||||||
width: isTreeView ? TREE_INDENT : 42 / 2 + 10,
|
width: isTreeView ? TREE_INDENT : LINEAR_AVI_WIDTH / 2 + 10,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ import {PostCtrls} from '#/view/com/util/post-ctrls/PostCtrls'
|
|||||||
import {PostEmbeds, PostEmbedViewContext} from '#/view/com/util/post-embeds'
|
import {PostEmbeds, PostEmbedViewContext} from '#/view/com/util/post-embeds'
|
||||||
import {PostMeta} from '#/view/com/util/PostMeta'
|
import {PostMeta} from '#/view/com/util/PostMeta'
|
||||||
import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar'
|
import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
|
import {
|
||||||
|
LINEAR_AVI_WIDTH,
|
||||||
|
OUTER_SPACE,
|
||||||
|
REPLY_LINE_WIDTH,
|
||||||
|
} from '#/screens/PostThread/const'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
||||||
import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash'
|
import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash'
|
||||||
@@ -180,37 +185,37 @@ let PostThreadItemLoaded = ({
|
|||||||
<SubtleHover>
|
<SubtleHover>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.px_sm,
|
|
||||||
a.pointer,
|
a.pointer,
|
||||||
showTopBorder && [a.border_t, t.atoms.border_contrast_low],
|
showTopBorder && [a.border_t, t.atoms.border_contrast_low],
|
||||||
|
{
|
||||||
|
paddingHorizontal: OUTER_SPACE,
|
||||||
|
},
|
||||||
|
// If there's no next child, add a little padding to bottom
|
||||||
|
!item.ui.showChildReplyLine && {
|
||||||
|
paddingBottom: OUTER_SPACE / 2,
|
||||||
|
},
|
||||||
]}>
|
]}>
|
||||||
<PostHider
|
<PostHider
|
||||||
testID={`postThreadItem-by-${post.author.handle}`}
|
testID={`postThreadItem-by-${post.author.handle}`}
|
||||||
href={postHref}
|
href={postHref}
|
||||||
disabled={overrides?.moderation === true}
|
disabled={overrides?.moderation === true}
|
||||||
modui={moderation.ui('contentList')}
|
modui={moderation.ui('contentList')}
|
||||||
iconSize={42}
|
iconSize={LINEAR_AVI_WIDTH}
|
||||||
iconStyles={{marginLeft: 2, marginRight: 2}}
|
iconStyles={{marginLeft: 2, marginRight: 2}}
|
||||||
profile={post.author}
|
profile={post.author}
|
||||||
interpretFilterAsBlur>
|
interpretFilterAsBlur>
|
||||||
<View
|
{/* Provides some space between posts as well as contains the reply line */}
|
||||||
style={{
|
<View style={[a.flex_row, {height: a.pt_md.paddingTop}]}>
|
||||||
flexDirection: 'row',
|
<View style={{width: LINEAR_AVI_WIDTH}}>
|
||||||
gap: 10,
|
|
||||||
paddingLeft: 8,
|
|
||||||
height: 16,
|
|
||||||
}}>
|
|
||||||
<View style={{width: 42}}>
|
|
||||||
{item.ui.showParentReplyLine && (
|
{item.ui.showParentReplyLine && (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
a.mx_auto,
|
||||||
|
a.flex_1,
|
||||||
|
a.mb_xs,
|
||||||
{
|
{
|
||||||
width: 2,
|
width: REPLY_LINE_WIDTH,
|
||||||
marginLeft: 'auto',
|
backgroundColor: t.atoms.border_contrast_low.borderColor,
|
||||||
marginRight: 'auto',
|
|
||||||
flexGrow: 1,
|
|
||||||
backgroundColor: pal.colors.replyLine,
|
|
||||||
marginBottom: 4,
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -218,19 +223,10 @@ let PostThreadItemLoaded = ({
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View
|
<View style={[a.flex_row, a.gap_md]}>
|
||||||
style={[
|
|
||||||
a.flex_row,
|
|
||||||
a.px_sm,
|
|
||||||
a.gap_md,
|
|
||||||
{
|
|
||||||
paddingBottom: item.ui.showChildReplyLine ? 0 : 8,
|
|
||||||
},
|
|
||||||
]}>
|
|
||||||
{/* If we are in threaded mode, the avatar is rendered in PostMeta */}
|
|
||||||
<View>
|
<View>
|
||||||
<PreviewableUserAvatar
|
<PreviewableUserAvatar
|
||||||
size={42}
|
size={LINEAR_AVI_WIDTH}
|
||||||
profile={post.author}
|
profile={post.author}
|
||||||
moderation={moderation.ui('avatar')}
|
moderation={moderation.ui('avatar')}
|
||||||
type={post.author.associated?.labeler ? 'labeler' : 'user'}
|
type={post.author.associated?.labeler ? 'labeler' : 'user'}
|
||||||
@@ -240,13 +236,12 @@ let PostThreadItemLoaded = ({
|
|||||||
{item.ui.showChildReplyLine && (
|
{item.ui.showChildReplyLine && (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
a.mx_auto,
|
||||||
|
a.mt_xs,
|
||||||
|
a.flex_1,
|
||||||
{
|
{
|
||||||
width: 2,
|
width: REPLY_LINE_WIDTH,
|
||||||
marginLeft: 'auto',
|
backgroundColor: t.atoms.border_contrast_low.borderColor,
|
||||||
marginRight: 'auto',
|
|
||||||
flexGrow: 1,
|
|
||||||
backgroundColor: pal.colors.replyLine,
|
|
||||||
marginTop: 4,
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -259,7 +254,6 @@ let PostThreadItemLoaded = ({
|
|||||||
moderation={moderation}
|
moderation={moderation}
|
||||||
timestamp={post.indexedAt}
|
timestamp={post.indexedAt}
|
||||||
postHref={postHref}
|
postHref={postHref}
|
||||||
avatarSize={24}
|
|
||||||
style={[a.pb_xs]}
|
style={[a.pb_xs]}
|
||||||
/>
|
/>
|
||||||
<LabelsOnMyPost post={post} style={[a.pb_xs]} />
|
<LabelsOnMyPost post={post} style={[a.pb_xs]} />
|
||||||
@@ -269,7 +263,6 @@ let PostThreadItemLoaded = ({
|
|||||||
additionalCauses={additionalPostAlerts}
|
additionalCauses={additionalPostAlerts}
|
||||||
/>
|
/>
|
||||||
{richText?.text ? (
|
{richText?.text ? (
|
||||||
<View style={[a.pb_2xs, a.pr_sm]}>
|
|
||||||
<RichText
|
<RichText
|
||||||
enableTags
|
enableTags
|
||||||
value={richText}
|
value={richText}
|
||||||
@@ -278,7 +271,6 @@ let PostThreadItemLoaded = ({
|
|||||||
authorHandle={post.author.handle}
|
authorHandle={post.author.handle}
|
||||||
shouldProxyLinks={true}
|
shouldProxyLinks={true}
|
||||||
/>
|
/>
|
||||||
</View>
|
|
||||||
) : undefined}
|
) : undefined}
|
||||||
{limitLines ? (
|
{limitLines ? (
|
||||||
<TextLink
|
<TextLink
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
export const TREE_INDENT = 16
|
export const TREE_INDENT = 16
|
||||||
export const TREE_AVI_WIDTH = 24
|
export const TREE_AVI_WIDTH = 24
|
||||||
|
export const LINEAR_AVI_WIDTH = 42
|
||||||
|
export const REPLY_LINE_WIDTH = 2
|
||||||
|
export const OUTER_SPACE = 16
|
||||||
|
|||||||
Reference in New Issue
Block a user