diff options
| author | marios <marios8543@gmail.com> | 2022-05-26 04:00:18 +0300 |
|---|---|---|
| committer | marios <marios8543@gmail.com> | 2022-05-26 04:00:18 +0300 |
| commit | 4b923c1dc70eaa4a3ca58d9e9f3218785b2fe919 (patch) | |
| tree | 3394a7e752b61bdfa16b1a7f50842c4e1dbc0972 /frontend/src/components/PluginView.tsx | |
| parent | 74438a31458af8bddd08d90eacc6d63677bab844 (diff) | |
| download | decky-loader-4b923c1dc70eaa4a3ca58d9e9f3218785b2fe919.tar.gz decky-loader-4b923c1dc70eaa4a3ca58d9e9f3218785b2fe919.zip | |
display overhaul, compatibility with legacy plugins, fixes
Diffstat (limited to 'frontend/src/components/PluginView.tsx')
| -rw-r--r-- | frontend/src/components/PluginView.tsx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/frontend/src/components/PluginView.tsx b/frontend/src/components/PluginView.tsx new file mode 100644 index 00000000..27cb386a --- /dev/null +++ b/frontend/src/components/PluginView.tsx @@ -0,0 +1,40 @@ +import { Button } from "decky-frontend-lib"; +import React from "react" + +class PluginView extends React.Component<{}, { runningPlugin: string, plugins: Array<any> }> { + constructor() { + super({}); + this.state = { + plugins: [], + runningPlugin: "" + } + } + + componentDidMount() { + window.__DeckyEvLoop.addEventListener("pluginClose", (_) => { this.setState({ runningPlugin: "", plugins: this.state.plugins }) }); + window.__DeckyEvLoop.addEventListener("setPlugins", (ev) => { console.log(ev); this.setState({ plugins: ev.data, runningPlugin: this.state.runningPlugin }) }); + } + + private openPlugin(name: string) { + const ev = new Event("pluginOpen"); + ev.data = name; + window.__DeckyEvLoop.dispatchEvent(ev); + this.setState({ runningPlugin: name, plugins: this.state.plugins }) + } + + render() { + if (this.state.runningPlugin) { + return this.state.plugins.find(x => x.name == this.state.runningPlugin).content; + } + else { + let buttons = []; + for (const plugin of this.state.plugins) { + buttons.push(<Button layout="below" onClick={(_) => this.openPlugin(plugin.name)}>{plugin.icon}{plugin.name}</Button>) + } + if (buttons.length == 0) return <div className='staticClasses.Text'>No plugins...</div>; + return buttons; + } + } +} + +export default PluginView;
\ No newline at end of file |
