import { usePortal } from "@gorhom/portal"; import { type ReactNode, useCallback, useEffect, useState } from "react"; import { ScrollView, View } from "react-native"; import { px, vh } from "yoshiki/native"; import { Container } from "./container"; import { ContrastArea, SwitchVariant, type YoshikiFunc } from "./theme"; import { ts } from "./utils"; export const Popup = ({ children, ...props }: { children: ReactNode | YoshikiFunc; }) => { return ( {({ css, theme }) => ( theme.themeOverlay, justifyContent: "center", alignItems: "center", })} > theme.background, overflow: "hidden", }, props, )} > {typeof children === "function" ? children({ css, theme }) : children} )} ); }; export const usePopup = () => { const { addPortal, removePortal } = usePortal(); const [current, setPopup] = useState(); const close = useCallback(() => setPopup(undefined), []); useEffect(() => { addPortal("popup", current); return () => removePortal("popup"); }, [current, addPortal, removePortal]); return [setPopup, close] as const; };