Skip to content

Commit

Permalink
examples: add declarative example
Browse files Browse the repository at this point in the history
Signed-off-by: Neo Xu <[email protected]>
  • Loading branch information
XuNeo committed Aug 18, 2024
1 parent dc6d844 commit 8150286
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/declarative.lua
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions examples/examples.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ end

createBtn(container, "keyboard")
createBtn(container, "animation")
createBtn(container, "declarative")
createBtn(container, "pointer")
createBtn(container, "analogTime")
createBtn(container, "userdata")
Expand Down

0 comments on commit 8150286

Please sign in to comment.