import { useLocation } from "react-router-dom"; import { useMemo, ReactNode } from "react"; import { Path, SlotID } from "@/app/constant"; import { getLang } from "@/app/locales"; import useMobileScreen from "@/app/hooks/useMobileScreen"; import { isIOS } from "@/app/utils"; import backgroundUrl from "!url-loader!@/app/icons/background.svg"; import useListenWinResize from "@/app/hooks/useListenWinResize"; interface ScreenProps { children: ReactNode; noAuth: ReactNode; sidebar: ReactNode; } export default function Screen(props: ScreenProps) { const location = useLocation(); const isAuth = location.pathname === Path.Auth; const isMobileScreen = useMobileScreen(); const isIOSMobile = useMemo( () => isIOS() && isMobileScreen, [isMobileScreen], ); useListenWinResize(); let containerClassName = "flex h-[100%] w-[100%] bg-center overflow-hidden"; let sidebarClassName = "flex-0 overflow-hidden"; let pageClassName = "flex-1 h-[100%] min-w-0 overflow-hidden"; if (isMobileScreen) { containerClassName = "relative flex flex-col-reverse h-[100%] w-[100%] bg-center"; sidebarClassName = "absolute w-[100%] bottom-0 z-10"; pageClassName = "w-[100%] h-[100%]"; } return (
{isAuth ? ( props.noAuth ) : ( <>
{props.sidebar}
{props.children}
)}
); }