refactoring: Fix generateLayouts
This commit is contained in:
parent
5117bccb9a
commit
7f26e4cb3b
5 changed files with 67 additions and 161 deletions
48
index.ts
48
index.ts
|
@ -1,52 +1,18 @@
|
|||
import { FixedUiElement } from "./UI/Base/FixedUiElement"
|
||||
import Combine from "./UI/Base/Combine"
|
||||
import { Utils } from "./Utils"
|
||||
import AllThemesGui from "./UI/AllThemesGui"
|
||||
import DetermineLayout from "./Logic/DetermineLayout"
|
||||
import LayoutConfig from "./Models/ThemeConfig/LayoutConfig"
|
||||
import ShowOverlayLayerImplementation from "./UI/ShowDataLayer/ShowOverlayLayerImplementation"
|
||||
import { DefaultGuiState } from "./UI/DefaultGuiState"
|
||||
import ThemeViewState from "./Models/ThemeViewState"
|
||||
import SvelteUIElement from "./UI/Base/SvelteUIElement"
|
||||
import ThemeViewGUI from "./UI/ThemeViewGUI.svelte"
|
||||
|
||||
ShowOverlayLayerImplementation.Implement()
|
||||
// Miscelleanous
|
||||
Utils.DisableLongPresses()
|
||||
|
||||
class Init {
|
||||
public static Init(layoutToUse: LayoutConfig) {
|
||||
if (layoutToUse === null) {
|
||||
// Something went wrong, error message is already on screen
|
||||
return
|
||||
}
|
||||
|
||||
if (layoutToUse === undefined) {
|
||||
// No layout found
|
||||
new AllThemesGui().setup()
|
||||
return
|
||||
}
|
||||
|
||||
const guiState = new DefaultGuiState()
|
||||
DefaultGuiState.state = guiState
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("decoration-desktop").remove()
|
||||
new Combine([
|
||||
"Initializing... <br/>",
|
||||
new FixedUiElement(
|
||||
"<a>If this message persist, something went wrong - click here to try again</a>"
|
||||
)
|
||||
.SetClass("link-underline small")
|
||||
.onClick(() => {
|
||||
localStorage.clear()
|
||||
window.location.reload()
|
||||
}),
|
||||
]).AttachTo("centermessage") // Add an initialization and reset button if something goes wrong
|
||||
|
||||
// @ts-ignore
|
||||
DetermineLayout.GetLayout()
|
||||
.then((value) => {
|
||||
console.log("Got ", value)
|
||||
Init.Init(value)
|
||||
.then((layout) => {
|
||||
const state = new ThemeViewState(layout)
|
||||
const main = new SvelteUIElement(ThemeViewGUI, { state })
|
||||
main.AttachTo("maindiv")
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Error while initializing: ", err, err.stack)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue