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/TitleView.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/TitleView.tsx')
| -rw-r--r-- | frontend/src/components/TitleView.tsx | 39 |
1 files changed, 39 insertions, 0 deletions
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 <div className={staticClasses.Title}> + <Button bottomSeparator={false} onClick={(_) => { + window.__DeckyEvLoop.dispatchEvent(new Event("pluginClose")); + this.setState({ runningPlugin: "" }); + }}><FaArrowCircleLeft /></Button> + {this.state.runningPlugin} + </div> + else + return <div className={staticClasses.Title}> + Plugins + <Button bottomSeparator={false} onClick={ (_) => this.openPluginStore() }><FaShoppingBag /></Button> + </div> + } +} + +export default TitleView;
\ No newline at end of file |
