Lua 应用开发Vela 能力模块

activity

页面状态管理,检测编辑模式与显示状态

页面状态管理,检测编辑模式与显示状态。

activity.isShown(opts)

local editing = activity.isShown {
    appID = activity.APPID.WATCHFACE,
    pageID = 2
}
参数类型说明
opts.appIDnumber应用 ID
opts.pageIDnumber页面 ID

返回值:boolean

APPID

常量值
activity.APPID.WATCHFACE2
activity.APPID.LUA56

生命周期模式

local lastEdit = false
lvgl.Timer {
    period = 200,
    cb = function(t)
        local editing = activity.isShown {
            appID = activity.APPID.WATCHFACE, pageID = 2
        }
        if editing and not lastEdit then pageOnPause end
        if not editing and lastEdit then pageOnResume end
        lastEdit = editing
    end
}

function pageOnPause
    for _, a in ipairs(ui.anims or {}) do a:remove end
    ui.anims = {}
    for _, token in ipairs(ui.tokens or {}) do dataman.pause(token) end
end

function pageOnResume
    for _, token in ipairs(ui.tokens or {}) do dataman.resume(token) end
end

参考来源:官方 docs-lua / 洛汐文档库

  • 官方文档:docs-lua 能力模块 activity/overview.md(Vela 官方能力模块文档)
  • 洛汐文档库:暂无对应模块的社区文档

大纲