动作表
用途
ui.themes.widgets.sheet 替代 ButtonDialog:标题加一列通栏按钮,超高自动分页,点按即关窗再执行。只有两三个动作时用它,不要拿列表装按钮。需要就地改设置、还不想关窗,用设置弹窗。
主要参数
items 可以是:
| 项 | 作用 |
|---|---|
{ text, callback, variant, enabled, icon } | 通栏按钮。危险或主操作可 variant = "primary" |
{ buttons = { { text, callback, ... }, ... } } | 同一行里等宽的几个小按钮 |
{ separator = true } | 留一段空隙分组 |
{ widget = function(width) ... end } | 放任意正文(注意多行文字要铺 t.dialog.bg) |
anchor 设成某个按钮的 dimen,会贴着它弹出。继承 Modal。
和三种风格的差异
按钮走主题变体,面板走 dialog。柔和是胶囊按钮,高对比是粗边直角。
示例
local Text = require("ui.themes.widgets.text")local t = require("ui.themes").current()require("ui.themes.widgets.sheet"):new{ title = _("这本书"), items = { { text = _("打开"), callback = open_book }, { buttons = { { text = _("复制"), callback = copy_title }, { icon = "share", callback = share_book }, } }, { separator = true }, { widget = function(width) return Text.box("caption", _("删除后书架上看不到,进度还在。"), width, { bg = t.dialog.bg, }) end }, { text = _("删除"), variant = "primary", callback = delete_book }, },}:show()require("ui.themes.widgets.sheet"):new{ anchor = button.dimen, items = { { text = _("重命名"), callback = rename }, { text = _("移动"), callback = move_to }, },}:show()本文已加密,请输入访问密码