From d8870f20620fc459ed284f652eb204366e6e317d Mon Sep 17 00:00:00 2001
From: Jonas Dellinger <jonas@dellinger.dev>
Date: Mon, 30 May 2022 22:23:13 +0200
Subject: Update lib, show example of router

---
 src/index.tsx | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index 8fd3a48..89de1b7 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,10 +1,12 @@
 import {
   ButtonItem,
   definePlugin,
+  DialogButton,
   Menu,
   MenuItem,
   PanelSection,
   PanelSectionRow,
+  Router,
   ServerAPI,
   showModal,
   staticClasses,
@@ -60,14 +62,44 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => {
           <img src={logo} />
         </div>
       </PanelSectionRow>
+
+      <PanelSectionRow>
+        <ButtonItem
+          layout="below"
+          onClick={() => {
+            Router.CloseSideMenus();
+            Router.Navigate("/decky-plugin-test");
+          }}
+        >
+          Router
+        </ButtonItem>
+      </PanelSectionRow>
     </PanelSection>
   );
 };
 
+const DeckyPluginRouterTest: VFC = () => {
+  return (
+    <div style={{ marginTop: "50px", color: "white" }}>
+      Hello World!
+      <DialogButton onClick={() => Router.NavigateToStore()}>
+        Go to Store
+      </DialogButton>
+    </div>
+  );
+};
+
 export default definePlugin((serverApi: ServerAPI) => {
+  serverApi.routerHook.addRoute("/decky-plugin-test", DeckyPluginRouterTest, {
+    exact: true,
+  });
+
   return {
     title: <div className={staticClasses.Title}>Example Plugin</div>,
     content: <Content serverAPI={serverApi} />,
     icon: <FaShip />,
+    onDismount() {
+      serverApi.routerHook.removeRoute("/decky-plugin-test");
+    },
   };
 });
-- 
cgit v1.2.3

