import React, { PropsWithChildren, useEffect } from 'react' import { useAtomValue, useSetAtom } from 'jotai' import { useTheme } from 'next-themes' import { SidebarLeft, SidebarRight } from '@containers/Sidebar' import { twMerge } from 'tailwind-merge' import { rightSideBarExpandStateAtom } from '@helpers/atoms/SideBarExpand.atom' import Topbar from '@containers/Topbar' import BottomBar from '@containers/BottomBar' import { motion as m } from 'framer-motion' import { getMainViewStateAtom } from '@helpers/atoms/MainView.atom' import { MainViewState } from '@helpers/atoms/MainView.atom' const BaseLayout = (props: PropsWithChildren) => { const { children } = props const isRightSidebarVisible = useAtomValue(rightSideBarExpandStateAtom) const viewState = useAtomValue(getMainViewStateAtom) const { theme } = useTheme() // Force set theme native useEffect(() => { async function setTheme() { switch (theme) { case 'light': return await window?.electronAPI.setNativeThemeLight() case 'dark': return await window?.electronAPI.setNativeThemeDark() default: return await window?.electronAPI.setNativeThemeSystem() } } setTheme() }, [theme]) return (
{children}
{viewState === MainViewState.BotInfo && isRightSidebarVisible && ( )}
) } export default BaseLayout