From 3eb531b00004f3752ec825350df1943c33028ac1 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 1 Nov 2024 22:02:39 +0000 Subject: [PATCH] Composer UI fixes (#6065) * Fix close button overlap * Make footer actually sticky on web * Special toast for thread * Only stick to bottom for last post --- src/view/com/composer/Composer.tsx | 25 +++++++++++++++---- .../com/composer/text-input/TextInput.tsx | 4 ++- .../com/composer/text-input/TextInput.web.tsx | 7 +++++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 842edeb14a..1899966dcb 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -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`), ) @@ -523,6 +525,7 @@ export const ComposePost = ({ } }, [composerState]) + const isLastThreadedPost = thread.posts.length > 1 && nextPost === undefined const { scrollHandler, onScrollViewContentSizeChange, @@ -531,7 +534,7 @@ export const ComposePost = ({ bottomBarAnimatedStyle, } = useScrollTracker({ scrollViewRef, - stickyBottom: true, + stickyBottom: isLastThreadedPost, }) const keyboardVerticalOffset = useKeyboardVerticalOffset() @@ -564,7 +567,7 @@ export const ComposePost = ({ ) - const isFooterSticky = !isNative && thread.posts.length > 1 + const isWebFooterSticky = !isNative && thread.posts.length > 1 return ( 1} isReply={index > 0 || !!replyTo} isActive={post.id === activePost.id} canRemovePost={thread.posts.length > 1} @@ -624,11 +628,13 @@ export const ComposePost = ({ onPublish={onComposerPostPublish} onError={setError} /> - {isFooterSticky && post.id === activePost.id && footer} + {isWebFooterSticky && post.id === activePost.id && ( + {footer} + )} ))} - {!isFooterSticky && footer} + {!isWebFooterSticky && footer} void @@ -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}) @@ -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', diff --git a/src/view/com/composer/text-input/TextInput.tsx b/src/view/com/composer/text-input/TextInput.tsx index b9c9579fbe..42d9bfc549 100644 --- a/src/view/com/composer/text-input/TextInput.tsx +++ b/src/view/com/composer/text-input/TextInput.tsx @@ -44,6 +44,7 @@ interface TextInputProps extends ComponentProps { richtext: RichText placeholder: string webForceMinHeight: boolean + hasRightPadding: boolean isActive: boolean setRichText: (v: RichText) => void onPhotoPasted: (uri: string) => void @@ -61,6 +62,7 @@ export const TextInput = forwardRef(function TextInputImpl( { richtext, placeholder, + hasRightPadding, setRichText, onPhotoPasted, onNewLink, @@ -232,7 +234,7 @@ export const TextInput = forwardRef(function TextInputImpl( }, [t, richtext, inputTextStyle]) return ( - + webForceMinHeight: boolean + hasRightPadding: boolean isActive: boolean setRichText: (v: RichText | ((v: RichText) => RichText)) => void onPhotoPasted: (uri: string) => void @@ -56,6 +57,7 @@ export const TextInput = React.forwardRef(function TextInputImpl( richtext, placeholder, webForceMinHeight, + hasRightPadding, isActive, setRichText, onPhotoPasted, @@ -307,7 +309,7 @@ export const TextInput = React.forwardRef(function TextInputImpl( return ( <> - + {/* @ts-ignore inputStyle is fine */} @@ -373,6 +375,9 @@ const styles = StyleSheet.create({ marginLeft: 8, marginBottom: 10, }, + rightPadding: { + paddingRight: 32, + }, dropContainer: { backgroundColor: '#0007', pointerEvents: 'none',