From 35ffee48e594c5b4a1209f32aa50aa04c5bd0b28 Mon Sep 17 00:00:00 2001 From: Mo Gorhom Date: Thu, 4 Mar 2021 15:51:44 +0000 Subject: [PATCH] fix: unmounting modals with navigation (#315) * chore: updated portal * refactor: implementation * chore: updated examples * chore: prevent update state when sheet is not mounted * chore: updated portal --- example/package.json | 2 +- example/src/screens/modal/StackExample.tsx | 9 - example/yarn.lock | 14 +- package.json | 2 +- src/components/bottomSheet/BottomSheet.tsx | 25 +- .../bottomSheetModal/BottomSheetModal.tsx | 228 +++++++++++------- src/components/bottomSheetModal/constants.ts | 7 +- src/components/bottomSheetModal/types.d.ts | 7 +- .../BottomSheetModalProvider.tsx | 130 +++++----- src/constants.ts | 13 +- yarn.lock | 14 +- 11 files changed, 271 insertions(+), 180 deletions(-) diff --git a/example/package.json b/example/package.json index 0f9bcb964..b8c31dbac 100644 --- a/example/package.json +++ b/example/package.json @@ -10,7 +10,7 @@ "postinstall": "npx patch-package" }, "dependencies": { - "@gorhom/portal": "^0.2.0", + "@gorhom/portal": "^1.0.4", "@gorhom/showcase-template": "^1.0.2", "@react-native-community/blur": "^3.6.0", "@react-native-community/masked-view": "0.1.10", diff --git a/example/src/screens/modal/StackExample.tsx b/example/src/screens/modal/StackExample.tsx index de3990cd8..41e5f38b0 100644 --- a/example/src/screens/modal/StackExample.tsx +++ b/example/src/screens/modal/StackExample.tsx @@ -55,13 +55,7 @@ const StackExample = () => { dismiss('A'); }, [dismiss]); - const handleModalDismiss = useCallback( - () => console.log('Modal Dismissed'), - [] - ); - // renders - const renderBottomSheetContent = useCallback( (title, onPress) => ( { name="A" ref={bottomSheetModalARef} snapPoints={snapPoints} - onDismiss={handleModalDismiss} children={renderBottomSheetContent('Modal A', handlePresentBPress)} /> @@ -129,7 +122,6 @@ const StackExample = () => { name="B" ref={bottomSheetModalBRef} snapPoints={snapPoints} - onDismiss={handleModalDismiss} children={renderBottomSheetContent('Modal B', handlePresentCPress)} /> @@ -139,7 +131,6 @@ const StackExample = () => { index={1} snapPoints={snapPoints} dismissOnPanDown={false} - onDismiss={handleModalDismiss} children={renderBottomSheetContent('Modal C', handleDismissCPress)} /> diff --git a/example/yarn.lock b/example/yarn.lock index 9b442ccc0..2934d38af 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -868,11 +868,12 @@ dependencies: "@types/hammerjs" "^2.0.36" -"@gorhom/portal@^0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@gorhom/portal/-/portal-0.2.0.tgz#65423726b1352e2b9e3c3b8da83a58e4dff48ce6" - integrity sha512-PoYYSliPCl624ORih+zyI1pVbH2Y2Mj+EY6nXeAIi2r1LGv10hItZLzdgnbPPfQ0neikTDYArlOzuB5zKIex5w== +"@gorhom/portal@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@gorhom/portal/-/portal-1.0.4.tgz#643c7baaffee223819cdd99dad748c3d9dc6bd73" + integrity sha512-KalM9E6Op1TCzi00YKhczBz86EV0yYpWuRuTt5J4VS09O2gGbGAEEJwUKb/Rvr3XadtinpLjePj0tZ6lFVPp+g== dependencies: + immer "^8.0.1" lodash.isequal "^4.5.0" nanoid "^3.1.20" @@ -2466,6 +2467,11 @@ image-size@^0.6.0: resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.3.tgz#e7e5c65bb534bd7cdcedd6cb5166272a85f75fb2" integrity sha512-47xSUiQioGaB96nqtp5/q55m0aBQSQdyIloMOc/x+QVTDZLNmXE892IIDrJ0hM1A5vcNUDD5tDffkSP5lCaIIA== +immer@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656" + integrity sha512-aqXhGP7//Gui2+UrEtvxZxSquQVXTpZ7KDxfCcKAF3Vysvw0CViVaW9RZ1j1xlIYqaaaipBoqdqeibkc18PNvA== + import-fresh@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546" diff --git a/package.json b/package.json index 5f7dae55d..57e6964de 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "bootstrap": "yarn install && yarn example" }, "dependencies": { - "@gorhom/portal": "^0.2.0", + "@gorhom/portal": "^1.0.4", "invariant": "^2.2.4", "lodash.isequal": "^4.5.0", "nanoid": "^3.1.20", diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index 757f3ac20..5e360bdc5 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -165,6 +165,7 @@ const BottomSheetComponent = forwardRef( const currentIndexRef = useRef( animateOnMount ? -1 : _providedIndex ); + const isClosing = useRef(false); const didMountOnAnimate = useRef(false); // scrollable variables @@ -221,6 +222,10 @@ const BottomSheetComponent = forwardRef( } currentIndexRef.current = index; + if (isClosing.current && (index === 0 || index === -1)) { + isClosing.current = false; + } + if (_providedOnChange) { /** * to avoid having -0 🤷‍♂️ @@ -370,19 +375,32 @@ const BottomSheetComponent = forwardRef( snapPoints.length - 1 }` ); + if (isClosing.current) { + return; + } const newSnapPoint = snapPoints[index]; runOnUI(animateToPoint)(newSnapPoint); }, [animateToPoint, snapPoints] ); const handleClose = useCallback(() => { + if (isClosing.current) { + return; + } + isClosing.current = true; runOnUI(animateToPoint)(safeContainerHeight); }, [animateToPoint, safeContainerHeight]); const handleExpand = useCallback(() => { + if (isClosing.current) { + return; + } const newSnapPoint = snapPoints[snapPoints.length - 1]; runOnUI(animateToPoint)(newSnapPoint); }, [animateToPoint, snapPoints]); const handleCollapse = useCallback(() => { + if (isClosing.current) { + return; + } const newSnapPoint = snapPoints[0]; runOnUI(animateToPoint)(newSnapPoint); }, [animateToPoint, snapPoints]); @@ -493,6 +511,7 @@ const BottomSheetComponent = forwardRef( animateOnMount && isLayoutCalculated && didMountOnAnimate.current === false && + isClosing.current === false && snapPoints[_providedIndex] !== safeContainerHeight ) { const newSnapPoint = snapPoints[_providedIndex]; @@ -512,7 +531,11 @@ const BottomSheetComponent = forwardRef( * keep animated position synced with snap points. */ useEffect(() => { - if (isLayoutCalculated && currentIndexRef.current !== -1) { + if ( + isLayoutCalculated && + currentIndexRef.current !== -1 && + isClosing.current === false + ) { const newSnapPoint = snapPoints[currentIndexRef.current]; requestAnimationFrame(() => runOnUI(animateToPoint)(newSnapPoint)); } diff --git a/src/components/bottomSheetModal/BottomSheetModal.tsx b/src/components/bottomSheetModal/BottomSheetModal.tsx index d1200619d..4fa664328 100644 --- a/src/components/bottomSheetModal/BottomSheetModal.tsx +++ b/src/components/bottomSheetModal/BottomSheetModal.tsx @@ -7,12 +7,15 @@ import React, { useRef, useState, } from 'react'; -import { Portal } from '@gorhom/portal'; +import { Portal, usePortal } from '@gorhom/portal'; import { nanoid } from 'nanoid/non-secure'; import isEqual from 'lodash.isequal'; import BottomSheet from '../bottomSheet'; import { useBottomSheetModalInternal } from '../../hooks'; -import { DEFAULT_DISMISS_ON_PAN_DOWN } from './constants'; +import { + DEFAULT_STACK_BEHAVIOR, + DEFAULT_DISMISS_ON_PAN_DOWN, +} from './constants'; import type { BottomSheetModalMethods } from '../../types'; import type { BottomSheetModalProps } from './types'; @@ -25,7 +28,7 @@ const BottomSheetModalComponent = forwardRef< const { // modal props name, - stackBehavior = 'replace', + stackBehavior = DEFAULT_STACK_BEHAVIOR, dismissOnPanDown = DEFAULT_DISMISS_ON_PAN_DOWN, onDismiss: _providedOnDismiss, @@ -43,18 +46,23 @@ const BottomSheetModalComponent = forwardRef< const [mount, setMount] = useState(false); //#endregion + //#region hooks const { containerHeight, mountSheet, unmountSheet, willUnmountSheet, } = useBottomSheetModalInternal(); + const { removePortal: unmountPortal } = usePortal(); + //#endregion //#region refs const bottomSheetRef = useRef(null); - const isMinimized = useRef(false); - const isForcedDismissed = useRef(false); const currentIndexRef = useRef(-1); + const restoreIndexRef = useRef(-1); + const minimized = useRef(false); + const forcedDismissed = useRef(false); + const mounted = useRef(true); //#endregion //#region variables @@ -70,119 +78,173 @@ const BottomSheetModalComponent = forwardRef< ); //#endregion - //#region callbacks - const doDismiss = useCallback(() => { - if (_providedOnDismiss) { - _providedOnDismiss(); - } - unmountSheet(key); - setMount(false); + //#region private methods + const resetVariables = useCallback(() => { + currentIndexRef.current = -1; + restoreIndexRef.current = -1; + minimized.current = false; + mounted.current = true; + forcedDismissed.current = false; + }, []); + const adjustIndex = useCallback( + (_index: number) => (dismissOnPanDown ? _index - 1 : _index), + [dismissOnPanDown] + ); + const unmount = useCallback(() => { + const _mounted = mounted.current; - // reset - isMinimized.current = false; - isForcedDismissed.current = false; - }, [key, _providedOnDismiss, unmountSheet]); - const handleOnChange = useCallback( - (_index: number) => { - if (isMinimized.current && !isForcedDismissed.current) { - return; - } + // reset variables + resetVariables(); - const adjustedIndex = dismissOnPanDown ? _index - 1 : _index; - currentIndexRef.current = _index; + // unmount sheet and portal + unmountSheet(key); + unmountPortal(key); - if (adjustedIndex >= 0) { - if (_providedOnChange) { - _providedOnChange(adjustedIndex); - } - } else { - doDismiss(); - } - }, - [dismissOnPanDown, _providedOnChange, doDismiss] - ); + // unmount the node, if sheet is still mounted + if (_mounted) { + setMount(false); + } + + // fire `onDismiss` callback + if (_providedOnDismiss) { + _providedOnDismiss(); + } + }, [key, resetVariables, unmountSheet, unmountPortal, _providedOnDismiss]); //#endregion - //#region private methods - const handleMinimize = useCallback(() => { - if (!isMinimized.current) { - isMinimized.current = true; - bottomSheetRef.current?.close(); + //#region bottom sheet methods + const handleSnapTo = useCallback(() => { + if (minimized.current) { + return; } + + bottomSheetRef.current?.snapTo(adjustIndex(currentIndexRef.current)); + }, [adjustIndex]); + const handleExpand = useCallback(() => { + if (minimized.current) { + return; + } + bottomSheetRef.current?.expand(); }, []); - const handleRestore = useCallback(() => { - if (isMinimized.current) { - isMinimized.current = false; - bottomSheetRef.current?.snapTo(currentIndexRef.current); + const handleCollapse = useCallback(() => { + if (minimized.current) { + return; + } + if (dismissOnPanDown) { + bottomSheetRef.current?.snapTo(1); + } else { + bottomSheetRef.current?.collapse(); + } + }, [dismissOnPanDown]); + const handleClose = useCallback(() => { + if (minimized.current) { + return; } + bottomSheetRef.current?.close(); }, []); //#endregion - //#region public methods + //#region bottom sheet modal methods const handlePresent = useCallback(() => { requestAnimationFrame(() => { setMount(true); mountSheet(key, ref, stackBehavior); }); - }, [key, stackBehavior, mountSheet, ref]); - const handleDismiss = useCallback( - (force: boolean = false) => { - if (force) { - if (isMinimized.current) { - doDismiss(); - return; - } - isForcedDismissed.current = true; - isMinimized.current = false; - } else { - willUnmountSheet(key); - } - bottomSheetRef.current?.close(); - }, - [key, doDismiss, willUnmountSheet] - ); - const handleClose = useCallback(() => { - if (isMinimized.current) { + }, [key, stackBehavior, ref, mountSheet]); + const handleDismiss = useCallback(() => { + /** + * if modal is already been dismiss, we exit the method. + */ + if (currentIndexRef.current === -1 && minimized.current === false) { return; } + + if (minimized.current) { + unmount(); + return; + } + willUnmountSheet(key); + forcedDismissed.current = true; bottomSheetRef.current?.close(); - }, []); - const handleCollapse = useCallback(() => { - if (isMinimized.current) { + }, [willUnmountSheet, unmount, key]); + const handleMinimize = useCallback(() => { + if (minimized.current) { return; } - if (dismissOnPanDown) { - bottomSheetRef.current?.snapTo(1); + minimized.current = true; + + /** + * if modal got minimized before it finish its mounting + * animation, we set the `restoreIndexRef` to the + * provided index. + */ + if (currentIndexRef.current === -1) { + restoreIndexRef.current = index; } else { - bottomSheetRef.current?.collapse(); + restoreIndexRef.current = currentIndexRef.current; } - }, [dismissOnPanDown]); - const handleExpand = useCallback(() => { - if (isMinimized.current) { + bottomSheetRef.current?.close(); + }, [index]); + const handleRestore = useCallback(() => { + if (!minimized.current || forcedDismissed.current) { return; } - bottomSheetRef.current?.expand(); + minimized.current = false; + bottomSheetRef.current?.snapTo(restoreIndexRef.current); }, []); - const handleSnapTo = useCallback( + //#endregion + + //#region callbacks + const handlePortalOnUnmount = useCallback(() => { + /** + * if modal is already been dismiss, we exit the method. + */ + if (currentIndexRef.current === -1 && minimized.current === false) { + return; + } + + mounted.current = false; + forcedDismissed.current = true; + + if (minimized.current) { + unmount(); + return; + } + willUnmountSheet(key); + bottomSheetRef.current?.close(); + }, [key, unmount, willUnmountSheet]); + const handleBottomSheetOnChange = useCallback( (_index: number) => { - if (isMinimized.current) { + const adjustedIndex = adjustIndex(_index); + currentIndexRef.current = _index; + + if (_providedOnChange) { + _providedOnChange(adjustedIndex); + } + + if (minimized.current) { return; } - bottomSheetRef.current?.snapTo(_index + (dismissOnPanDown ? 1 : 0)); + + if (adjustedIndex === -1) { + unmount(); + } }, - [dismissOnPanDown] + [adjustIndex, unmount, _providedOnChange] ); //#endregion - //#region expose public methods + //#region expose methods useImperativeHandle(ref, () => ({ - present: handlePresent, - dismiss: handleDismiss, - close: handleClose, + // sheet snapTo: handleSnapTo, expand: handleExpand, collapse: handleCollapse, - // private + close: handleClose, + dismiss: handleDismiss, + // modal methods + present: handlePresent, + // internal minimize: handleMinimize, restore: handleRestore, })); @@ -191,7 +253,7 @@ const BottomSheetModalComponent = forwardRef< // render // console.log('BottomSheetModal', index, snapPoints) return mount ? ( - + diff --git a/src/components/bottomSheetModal/constants.ts b/src/components/bottomSheetModal/constants.ts index ec4c733a8..dd9af3a78 100644 --- a/src/components/bottomSheetModal/constants.ts +++ b/src/components/bottomSheetModal/constants.ts @@ -1,7 +1,4 @@ -// export const DEFAULT_OVERLAY_OPACITY = 0.5; -// export const DEFAULT_DISMISS_ON_OVERLAY_PRESS = true; -// export const DEFAULT_ALLOW_TOUCH_THROUGH_OVERLAY = false; - +const DEFAULT_STACK_BEHAVIOR = 'replace'; const DEFAULT_DISMISS_ON_PAN_DOWN = true; -export { DEFAULT_DISMISS_ON_PAN_DOWN }; +export { DEFAULT_STACK_BEHAVIOR, DEFAULT_DISMISS_ON_PAN_DOWN }; diff --git a/src/components/bottomSheetModal/types.d.ts b/src/components/bottomSheetModal/types.d.ts index 3ecf1211b..1afe42c45 100644 --- a/src/components/bottomSheetModal/types.d.ts +++ b/src/components/bottomSheetModal/types.d.ts @@ -1,4 +1,5 @@ -import { BottomSheetProps } from '../bottomSheet'; +import type { BottomSheetProps } from '../bottomSheet'; +import type { MODAL_STACK_BEHAVIOR } from '../../constants'; export interface BottomSheetModalPrivateMethods { dismiss: (force?: boolean) => void; @@ -6,10 +7,10 @@ export interface BottomSheetModalPrivateMethods { restore: () => void; } -export type BottomSheetModalStackBehavior = 'push' | 'replace'; +export type BottomSheetModalStackBehavior = keyof typeof MODAL_STACK_BEHAVIOR; export interface BottomSheetModalProps - extends Exclude { + extends Omit { /** * Modal name to help identify the modal for later on. * @type string diff --git a/src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx b/src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx index 40e9c5b7c..ee1740f00 100644 --- a/src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx +++ b/src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx @@ -1,23 +1,20 @@ import React, { useCallback, useMemo, useRef, useState } from 'react'; -import { PortalHost } from '@gorhom/portal'; +import { PortalProvider } from '@gorhom/portal'; import { BottomSheetModalProvider, BottomSheetModalInternalProvider, } from '../../contexts'; import BottomSheetContainer from '../bottomSheetContainer'; -import { WINDOW_HEIGHT } from '../../constants'; +import { MODAL_STACK_BEHAVIOR, WINDOW_HEIGHT } from '../../constants'; import type { BottomSheetModalStackBehavior } from '../bottomSheetModal'; import type { BottomSheetModalProviderProps, BottomSheetModalRef, } from './types'; -const BottomSheetModalProviderWrapper = ( - props: BottomSheetModalProviderProps -) => { - // extract props - const { children } = props; - +const BottomSheetModalProviderWrapper = ({ + children, +}: BottomSheetModalProviderProps) => { //#region layout state const [containerHeight, setContainerHeight] = useState(WINDOW_HEIGHT); //#endregion @@ -34,102 +31,99 @@ const BottomSheetModalProviderWrapper = ( //#region private methods const handleMountSheet = useCallback( - (key: string, ref, stackBehavior: BottomSheetModalStackBehavior) => { + (key: string, ref: any, stackBehavior: BottomSheetModalStackBehavior) => { + const _sheetsQueue = sheetsQueueRef.current.slice(); + const sheetIndex = _sheetsQueue.findIndex(item => item.key === key); + const sheetOnTop = sheetIndex === _sheetsQueue.length - 1; + + /** + * Exit the method, if sheet is already presented + * and at the top. + */ + if (sheetIndex !== -1 && sheetOnTop) { + return; + } + /** - * Here we try to minimize the current sheet if exists, - * also we make sure that it is not incoming mounted sheet. + * Minimize the current sheet if: + * - it exists. + * - it is not unmounting. + * - stack behavior is 'replace'. */ - const mountedSheet = - sheetsQueueRef.current[sheetsQueueRef.current.length - 1]; + const currentMountedSheet = _sheetsQueue[_sheetsQueue.length - 1]; if ( - stackBehavior === 'replace' && - mountedSheet && - mountedSheet.key !== key && - !mountedSheet.willUnmount + currentMountedSheet && + !currentMountedSheet.willUnmount && + stackBehavior === MODAL_STACK_BEHAVIOR.replace ) { - sheetsQueueRef.current[ - sheetsQueueRef.current.length - 1 - ].ref.current.minimize(); + currentMountedSheet.ref.current.minimize(); } /** - * We check if the incoming sheet is already mounted. + * Restore and remove incoming sheet from the queue, + * if it was registered. */ - const isIncomingSheetMounted = - sheetsQueueRef.current.find(item => item.key === key) !== undefined; - - if (isIncomingSheetMounted) { - /** - * We move the mounted incoming sheet to the - * end of the queue. - */ - const newSheetsQueue = sheetsQueueRef.current.filter( - item => item.key !== key - ); - newSheetsQueue.push({ - key, - ref, - willUnmount: false, - }); - sheetsQueueRef.current = newSheetsQueue; - + if (sheetIndex !== -1) { + _sheetsQueue.splice(sheetIndex, 1); ref.current.restore(); - } else { - /** - * We add the incoming sheet to the end of the queue. - */ - sheetsQueueRef.current.push({ - key, - ref, - willUnmount: false, - }); } + + _sheetsQueue.push({ + key, + ref, + willUnmount: false, + }); + sheetsQueueRef.current = _sheetsQueue; }, [] ); const handleUnmountSheet = useCallback((key: string) => { + const _sheetsQueue = sheetsQueueRef.current.slice(); + const sheetIndex = _sheetsQueue.findIndex(item => item.key === key); + const sheetOnTop = sheetIndex === _sheetsQueue.length - 1; + /** * Here we remove the unmounted sheet and update * the sheets queue. */ - const newSheetsQueue = sheetsQueueRef.current.filter( - item => item.key !== key - ); - sheetsQueueRef.current = newSheetsQueue; + _sheetsQueue.splice(sheetIndex, 1); + sheetsQueueRef.current = _sheetsQueue; - /** - * Here we try to restore previous sheet position, - * This is needed when user dismiss the modal by panning down. - */ + // /** + // * Here we try to restore previous sheet position if unmounted + // * sheet was on top. This is needed when user dismiss + // * the modal by panning down. + // */ const hasMinimizedSheet = sheetsQueueRef.current.length > 0; - if (hasMinimizedSheet) { + if (sheetOnTop && hasMinimizedSheet) { sheetsQueueRef.current[ sheetsQueueRef.current.length - 1 ].ref.current.restore(); } }, []); const handleWillUnmountSheet = useCallback((key: string) => { + const _sheetsQueue = sheetsQueueRef.current.slice(); + const sheetIndex = _sheetsQueue.findIndex(item => item.key === key); + const sheetOnTop = sheetIndex === _sheetsQueue.length - 1; + /** * Here we mark the sheet that will unmount, * so it won't be restored. */ - const sheetToBeUnmount = sheetsQueueRef.current.find( - item => item.key === key - ); - if (sheetToBeUnmount) { - sheetToBeUnmount.willUnmount = true; + if (sheetIndex !== -1) { + _sheetsQueue[sheetIndex].willUnmount = true; } /** * Here we try to restore previous sheet position, * This is needed when user dismiss the modal by fire the dismiss action. */ - const hasMinimizedSheet = sheetsQueueRef.current.length > 1; - if (hasMinimizedSheet) { - sheetsQueueRef.current[ - sheetsQueueRef.current.length - 2 - ].ref.current.restore(); + const hasMinimizedSheet = _sheetsQueue.length > 1; + if (sheetOnTop && hasMinimizedSheet) { + _sheetsQueue[_sheetsQueue.length - 2].ref.current.restore(); } + + sheetsQueueRef.current = _sheetsQueue; }, []); //#endregion @@ -182,7 +176,7 @@ const BottomSheetModalProviderWrapper = ( onMeasureHeight={handleOnContainerMeasureHeight} children={null} /> - {children} + {children} ); diff --git a/src/constants.ts b/src/constants.ts index 3ff1533fa..024cae9ef 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -14,4 +14,15 @@ enum ANIMATION_STATE { STOPPED, } -export { WINDOW_HEIGHT, WINDOW_WIDTH, GESTURE, ANIMATION_STATE }; +const MODAL_STACK_BEHAVIOR = { + replace: 'replace', + push: 'push', +}; + +export { + WINDOW_HEIGHT, + WINDOW_WIDTH, + GESTURE, + ANIMATION_STATE, + MODAL_STACK_BEHAVIOR, +}; diff --git a/yarn.lock b/yarn.lock index 220afd472..de31fd772 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1720,11 +1720,12 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@gorhom/portal@^0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@gorhom/portal/-/portal-0.2.0.tgz#65423726b1352e2b9e3c3b8da83a58e4dff48ce6" - integrity sha512-PoYYSliPCl624ORih+zyI1pVbH2Y2Mj+EY6nXeAIi2r1LGv10hItZLzdgnbPPfQ0neikTDYArlOzuB5zKIex5w== +"@gorhom/portal@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@gorhom/portal/-/portal-1.0.4.tgz#643c7baaffee223819cdd99dad748c3d9dc6bd73" + integrity sha512-KalM9E6Op1TCzi00YKhczBz86EV0yYpWuRuTt5J4VS09O2gGbGAEEJwUKb/Rvr3XadtinpLjePj0tZ6lFVPp+g== dependencies: + immer "^8.0.1" lodash.isequal "^4.5.0" nanoid "^3.1.20" @@ -5096,6 +5097,11 @@ image-size@^0.6.0: resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.3.tgz#e7e5c65bb534bd7cdcedd6cb5166272a85f75fb2" integrity sha512-47xSUiQioGaB96nqtp5/q55m0aBQSQdyIloMOc/x+QVTDZLNmXE892IIDrJ0hM1A5vcNUDD5tDffkSP5lCaIIA== +immer@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656" + integrity sha512-aqXhGP7//Gui2+UrEtvxZxSquQVXTpZ7KDxfCcKAF3Vysvw0CViVaW9RZ1j1xlIYqaaaipBoqdqeibkc18PNvA== + import-cwd@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/import-cwd/-/import-cwd-3.0.0.tgz#20845547718015126ea9b3676b7592fb8bd4cf92"