From edb7c949322dd89236788d0a511913d62e1313c3 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Fri, 1 Mar 2024 19:35:30 +0100 Subject: [PATCH 1/8] fix: no action after swipe down to close action --- src/components/AttachmentModal.tsx | 184 ++++++++++-------- .../Pager/AttachmentCarouselPagerContext.ts | 2 +- .../AttachmentCarousel/index.native.js | 8 +- .../MultiGestureCanvas/usePanGesture.ts | 8 +- 4 files changed, 107 insertions(+), 95 deletions(-) diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx index 7f0178863fc9..89250fffc2f1 100755 --- a/src/components/AttachmentModal.tsx +++ b/src/components/AttachmentModal.tsx @@ -4,6 +4,7 @@ import {Animated, Keyboard, View} from 'react-native'; import {GestureHandlerRootView} from 'react-native-gesture-handler'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; +import { useSharedValue } from 'react-native-reanimated'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useStyleUtils from '@hooks/useStyleUtils'; @@ -39,6 +40,7 @@ import * as Expensicons from './Icon/Expensicons'; import * as Illustrations from './Icon/Illustrations'; import Modal from './Modal'; import SafeAreaConsumer from './SafeAreaConsumer'; +import AttachmentCarouselPagerContext from './Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext'; /** * Modal render prop component that exposes modal launching triggers that can be used @@ -184,6 +186,7 @@ function AttachmentModal({ const [isConfirmButtonDisabled, setIsConfirmButtonDisabled] = useState(false); const [confirmButtonFadeAnimation] = useState(() => new Animated.Value(1)); const [isDownloadButtonReadyToBeShown, setIsDownloadButtonReadyToBeShown] = React.useState(true); + const nope = useSharedValue(false); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); const isOverlayModalVisible = (isReceiptAttachment && isDeleteReceiptConfirmModalVisible) || (!isReceiptAttachment && isAttachmentInvalid); @@ -466,6 +469,16 @@ function AttachmentModal({ shouldShowDownloadButton = allowDownload && isDownloadButtonReadyToBeShown && !isReceiptAttachment && !isOffline; shouldShowThreeDotsButton = isReceiptAttachment && isModalOpen && threeDotsMenuItems.length !== 0; } + const context = useMemo(() => ({ + pagerItems: [], + activePage: 0, + pagerRef: undefined, + isPagerScrolling: nope, + isScrollEnabled: nope, + onTap: () => {}, + onScaleChanged: () => {}, + onSwipeDown: closeModal, + }), [closeModal, nope]); return ( <> @@ -485,94 +498,97 @@ function AttachmentModal({ propagateSwipe > - {isSmallScreenWidth && } - downloadAttachment()} - shouldShowCloseButton={!isSmallScreenWidth} - shouldShowBackButton={isSmallScreenWidth} - onBackButtonPress={closeModal} - onCloseButtonPress={closeModal} - shouldShowThreeDotsButton={shouldShowThreeDotsButton} - threeDotsAnchorPosition={styles.threeDotsPopoverOffsetAttachmentModal(windowWidth)} - threeDotsMenuItems={threeDotsMenuItems} - shouldOverlayDots - /> - - {isLoading && } - {shouldShowNotFoundPage && !isLoading && ( - Navigation.dismissModal()} - /> - )} - {!isEmptyObject(report) && !isReceiptAttachment ? ( - - ) : ( - !!sourceForAttachmentView && - shouldLoadAttachment && - !isLoading && - !shouldShowNotFoundPage && ( - + {isSmallScreenWidth && } + downloadAttachment()} + shouldShowCloseButton={!isSmallScreenWidth} + shouldShowBackButton={isSmallScreenWidth} + onBackButtonPress={closeModal} + onCloseButtonPress={closeModal} + shouldShowThreeDotsButton={shouldShowThreeDotsButton} + threeDotsAnchorPosition={styles.threeDotsPopoverOffsetAttachmentModal(windowWidth)} + threeDotsMenuItems={threeDotsMenuItems} + shouldOverlayDots + /> + + {isLoading && } + {shouldShowNotFoundPage && !isLoading && ( + Navigation.dismissModal()} + /> + )} + {!isEmptyObject(report) && !isReceiptAttachment ? ( + - ) - )} - - {/* If we have an onConfirm method show a confirmation button */} - {!!onConfirm && ( - - {({safeAreaPaddingBottomStyle}) => ( - -