From 4b923c1dc70eaa4a3ca58d9e9f3218785b2fe919 Mon Sep 17 00:00:00 2001 From: marios Date: Thu, 26 May 2022 04:00:18 +0300 Subject: display overhaul, compatibility with legacy plugins, fixes --- frontend/src/components/LegacyPlugin.tsx | 13 +++++++++++ frontend/src/components/PluginView.tsx | 40 ++++++++++++++++++++++++++++++++ frontend/src/components/TitleView.tsx | 39 +++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 frontend/src/components/LegacyPlugin.tsx create mode 100644 frontend/src/components/PluginView.tsx create mode 100644 frontend/src/components/TitleView.tsx (limited to 'frontend/src/components') diff --git a/frontend/src/components/LegacyPlugin.tsx b/frontend/src/components/LegacyPlugin.tsx new file mode 100644 index 00000000..86abf2c8 --- /dev/null +++ b/frontend/src/components/LegacyPlugin.tsx @@ -0,0 +1,13 @@ +import React from "react" + +class LegacyPlugin extends React.Component { + constructor(props: object) { + super(props); + } + + render() { + return + } +} + +export default LegacyPlugin; \ No newline at end of file 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 }> { + 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() + } + if (buttons.length == 0) return
No plugins...
; + return buttons; + } + } +} + +export default PluginView; \ No newline at end of file diff --git a/frontend/src/components/TitleView.tsx b/frontend/src/components/TitleView.tsx new file mode 100644 index 00000000..e0a8552f --- /dev/null +++ b/frontend/src/components/TitleView.tsx @@ -0,0 +1,39 @@ +import { Button, staticClasses } from "decky-frontend-lib"; +import React from "react" +import { FaArrowCircleLeft, FaShoppingBag } from "react-icons/fa" + +class TitleView extends React.Component<{}, { runningPlugin: string }> { + constructor() { + super({}); + this.state = { + runningPlugin: "" + } + } + + componentDidMount() { + window.__DeckyEvLoop.addEventListener("pluginOpen", (ev) => this.setState({ runningPlugin: ev.data })); + window.__DeckyEvLoop.addEventListener("pluginClose", (_) => this.setState({ runningPlugin: "" })); + } + + private openPluginStore() { + fetch("http://127.0.0.1:1337/methods/open_plugin_store", {method: "POST"}) + } + + render() { + if (this.state.runningPlugin) + return
+ + {this.state.runningPlugin} +
+ else + return
+ Plugins + +
+ } +} + +export default TitleView; \ No newline at end of file -- cgit v1.2.3