|
1 | 1 | import React, {forwardRef, useCallback, useContext, useEffect, useMemo, useRef} from 'react'; |
2 | | -import {View} from 'react-native'; |
| 2 | +// Animated required for side panel navigation |
| 3 | +// eslint-disable-next-line no-restricted-imports |
| 4 | +import {Animated, View} from 'react-native'; |
3 | 5 | import type {ModalProps as ReactNativeModalProps} from 'react-native-modal'; |
4 | 6 | import ReactNativeModal from 'react-native-modal'; |
5 | 7 | import type {ValueOf} from 'type-fest'; |
@@ -105,9 +107,10 @@ function BaseModal( |
105 | 107 | const {windowWidth, windowHeight} = useWindowDimensions(); |
106 | 108 | // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply correct modal width |
107 | 109 | // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth |
108 | | - const {isSmallScreenWidth} = useResponsiveLayout(); |
109 | | - const {sidePanelOffset} = useSidePanel(); |
110 | | - const sidePanelStyle = shouldApplySidePanelOffset && !isSmallScreenWidth ? {paddingRight: sidePanelOffset.current} : undefined; |
| 110 | + const {isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); |
| 111 | + const {sidePanelOffset, modalTranslateX} = useSidePanel(); |
| 112 | + const sidePanelStyle = !shouldUseReanimatedModal && shouldApplySidePanelOffset && !isSmallScreenWidth ? {paddingRight: sidePanelOffset.current} : undefined; |
| 113 | + const sidePanelReanimatedStyle = shouldUseReanimatedModal && shouldApplySidePanelOffset && !isSmallScreenWidth ? {transform: [{translateX: modalTranslateX.current}]} : undefined; |
111 | 114 | const keyboardStateContextValue = useKeyboardState(); |
112 | 115 |
|
113 | 116 | const insets = useSafeAreaInsets(); |
@@ -221,13 +224,27 @@ function BaseModal( |
221 | 224 | windowWidth, |
222 | 225 | windowHeight, |
223 | 226 | isSmallScreenWidth, |
| 227 | + shouldUseNarrowLayout, |
224 | 228 | }, |
225 | 229 | popoverAnchorPosition, |
226 | 230 | innerContainerStyle, |
227 | 231 | outerStyle, |
228 | 232 | shouldUseModalPaddingStyle, |
| 233 | + shouldUseReanimatedModal, |
229 | 234 | ), |
230 | | - [StyleUtils, type, windowWidth, windowHeight, isSmallScreenWidth, popoverAnchorPosition, innerContainerStyle, outerStyle, shouldUseModalPaddingStyle], |
| 235 | + [ |
| 236 | + StyleUtils, |
| 237 | + type, |
| 238 | + windowWidth, |
| 239 | + windowHeight, |
| 240 | + isSmallScreenWidth, |
| 241 | + shouldUseNarrowLayout, |
| 242 | + popoverAnchorPosition, |
| 243 | + innerContainerStyle, |
| 244 | + outerStyle, |
| 245 | + shouldUseModalPaddingStyle, |
| 246 | + shouldUseReanimatedModal, |
| 247 | + ], |
231 | 248 | ); |
232 | 249 |
|
233 | 250 | const modalPaddingStyles = useMemo(() => { |
@@ -349,12 +366,12 @@ function BaseModal( |
349 | 366 | initialFocus={initialFocus} |
350 | 367 | shouldPreventScroll={shouldPreventScrollOnFocus} |
351 | 368 | > |
352 | | - <View |
353 | | - style={[styles.defaultModalContainer, modalContainerStyle, modalPaddingStyles, !isVisible && styles.pointerEventsNone]} |
| 369 | + <Animated.View |
| 370 | + style={[styles.defaultModalContainer, modalContainerStyle, modalPaddingStyles, !isVisible && styles.pointerEventsNone, sidePanelReanimatedStyle]} |
354 | 371 | ref={ref} |
355 | 372 | > |
356 | 373 | <ColorSchemeWrapper>{children}</ColorSchemeWrapper> |
357 | | - </View> |
| 374 | + </Animated.View> |
358 | 375 | </FocusTrapForModal> |
359 | 376 | </ModalContent> |
360 | 377 | {!keyboardStateContextValue?.isKeyboardActive && <NavigationBar />} |
|
0 commit comments