Commit 7dd5f05c by G

updated a little bit the rendering condition and export the modal z index os…

updated a little bit the rendering condition and export the modal z index os that other component can increment their based on this value
parent 197cada0
import { createContext, useContext, useState } from "react";
import { createContext, useContext, useEffect, useState } from "react";
import { View } from "react-native";
export interface ImodalsManagerContext {
......@@ -26,6 +26,13 @@ export const ModalsManagerProvider = ({ children }: { children: React.ReactNode
setShowBackdrop(false);
};
useEffect(() => {
return () => {
setShowBackdrop(false);
setModalElement(null);
};
}, []);
return (
<ModalsManagerContext.Provider
value={{
......@@ -34,8 +41,13 @@ export const ModalsManagerProvider = ({ children }: { children: React.ReactNode
}}
>
{children}
{showBackdrop && <OverlayBackdrop />}
{modalElement && modalElement}
{modalElement && (
<>
<OverlayBackdrop />
{modalElement}
</>
)}
</ModalsManagerContext.Provider>
);
};
......@@ -44,6 +56,8 @@ export const useModalsManagerContext = () => {
return useContext(ModalsManagerContext);
};
export const OVERLAY_BACKDROP_Z_INDEX = 10;
const OverlayBackdrop = () => {
return (
<View
......@@ -53,7 +67,7 @@ const OverlayBackdrop = () => {
height: "100%",
// justifyContent: "center",
// alignItems: "center",
zIndex: 10,
zIndex: OVERLAY_BACKDROP_Z_INDEX,
backgroundColor: "black",
opacity: 0.5,
position: "absolute",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment