Skip to content
Snippets Groups Projects
RevoltApp.tsx 3.68 KiB
Newer Older
import { Docked, OverlappingPanels, ShowIf } from "react-overlapping-panels";
insert's avatar
insert committed
import { isTouchscreenDevice } from "../lib/isTouchscreenDevice";
import { Switch, Route, useLocation } from "react-router-dom";
insert's avatar
insert committed
import styled from "styled-components";
insert's avatar
insert committed
import ContextMenus from "../lib/ContextMenus";
import Popovers from "../context/intermediate/Popovers";
import SyncManager from "../context/revoltjs/SyncManager";
import StateMonitor from "../context/revoltjs/StateMonitor";
import Notifications from "../context/revoltjs/Notifications";
insert's avatar
insert committed

insert's avatar
insert committed
import LeftSidebar from "../components/navigation/LeftSidebar";
import RightSidebar from "../components/navigation/RightSidebar";
import BottomNavigation from "../components/navigation/BottomNavigation";
insert's avatar
insert committed

insert's avatar
insert committed
import Open from "./Open";
insert's avatar
insert committed
import Home from './home/Home';
insert's avatar
insert committed
import Invite from "./invite/Invite";
insert's avatar
insert committed
import Friends from "./friends/Friends";
import Channel from "./channels/Channel";
insert's avatar
insert committed
import Settings from './settings/Settings';
insert's avatar
insert committed
import Developer from "./developer/Developer";
insert's avatar
insert committed
import ServerSettings from "./settings/ServerSettings";
import ChannelSettings from "./settings/ChannelSettings";
insert's avatar
insert committed

const Routes = styled.div`
    min-width: 0;
    display: flex;
    overflow: hidden;
    flex-direction: column;
    background: var(--primary-background);
`;
insert's avatar
insert committed

export default function App() {
    const path = useLocation().pathname;
    const fixedBottomNav = (path === '/' || path === '/settings' || path.startsWith("/friends"));
insert's avatar
insert committed
    const inSettings = path === '/settings';
    const inChannel = path.includes('/channel');
insert's avatar
insert committed
    return (
        <OverlappingPanels
            width="100vw"
insert's avatar
insert committed
            height="100vh"
insert's avatar
insert committed
            leftPanel={inSettings ? undefined : { width: 292, component: <LeftSidebar /> }}
            rightPanel={(!inSettings && inChannel) ? { width: 240, component: <RightSidebar /> } : undefined}
            bottomNav={{
                component: <BottomNavigation />,
                showIf: fixedBottomNav ? ShowIf.Always : ShowIf.Left,
                height: 50
            }}
insert's avatar
insert committed
            docked={isTouchscreenDevice ? Docked.None : Docked.Left}>
insert's avatar
insert committed
            <Routes>
                <Switch>
insert's avatar
insert committed
                    <Route path="/server/:server/channel/:channel/settings/:page" component={ChannelSettings} />
                    <Route path="/server/:server/channel/:channel/settings" component={ChannelSettings} />
                    <Route path="/server/:server/settings/:page" component={ServerSettings} />
                    <Route path="/server/:server/settings" component={ServerSettings} />
                    <Route path="/channel/:channel/settings/:page" component={ChannelSettings} />
                    <Route path="/channel/:channel/settings" component={ChannelSettings} />

                    <Route path="/channel/:channel/message/:message" component={Channel} />
                    <Route path="/server/:server/channel/:channel" component={Channel} />
                    <Route path="/server/:server" />
                    <Route path="/channel/:channel" component={Channel} />
insert's avatar
insert committed
                    
                    <Route path="/settings/:page" component={Settings} />
                    <Route path="/settings" component={Settings} />
insert's avatar
insert committed

insert's avatar
insert committed
                    <Route path="/dev" component={Developer} />
                    <Route path="/friends" component={Friends} />
insert's avatar
insert committed
                    <Route path="/open/:id" component={Open} />
                    <Route path="/invite/:code" component={Invite} />
insert's avatar
insert committed
                    <Route path="/" component={Home} />
insert's avatar
insert committed
                </Switch>
            </Routes>
insert's avatar
insert committed
            <ContextMenus />
insert's avatar
insert committed
            <Popovers />
            <Notifications />
            <StateMonitor />
            <SyncManager />
insert's avatar
insert committed
        </OverlappingPanels>
    );
};