From 05b55c1966b12f4849235dc794455bc60c5753c1 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 31 May 2024 14:55:51 +0300 Subject: [PATCH] Composer - fix modals, and other tweaks (#4298) * fix depreciated import * add animations to old dropdown * wrap modals in fullwindowoverlay * move errors inside header * add background to bottom bar and stop overlap * nest dialogs on android * fix android (wrap in gesturehandlerrootview) * make borders all the same color * revert threadgate button back to solid --- src/components/Dialog/index.tsx | 85 +++---- src/components/FullWindowOverlay.ios.tsx | 1 + src/components/FullWindowOverlay.tsx | 1 + src/view/com/composer/Composer.tsx | 228 +++++++++--------- src/view/com/composer/ComposerReplyTo.tsx | 6 +- .../com/composer/threadgate/ThreadgateBtn.tsx | 5 +- src/view/com/modals/Modal.tsx | 41 ++-- src/view/com/modals/Threadgate.tsx | 21 +- .../com/util/BottomSheetCustomBackdrop.tsx | 4 +- src/view/com/util/forms/DropdownButton.tsx | 35 +-- src/view/shell/Composer.tsx | 63 +++-- 11 files changed, 269 insertions(+), 221 deletions(-) create mode 100644 src/components/FullWindowOverlay.ios.tsx create mode 100644 src/components/FullWindowOverlay.tsx diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index f32e0e79..158244c8 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -32,6 +32,7 @@ import { DialogOuterProps, } from '#/components/Dialog/types' import {createInput} from '#/components/forms/TextField' +import {FullWindowOverlay} from '#/components/FullWindowOverlay' import {Portal} from '#/components/Portal' export {useDialogContext, useDialogControl} from '#/components/Dialog/context' @@ -170,47 +171,49 @@ export function Outer({ return ( isOpen && ( - Keyboard.dismiss()}> - - - - {children} - - - + + Keyboard.dismiss()}> + + + + {children} + + + + ) ) diff --git a/src/components/FullWindowOverlay.ios.tsx b/src/components/FullWindowOverlay.ios.tsx new file mode 100644 index 00000000..db516c65 --- /dev/null +++ b/src/components/FullWindowOverlay.ios.tsx @@ -0,0 +1 @@ +export {FullWindowOverlay} from 'react-native-screens' diff --git a/src/components/FullWindowOverlay.tsx b/src/components/FullWindowOverlay.tsx new file mode 100644 index 00000000..c9bdb6e7 --- /dev/null +++ b/src/components/FullWindowOverlay.tsx @@ -0,0 +1 @@ +export {Fragment as FullWindowOverlay} from 'react' diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index c8bb8d72..b1c020a1 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -181,12 +181,7 @@ export const ComposePost = observer(function ComposePost({ borderColor: interpolateColor( hasScrolled.value, [0, 1], - [ - 'transparent', - isWeb - ? t.atoms.border_contrast_low.borderColor - : t.atoms.border_contrast_high.borderColor, - ], + ['transparent', t.atoms.border_contrast_medium.borderColor], ), } }) @@ -405,106 +400,112 @@ export const ComposePost = observer(function ComposePost({ - + style={a.flex_1} + keyboardVerticalOffset={replyTo ? 120 : isAndroid ? 180 : 150}> + - - - Cancel - - - - {isProcessing ? ( - <> - {processingState} - - - - - ) : ( - <> - - {canPost ? ( - - - - {replyTo ? ( - Reply - ) : ( - Post - )} - - - - ) : ( - - - Post - - + + + hitSlop={HITSLOP_10}> + + Cancel + + + + {isProcessing ? ( + <> + {processingState} + + + + + ) : ( + <> + + {canPost ? ( + + + + {replyTo ? ( + Reply + ) : ( + Post + )} + + + + ) : ( + + + Post + + + )} + + )} + + + {isAltTextRequiredAndMissing && ( + + + + + + One or more images is missing alt text. + + + )} + {error !== '' && ( + + + + + {error} + )} - {isAltTextRequiredAndMissing && ( - - - - - - One or more images is missing alt text. - - - )} - {error !== '' && ( - - - - - {error} - - )} )} - + @@ -598,7 +604,7 @@ export const ComposePost = observer(function ComposePost({ ) : null} - + @@ -621,11 +627,6 @@ export function useComposerCancelRef() { const styles = StyleSheet.create({ topbar: { - flexDirection: 'row', - alignItems: 'center', - marginHorizontal: 16, - height: 54, - gap: 4, borderBottomWidth: StyleSheet.hairlineWidth, }, topbarDesktop: { @@ -633,6 +634,13 @@ const styles = StyleSheet.create({ paddingBottom: 10, height: 50, }, + topbarInner: { + flexDirection: 'row', + alignItems: 'center', + paddingHorizontal: 16, + height: 54, + gap: 4, + }, postBtn: { borderRadius: 20, paddingHorizontal: 20, @@ -643,19 +651,19 @@ const styles = StyleSheet.create({ flexDirection: 'row', backgroundColor: colors.red1, borderRadius: 6, - marginHorizontal: 15, + marginHorizontal: 16, paddingHorizontal: 8, paddingVertical: 6, - marginVertical: 6, + marginBottom: 8, }, reminderLine: { flexDirection: 'row', alignItems: 'center', borderRadius: 6, - marginHorizontal: 15, + marginHorizontal: 16, paddingHorizontal: 8, paddingVertical: 6, - marginBottom: 6, + marginBottom: 8, }, errorIcon: { borderWidth: hairlineWidth, @@ -690,8 +698,8 @@ const styles = StyleSheet.create({ bottomBar: { flexDirection: 'row', paddingVertical: 4, - paddingLeft: 15, - paddingRight: 20, + paddingLeft: 8, + paddingRight: 16, alignItems: 'center', borderTopWidth: hairlineWidth, }, diff --git a/src/view/com/composer/ComposerReplyTo.tsx b/src/view/com/composer/ComposerReplyTo.tsx index 902d60a4..6b38caff 100644 --- a/src/view/com/composer/ComposerReplyTo.tsx +++ b/src/view/com/composer/ComposerReplyTo.tsx @@ -10,7 +10,6 @@ import { import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {isWeb} from '#/platform/detection' import {sanitizeDisplayName} from 'lib/strings/display-names' import {sanitizeHandle} from 'lib/strings/handles' import {ComposerOptsPostRef} from 'state/shell/composer' @@ -76,10 +75,7 @@ export function ComposerReplyTo({replyTo}: {replyTo: ComposerOptsPostRef}) { return ( { @@ -45,7 +46,7 @@ export function ThreadgateBtn({ : _(msg`Some people can reply`) return ( - +