Skip to content

Commit

Permalink
Composer UI fixes (#6065)
Browse files Browse the repository at this point in the history
* Fix close button overlap

* Make footer actually sticky on web

* Special toast for thread

* Only stick to bottom for last post
  • Loading branch information
gaearon authored Nov 1, 2024
1 parent 46004fb commit 3eb531b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
25 changes: 20 additions & 5 deletions src/view/com/composer/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ export const ComposePost = ({
}
onClose()
Toast.show(
replyTo
thread.posts.length > 1
? _(msg`Your posts have been published`)
: replyTo
? _(msg`Your reply has been published`)
: _(msg`Your post has been published`),
)
Expand Down Expand Up @@ -523,6 +525,7 @@ export const ComposePost = ({
}
}, [composerState])

const isLastThreadedPost = thread.posts.length > 1 && nextPost === undefined
const {
scrollHandler,
onScrollViewContentSizeChange,
Expand All @@ -531,7 +534,7 @@ export const ComposePost = ({
bottomBarAnimatedStyle,
} = useScrollTracker({
scrollViewRef,
stickyBottom: true,
stickyBottom: isLastThreadedPost,
})

const keyboardVerticalOffset = useKeyboardVerticalOffset()
Expand Down Expand Up @@ -564,7 +567,7 @@ export const ComposePost = ({
</>
)

const isFooterSticky = !isNative && thread.posts.length > 1
const isWebFooterSticky = !isNative && thread.posts.length > 1
return (
<BottomSheetPortalProvider>
<KeyboardAvoidingView
Expand Down Expand Up @@ -615,6 +618,7 @@ export const ComposePost = ({
dispatch={composerDispatch}
textInput={post.id === activePost.id ? textInput : null}
isFirstPost={index === 0}
isPartOfThread={thread.posts.length > 1}
isReply={index > 0 || !!replyTo}
isActive={post.id === activePost.id}
canRemovePost={thread.posts.length > 1}
Expand All @@ -624,11 +628,13 @@ export const ComposePost = ({
onPublish={onComposerPostPublish}
onError={setError}
/>
{isFooterSticky && post.id === activePost.id && footer}
{isWebFooterSticky && post.id === activePost.id && (
<View style={styles.stickyFooterWeb}>{footer}</View>
)}
</React.Fragment>
))}
</Animated.ScrollView>
{!isFooterSticky && footer}
{!isWebFooterSticky && footer}
</View>

<Prompt.Basic
Expand All @@ -651,6 +657,7 @@ let ComposerPost = React.memo(function ComposerPost({
isActive,
isReply,
isFirstPost,
isPartOfThread,
canRemovePost,
canRemoveQuote,
onClearVideo,
Expand All @@ -664,6 +671,7 @@ let ComposerPost = React.memo(function ComposerPost({
isActive: boolean
isReply: boolean
isFirstPost: boolean
isPartOfThread: boolean
canRemovePost: boolean
canRemoveQuote: boolean
onClearVideo: (postId: string) => void
Expand Down Expand Up @@ -743,6 +751,8 @@ let ComposerPost = React.memo(function ComposerPost({
placeholder={selectTextInputPlaceholder}
autoFocus
webForceMinHeight={forceMinHeight}
// To avoid overlap with the close button:
hasRightPadding={isPartOfThread}
isActive={isActive}
setRichText={rt => {
dispatchPost({type: 'update_richtext', richtext: rt})
Expand Down Expand Up @@ -1395,6 +1405,11 @@ const styles = StyleSheet.create({
paddingVertical: 6,
marginLeft: 12,
},
stickyFooterWeb: {
// @ts-ignore web-only
position: 'sticky',
bottom: 0,
},
errorLine: {
flexDirection: 'row',
alignItems: 'center',
Expand Down
4 changes: 3 additions & 1 deletion src/view/com/composer/text-input/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface TextInputProps extends ComponentProps<typeof RNTextInput> {
richtext: RichText
placeholder: string
webForceMinHeight: boolean
hasRightPadding: boolean
isActive: boolean
setRichText: (v: RichText) => void
onPhotoPasted: (uri: string) => void
Expand All @@ -61,6 +62,7 @@ export const TextInput = forwardRef(function TextInputImpl(
{
richtext,
placeholder,
hasRightPadding,
setRichText,
onPhotoPasted,
onNewLink,
Expand Down Expand Up @@ -232,7 +234,7 @@ export const TextInput = forwardRef(function TextInputImpl(
}, [t, richtext, inputTextStyle])

return (
<View style={[a.flex_1, a.pl_md]}>
<View style={[a.flex_1, a.pl_md, hasRightPadding && a.pr_4xl]}>
<PasteInput
testID="composerTextInput"
ref={textInput}
Expand Down
7 changes: 6 additions & 1 deletion src/view/com/composer/text-input/TextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface TextInputProps {
placeholder: string
suggestedLinks: Set<string>
webForceMinHeight: boolean
hasRightPadding: boolean
isActive: boolean
setRichText: (v: RichText | ((v: RichText) => RichText)) => void
onPhotoPasted: (uri: string) => void
Expand All @@ -56,6 +57,7 @@ export const TextInput = React.forwardRef(function TextInputImpl(
richtext,
placeholder,
webForceMinHeight,
hasRightPadding,
isActive,
setRichText,
onPhotoPasted,
Expand Down Expand Up @@ -307,7 +309,7 @@ export const TextInput = React.forwardRef(function TextInputImpl(

return (
<>
<View style={styles.container}>
<View style={[styles.container, hasRightPadding && styles.rightPadding]}>
{/* @ts-ignore inputStyle is fine */}
<EditorContent editor={editor} style={inputStyle} />
</View>
Expand Down Expand Up @@ -373,6 +375,9 @@ const styles = StyleSheet.create({
marginLeft: 8,
marginBottom: 10,
},
rightPadding: {
paddingRight: 32,
},
dropContainer: {
backgroundColor: '#0007',
pointerEvents: 'none',
Expand Down

0 comments on commit 3eb531b

Please sign in to comment.