|
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'; |
@@ -106,9 +108,11 @@ function BaseModal( |
106 | 108 | const {windowWidth, windowHeight} = useWindowDimensions(); |
107 | 109 | // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply correct modal width |
108 | 110 | // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth |
109 | | - const {isSmallScreenWidth} = useResponsiveLayout(); |
| 111 | + const {isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); |
110 | 112 | const {sidePanelOffset} = useSidePanel(); |
111 | | - const sidePanelStyle = shouldApplySidePanelOffset && !isSmallScreenWidth ? {paddingRight: sidePanelOffset.current} : undefined; |
| 113 | + const sidePanelStyle = !shouldUseReanimatedModal && shouldApplySidePanelOffset && !isSmallScreenWidth ? {paddingRight: sidePanelOffset.current} : undefined; |
| 114 | + const sidePanelReanimatedStyle = |
| 115 | + shouldUseReanimatedModal && shouldApplySidePanelOffset && !isSmallScreenWidth ? {transform: [{translateX: Animated.multiply(sidePanelOffset.current, -1)}]} : undefined; |
112 | 116 | const keyboardStateContextValue = useKeyboardState(); |
113 | 117 |
|
114 | 118 | const insets = useSafeAreaInsets(); |
@@ -222,14 +226,27 @@ function BaseModal( |
222 | 226 | windowWidth, |
223 | 227 | windowHeight, |
224 | 228 | isSmallScreenWidth, |
| 229 | + shouldUseNarrowLayout, |
225 | 230 | }, |
226 | 231 | popoverAnchorPosition, |
227 | 232 | innerContainerStyle, |
228 | 233 | outerStyle, |
229 | 234 | shouldUseModalPaddingStyle, |
230 | 235 | shouldUseReanimatedModal, |
231 | 236 | ), |
232 | | - [StyleUtils, type, windowWidth, windowHeight, isSmallScreenWidth, popoverAnchorPosition, innerContainerStyle, outerStyle, shouldUseModalPaddingStyle, shouldUseReanimatedModal], |
| 237 | + [ |
| 238 | + StyleUtils, |
| 239 | + type, |
| 240 | + windowWidth, |
| 241 | + windowHeight, |
| 242 | + isSmallScreenWidth, |
| 243 | + shouldUseNarrowLayout, |
| 244 | + popoverAnchorPosition, |
| 245 | + innerContainerStyle, |
| 246 | + outerStyle, |
| 247 | + shouldUseModalPaddingStyle, |
| 248 | + shouldUseReanimatedModal, |
| 249 | + ], |
233 | 250 | ); |
234 | 251 |
|
235 | 252 | const modalPaddingStyles = useMemo(() => { |
@@ -351,12 +368,12 @@ function BaseModal( |
351 | 368 | initialFocus={initialFocus} |
352 | 369 | shouldPreventScroll={shouldPreventScrollOnFocus} |
353 | 370 | > |
354 | | - <View |
355 | | - style={[styles.defaultModalContainer, modalContainerStyle, modalPaddingStyles, !isVisible && styles.pointerEventsNone]} |
| 371 | + <Animated.View |
| 372 | + style={[styles.defaultModalContainer, modalContainerStyle, modalPaddingStyles, !isVisible && styles.pointerEventsNone, sidePanelReanimatedStyle]} |
356 | 373 | ref={ref} |
357 | 374 | > |
358 | 375 | <ColorSchemeWrapper>{children}</ColorSchemeWrapper> |
359 | | - </View> |
| 376 | + </Animated.View> |
360 | 377 | </FocusTrapForModal> |
361 | 378 | </ModalContent> |
362 | 379 | {!keyboardStateContextValue?.isKeyboardActive && <NavigationBar />} |
|
0 commit comments