import * as React from "react" import { ipcRenderer, remote } from "electron" import { Icon } from "@fluentui/react/lib/Icon" import { AppState } from "../scripts/models/app" type NavProps = { state: AppState, fetch: () => void, menu: () => void, logs: () => void, settings: () => void } type NavState = { maximized: boolean, window: Electron.BrowserWindow } class Nav extends React.Component { constructor(props) { super(props) let window = remote.getCurrentWindow() window.on("maximize", () => { this.setState({ maximized: true }) }) window.on("unmaximize", () => { this.setState({ maximized: false }) }) this.state = { maximized: remote.getCurrentWindow().isMaximized(), window: window } } minimize = () => { this.state.window.minimize() } maximize = () => { if (this.state.maximized) { this.state.window.unmaximize() } else { this.state.window.maximize() } this.setState({ maximized: !this.state.maximized }) } close = () => { this.state.window.close() } canFetch = () => this.props.state.sourceInit && this.props.state.feedInit && !this.props.state.fetchingItems fetching = () => !this.canFetch() ? " fetching" : "" menuOn = () => this.props.state.menu ? " menu-on" : "" hideButtons = () => this.props.state.settings.display ? "hide-btns" : "" fetch = () => { if (this.canFetch()) this.props.fetch() } render() { return ( ) } } export default Nav