Skip to content

windowDemo.llua

xu.jingyu edited this page Aug 11, 2020 · 2 revisions

copy下面代码,运行试试

--demo1:StatusBar 、生命周期
local windowWidth = window.width()
local windowHeight = window.height()
---
--- UI
ui {
    --- layout views
    Label(windowWidth .. "  ," .. windowHeight)
    .widthPercent(100)
    .height(100)
    .bgColor(Color(0xdddddd))
}
.statusBarMode(StatusMode.NON_FULLSCREEN)
.statusBarColor(Color(200, 100, 0, 1))
.onAppear(function()
    print("window_onAppear")
end)
.onDisappear(function()
    print("window_onDisappear")
end)
.onDestroy(function()
    print("window_onDestroy")
end)
.onSizeChanged(function(w, h)
    print("window_onSizeChanged")
end)
---
--- preview
local function preview()
end


--demo2:keyboard相关
ui {

    VStack()
    .widthPercent(100)
    .subs(
        Label(windowWidth .. "  ," .. windowHeight)
        .widthPercent(100)
        .height(100)
        .bgColor(Color(0xdddddd))
        ,
        EditTextView()
        .placeholder("请输入")
        .widthPercent(100)
        .padding(20, 20, 20, 20)
        .bgColor(Color(0xaa00aa))
    ).positionType(PositionType.ABSOLUTE)
    .positionBottom(0)
}
.safeArea(SafeArea.TOP)
.keyboardDismiss(true) 
.keyboardOffset(20)
.watchKeyboard(function(isShow, height)
    print(isShow, height)
end)

---
--- preview
local function preview()
end
Clone this wiki locally