import {createRoot} from 'react-dom/client'; import React, {Component} from "react"; import Startup from "./Startup"; import WiFi from "./WiFi"; import Cloud from "./Cloud"; import Game from "./Game"; import GameSetup from "./GameSetup"; import GameEnd from "./GameEnd"; import Setup from "./Setup"; const root = createRoot(document.getElementById("root")); //window.app = window.MyNamespace || {}; interface HeadingSwitcherState { counter: number; } class HeadingSwitcher extends Component<{}, HeadingSwitcherState> { private interval: NodeJS.Timeout; constructor(props: {}) { super(props); this.state = {counter: 0}; } componentDidMount() { this.interval = setInterval(() => this.tick(), 500); } componentWillUnmount() { clearInterval(this.interval); } tick() { if (this.state.counter > 5) this.setState({counter: 1}); else this.setState({counter: this.state.counter + 1}); } render() { switch (this.state.counter) { case 1: return

H1

; case 2: return

H2

; case 3: return

H3

; case 4: return

H4

; case 5: return
H5
; case 6: return
H6
; } } } enum PAGE { STARTUP, SETUP, WIFI, CLOUD, GAME_SETUP, GAME, GAME_END } interface AppState { currentPage: PAGE, showWiFi: boolean } export class App extends Component<{}, AppState> { static PAGES: Map = new Map(); constructor(props: {}) { super(props); this.state = { currentPage: PAGE.STARTUP, showWiFi: false } } toggleWiFiSettings = (state: boolean) => { this.setState((prevState) => ({ ...prevState, showWiFi: state })); } render() { return (
{this.state.showWiFi ? : null} {this.state.currentPage == PAGE.STARTUP ? { App.PAGES.set(PAGE.STARTUP, ref); }}/> : null} {this.state.currentPage == PAGE.SETUP ? { App.PAGES.set(PAGE.SETUP, ref); }}/> : null} {this.state.currentPage == PAGE.WIFI ? { App.PAGES.set(PAGE.WIFI, ref); }}/> : null} {this.state.currentPage == PAGE.CLOUD ? { App.PAGES.set(PAGE.CLOUD, ref); }}/> : null} {this.state.currentPage == PAGE.GAME_SETUP ? { App.PAGES.set(PAGE.GAME_SETUP, ref); }}/> : null} {this.state.currentPage == PAGE.GAME ? { App.PAGES.set(PAGE.GAME, ref); }}/> : null} {this.state.currentPage == PAGE.GAME_END ? { App.PAGES.set(PAGE.GAME_END, ref); }}/> : null}
); } } root.render( { window.app = ref; }}/> )