import {useSidebar} from "@contexts/sidebarContext";
import {useThemeProvider} from "@contexts/themeContext";
import {useLocation} from "react-router-dom";
import {ROUTE_PATH} from "@constants/routes";

const AppContainer=({children})=>{
    const {open} = useSidebar();
    const {isMobile} = useThemeProvider();
    const sidebar=open?'sidebar-open':'sidebar-close';
    const styleadd=isMobile()?'':sidebar;
    const {pathname} = useLocation();
    const checkNoAni=()=>{
        //桌面版sports 太卡去掉 sidebar 动画
        if (!isMobile())
        {
            if (pathname.startsWith(ROUTE_PATH.SPORTS)){
                return true;
            }
        }
        return false;
    }
    const isNoAni=checkNoAni();
    return (
        <div className={`app_container ${styleadd} ${isNoAni?'sidebar-noani':''}`} style={{marginTop:"var(--header-active)"}}>
            {children}
        </div>
    )
}
export default AppContainer;
