diff options
author | wlodekm <[email protected]> | 2024-11-09 12:38:31 +0200 |
---|---|---|
committer | wlodekm <[email protected]> | 2024-11-09 12:38:31 +0200 |
commit | 9d64e0510ce33a80c3c74e2dbbb3d9a69364e247 (patch) | |
tree | ee785581b0220a848a8d9ea1512472e16d208a15 /v2/screenbuilder.ts |
initial
Diffstat (limited to 'v2/screenbuilder.ts')
-rw-r--r-- | v2/screenbuilder.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/v2/screenbuilder.ts b/v2/screenbuilder.ts new file mode 100644 index 0000000..dcf1af7 --- /dev/null +++ b/v2/screenbuilder.ts @@ -0,0 +1,30 @@ +import { Screen } from "./screen.ts"; +import * as elements from "./elements.ts"; + +export enum ElemType { + TextElem, + InputElem, + ButtonElem, +} + +const types = { + 0: elements.Text, + 1: elements.Input, + 2: elements.Button +} + +type BuilderElem = { + type: ElemType, + id: string, + data: any[] +} + +export function build(data: {elements: BuilderElem[],focus?:string,name:string}) { + const screen = new Screen(data.name); + for (const element of data.elements) { + //@ts-ignore + screen.addElement(element.id, new types[element.type](...element.data)) + } + if (data.focus) screen.focus(data.focus); + screen.ready() +} \ No newline at end of file |