This commit is contained in:
Philip Cesar Garay
2025-07-31 21:25:33 +08:00
parent 5cfbc81e3a
commit 84fc719a10
307 changed files with 46470 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
import React from "react";
import { Pressable, StyleSheet } from "react-native";
import { AnimatePresence, Motion } from "@legendapp/motion";
import { BlurView } from "expo-blur";
import { Portal } from "@gorhom/portal";
import useLayoutType from "../hooks/useLayoutType";
import { Palette, Style } from "../styles";
import { defaultBlurIntensity } from "../styles/Style";
const Overlay = ({
isVisible,
setIsVisible,
blurIntensity = null,
children,
contentContainerStyle = {},
hasPortal = true,
}) => {
const { isNative } = useLayoutType();
const ContentContainerView = hasPortal ? Portal : React.Fragment;
return (
<ContentContainerView>
<AnimatePresence>
{isVisible ? (
<Motion.View
key="overlay"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{
type: "tween",
duration: 500,
}}
style={{
position: isNative ? "absolute" : "fixed",
...StyleSheet.absoluteFillObject,
backgroundColor: Palette.ultraLightBlack,
flex: 1,
...Style.containerCenter,
}}
>
<BlurView
intensity={blurIntensity || isNative ? defaultBlurIntensity : 15}
tint="dark"
style={{
width: "100%",
height: "100%",
...Style.containerCenter,
...StyleSheet.absoluteFillObject,
...contentContainerStyle,
}}
>
<Pressable
style={{
...StyleSheet.absoluteFillObject,
}}
onPress={() => {
console.log("overlay pressed");
setIsVisible?.(false);
}}
/>
{children}
</BlurView>
</Motion.View>
) : null}
</AnimatePresence>
</ContentContainerView>
);
};
export default Overlay;