mirror of
https://github.com/SteamDeckHomebrew/decky-plugin-template.git
synced 2025-11-03 15:52:25 -06:00
Initial commit
This commit is contained in:
commit
52f6ca1c58
8 changed files with 2679 additions and 0 deletions
51
src/index.tsx
Normal file
51
src/index.tsx
Normal file
|
|
@ -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 />,
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue