diff options
author | wlodekm <[email protected]> | 2024-11-10 19:33:13 +0200 |
---|---|---|
committer | wlodekm <[email protected]> | 2024-11-10 19:33:13 +0200 |
commit | 6c6f9765c5982347b36a38bce366dddadc497fe3 (patch) | |
tree | 888f22cb99c6dbae08cd31e0351adecef4c0f7ba /v2/screenbuilder.ts | |
parent | 22a2150eef88430f9d9d5491a002e23e7813ac0c (diff) |
add home
Diffstat (limited to 'v2/screenbuilder.ts')
-rw-r--r-- | v2/screenbuilder.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/v2/screenbuilder.ts b/v2/screenbuilder.ts index dcf1af7..e8ce587 100644 --- a/v2/screenbuilder.ts +++ b/v2/screenbuilder.ts @@ -5,26 +5,39 @@ export enum ElemType { TextElem, InputElem, ButtonElem, + HR, + BR } const types = { 0: elements.Text, 1: elements.Input, - 2: elements.Button + 2: elements.Button, + 3: elements.HR, + 4: elements.BR } type BuilderElem = { type: ElemType, id: string, - data: any[] + data?: any[], } -export function build(data: {elements: BuilderElem[],focus?:string,name:string}) { +type Data = { + elements: BuilderElem[], + focus?: string, + name: string + onload?: (screen: Screen) => any +} + +export function build(data: Data) { const screen = new Screen(data.name); for (const element of data.elements) { + if (!element.data) element.data = [] //@ts-ignore screen.addElement(element.id, new types[element.type](...element.data)) } if (data.focus) screen.focus(data.focus); screen.ready() + if (data.onload) data.onload(screen) } \ No newline at end of file |