Skip to content

Commit 7a63b92

Browse files
committed
examples: add declarative example
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
1 parent dc6d844 commit 7a63b92

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

examples/declarative.lua

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
local lvgl = require("lvgl")
2+
3+
Object {
4+
flex = {
5+
flex_direction = "row",
6+
flex_wrap = "wrap",
7+
justify_content = "center",
8+
align_items = "center",
9+
align_content = "center",
10+
},
11+
w = 400,
12+
h = 100,
13+
align = lvgl.ALIGN.CENTER,
14+
15+
-- Button with label, inside a container
16+
Object {
17+
w = 150,
18+
h = lvgl.PCT(80),
19+
bg_color = "#aa0",
20+
21+
Button {
22+
Label {
23+
text = string.format("BUTTON %d", 1),
24+
align = lvgl.ALIGN.CENTER
25+
}
26+
}:center()
27+
}:clear_flag(lvgl.FLAG.SCROLLABLE),
28+
29+
-- Label inside a container
30+
Object {
31+
w = 150,
32+
h = lvgl.PCT(80),
33+
Label {
34+
text = string.format("label %d", 2)
35+
}:center()
36+
}:clear_flag(lvgl.FLAG.SCROLLABLE)
37+
}

examples/examples.lua

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ end
4141

4242
createBtn(container, "keyboard")
4343
createBtn(container, "animation")
44+
createBtn(container, "declarative")
4445
createBtn(container, "pointer")
4546
createBtn(container, "analogTime")
4647
createBtn(container, "userdata")

0 commit comments

Comments
 (0)