2021-06-21 13:44:43 +01:00
|
|
|
import { Docked, OverlappingPanels, ShowIf } from "react-overlapping-panels";
|
|
|
|
import { Switch, Route, useLocation } from "react-router-dom";
|
2021-06-19 20:00:30 +01:00
|
|
|
import styled from "styled-components";
|
2021-06-19 12:34:53 +01:00
|
|
|
|
2021-06-19 20:24:11 +01:00
|
|
|
import ContextMenus from "../lib/ContextMenus";
|
2021-07-05 11:23:23 +01:00
|
|
|
import { isTouchscreenDevice } from "../lib/isTouchscreenDevice";
|
|
|
|
|
2021-06-21 13:28:26 +01:00
|
|
|
import Popovers from "../context/intermediate/Popovers";
|
|
|
|
import Notifications from "../context/revoltjs/Notifications";
|
2021-07-05 11:23:23 +01:00
|
|
|
import StateMonitor from "../context/revoltjs/StateMonitor";
|
|
|
|
import SyncManager from "../context/revoltjs/SyncManager";
|
2021-06-19 20:24:11 +01:00
|
|
|
|
2021-08-01 16:44:51 +01:00
|
|
|
import { USE_TITLEBAR } from "../components/native/Titlebar";
|
2021-07-05 11:23:23 +01:00
|
|
|
import BottomNavigation from "../components/navigation/BottomNavigation";
|
2021-06-19 15:29:04 +01:00
|
|
|
import LeftSidebar from "../components/navigation/LeftSidebar";
|
|
|
|
import RightSidebar from "../components/navigation/RightSidebar";
|
2021-06-21 21:35:21 +01:00
|
|
|
import Open from "./Open";
|
2021-06-20 17:31:53 +01:00
|
|
|
import Channel from "./channels/Channel";
|
2021-06-19 20:24:11 +01:00
|
|
|
import Developer from "./developer/Developer";
|
2021-07-05 11:23:23 +01:00
|
|
|
import Friends from "./friends/Friends";
|
|
|
|
import Home from "./home/Home";
|
|
|
|
import Invite from "./invite/Invite";
|
2021-06-19 22:37:12 +01:00
|
|
|
import ChannelSettings from "./settings/ChannelSettings";
|
2021-07-05 11:23:23 +01:00
|
|
|
import ServerSettings from "./settings/ServerSettings";
|
|
|
|
import Settings from "./settings/Settings";
|
2021-06-19 20:00:30 +01:00
|
|
|
|
|
|
|
const Routes = styled.div`
|
2021-07-05 11:25:20 +01:00
|
|
|
min-width: 0;
|
|
|
|
display: flex;
|
|
|
|
overflow: hidden;
|
|
|
|
flex-direction: column;
|
|
|
|
background: var(--primary-background);
|
2021-06-19 20:00:30 +01:00
|
|
|
`;
|
2021-06-19 12:34:53 +01:00
|
|
|
|
|
|
|
export default function App() {
|
2021-07-05 11:25:20 +01:00
|
|
|
const path = useLocation().pathname;
|
|
|
|
const fixedBottomNav =
|
|
|
|
path === "/" || path === "/settings" || path.startsWith("/friends");
|
|
|
|
const inChannel = path.includes("/channel");
|
|
|
|
const inSpecial =
|
|
|
|
(path.startsWith("/friends") && isTouchscreenDevice) ||
|
|
|
|
path.startsWith("/invite") ||
|
2021-07-10 16:26:58 +01:00
|
|
|
path.includes("/settings");
|
2021-07-05 11:23:23 +01:00
|
|
|
|
2021-07-05 11:25:20 +01:00
|
|
|
return (
|
2021-08-01 14:22:08 +01:00
|
|
|
<>
|
|
|
|
<OverlappingPanels
|
|
|
|
width="100vw"
|
|
|
|
height={
|
|
|
|
USE_TITLEBAR
|
2021-08-01 16:44:51 +01:00
|
|
|
? "calc(var(--app-height) - var(--titlebar-height))"
|
2021-08-01 14:22:08 +01:00
|
|
|
: "var(--app-height)"
|
|
|
|
}
|
|
|
|
leftPanel={
|
|
|
|
inSpecial
|
|
|
|
? undefined
|
|
|
|
: { width: 292, component: <LeftSidebar /> }
|
|
|
|
}
|
|
|
|
rightPanel={
|
|
|
|
!inSpecial && inChannel
|
|
|
|
? { width: 240, component: <RightSidebar /> }
|
|
|
|
: undefined
|
|
|
|
}
|
|
|
|
bottomNav={{
|
|
|
|
component: <BottomNavigation />,
|
|
|
|
showIf: fixedBottomNav ? ShowIf.Always : ShowIf.Left,
|
|
|
|
height: 50,
|
|
|
|
}}
|
|
|
|
docked={isTouchscreenDevice ? Docked.None : Docked.Left}>
|
|
|
|
<Routes>
|
|
|
|
<Switch>
|
|
|
|
<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}
|
|
|
|
/>
|
2021-06-21 13:44:43 +01:00
|
|
|
|
2021-08-01 14:22:08 +01:00
|
|
|
<Route
|
|
|
|
path="/channel/:channel/:message"
|
|
|
|
component={Channel}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/server/:server/channel/:channel/:message"
|
|
|
|
component={Channel}
|
|
|
|
/>
|
2021-07-08 22:47:56 +01:00
|
|
|
|
2021-08-01 14:22:08 +01:00
|
|
|
<Route
|
|
|
|
path="/server/:server/channel/:channel"
|
|
|
|
component={Channel}
|
|
|
|
/>
|
|
|
|
<Route path="/server/:server" />
|
|
|
|
<Route path="/channel/:channel" component={Channel} />
|
2021-06-20 17:31:53 +01:00
|
|
|
|
2021-08-01 14:22:08 +01:00
|
|
|
<Route path="/settings/:page" component={Settings} />
|
|
|
|
<Route path="/settings" component={Settings} />
|
2021-06-19 20:24:11 +01:00
|
|
|
|
2021-08-01 14:22:08 +01:00
|
|
|
<Route path="/dev" component={Developer} />
|
|
|
|
<Route path="/friends" component={Friends} />
|
|
|
|
<Route path="/open/:id" component={Open} />
|
|
|
|
<Route path="/invite/:code" component={Invite} />
|
|
|
|
<Route path="/" component={Home} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
<ContextMenus />
|
|
|
|
<Popovers />
|
|
|
|
<Notifications />
|
|
|
|
<StateMonitor />
|
|
|
|
<SyncManager />
|
|
|
|
</OverlappingPanels>
|
|
|
|
</>
|
2021-07-05 11:25:20 +01:00
|
|
|
);
|
2021-07-05 11:23:23 +01:00
|
|
|
}
|