From 81502860f431066312e2c3cb4e0ea964a67e86b8 Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Sun, 18 Aug 2024 20:16:30 +0800 Subject: [PATCH] examples: add declarative example Signed-off-by: Neo Xu --- examples/declarative.lua | 37 +++++++++++++++++++++++++++++++++++++ examples/examples.lua | 1 + 2 files changed, 38 insertions(+) create mode 100644 examples/declarative.lua 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")