diff options
Diffstat (limited to 'frontend/src/components/TitleView.tsx')
| -rw-r--r-- | frontend/src/components/TitleView.tsx | 49 |
1 files changed, 15 insertions, 34 deletions
diff --git a/frontend/src/components/TitleView.tsx b/frontend/src/components/TitleView.tsx index e0a8552f..4b4a6825 100644 --- a/frontend/src/components/TitleView.tsx +++ b/frontend/src/components/TitleView.tsx @@ -1,39 +1,20 @@ -import { Button, staticClasses } from "decky-frontend-lib"; -import React from "react" -import { FaArrowCircleLeft, FaShoppingBag } from "react-icons/fa" +import { staticClasses } from 'decky-frontend-lib'; +import { VFC } from 'react'; -class TitleView extends React.Component<{}, { runningPlugin: string }> { - constructor() { - super({}); - this.state = { - runningPlugin: "" - } - } +import { useDeckyState } from './DeckyState'; - componentDidMount() { - window.__DeckyEvLoop.addEventListener("pluginOpen", (ev) => this.setState({ runningPlugin: ev.data })); - window.__DeckyEvLoop.addEventListener("pluginClose", (_) => this.setState({ runningPlugin: "" })); - } +const TitleView: VFC = () => { + const { activePlugin } = useDeckyState(); - private openPluginStore() { - fetch("http://127.0.0.1:1337/methods/open_plugin_store", {method: "POST"}) - } + if (activePlugin === null) { + return <div className={staticClasses.Title}>Decky</div>; + } - 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> - } -} + return ( + <div className={staticClasses.Title} style={{ paddingLeft: '60px' }}> + {activePlugin.name} + </div> + ); +}; -export default TitleView;
\ No newline at end of file +export default TitleView; |
