summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.tsx51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/index.tsx b/src/index.tsx
new file mode 100644
index 0000000..56301a7
--- /dev/null
+++ b/src/index.tsx
@@ -0,0 +1,51 @@
+import {
+ Button,
+ definePlugin,
+ PanelSection,
+ PanelSectionRow,
+ ServerAPI,
+ TabTitle,
+} from "decky-frontend-lib";
+import { useState, VFC } from "react";
+import { FaShip } from "react-icons/fa";
+
+interface AddMethodArgs {
+ left: number;
+ right: number;
+}
+
+const Content: VFC<{ serverAPI: ServerAPI }> = ({ serverAPI }) => {
+ const [result, setResult] = useState<number | undefined>();
+
+ const onClick = async () => {
+ const result = await serverAPI.callPluginMethod<AddMethodArgs, number>(
+ "add",
+ {
+ left: 2,
+ right: 2,
+ }
+ );
+ if (result.success) {
+ setResult(result.result);
+ }
+ };
+
+ return (
+ <PanelSection>
+ <PanelSectionRow>
+ <Button layout="below" bottomSeparator={false} onClick={onClick}>
+ What is 2+2?
+ </Button>
+ <div>Server says: {result}</div>
+ </PanelSectionRow>
+ </PanelSection>
+ );
+};
+
+export default definePlugin((serverApi) => {
+ return {
+ title: <TabTitle>Example Plugin</TabTitle>,
+ content: <Content serverAPI={serverApi} />,
+ icon: <FaShip />,
+ };
+});