diff --git a/examples/declarative.lua b/examples/declarative.lua new file mode 100644 index 0000000..1dc2159 --- /dev/null +++ b/examples/declarative.lua @@ -0,0 +1,37 @@ +local lvgl = require("lvgl") + +Object { + flex = { + flex_direction = "row", + flex_wrap = "wrap", + justify_content = "center", + align_items = "center", + align_content = "center", + }, + w = 400, + h = 100, + align = lvgl.ALIGN.CENTER, + + -- Button with label, inside a container + Object { + w = 150, + h = lvgl.PCT(80), + bg_color = "#aa0", + + Button { + Label { + text = string.format("BUTTON %d", 1), + align = lvgl.ALIGN.CENTER + } + }:center() + }:clear_flag(lvgl.FLAG.SCROLLABLE), + + -- Label inside a container + Object({ + w = 150, + h = lvgl.PCT(80), + Label { + text = string.format("label %d", 2) + }:center() + }):clear_flag(lvgl.FLAG.SCROLLABLE) +} diff --git a/examples/examples.lua b/examples/examples.lua index e64c15c..dddd057 100644 --- a/examples/examples.lua +++ b/examples/examples.lua @@ -41,6 +41,7 @@ end createBtn(container, "keyboard") createBtn(container, "animation") +createBtn(container, "declarative") createBtn(container, "pointer") createBtn(container, "analogTime") createBtn(container, "userdata")