mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
e28f45452d
Layout breakpoints use the screen width at 1x, so Interface size scales text, icons and spacing without dropping Home columns or detail panes. Every page, sheet and widget picks a layout that fits instead of cutting text or leaving gaps; search becomes balanced list-row sections, Edit Home keeps hidden widgets, stock KOReader messages become BookOrbit toasts, and the plugin is 2.1.0.
45 lines
2.2 KiB
Lua
45 lines
2.2 KiB
Lua
package.path = "koreader-plugin/bookorbit.koplugin/?.lua;" .. package.path
|
|
|
|
local widget = {}
|
|
function widget:new(options) return options or {} end
|
|
function widget:extend(options) return setmetatable(options or {}, { __index = self }) end
|
|
for _, name in ipairs({
|
|
"ui/geometry", "ui/widget/container/centercontainer", "ui/widget/container/framecontainer",
|
|
"ui/widget/container/leftcontainer", "ui/widget/container/rightcontainer",
|
|
"ui/widget/container/widgetcontainer", "ui/widget/horizontalgroup", "ui/widget/horizontalspan",
|
|
"ui/widget/overlapgroup", "ui/widget/textboxwidget", "ui/widget/textwidget",
|
|
"ui/widget/verticalgroup", "ui/widget/verticalspan", "ui/widget/widget",
|
|
}) do
|
|
package.loaded[name] = widget
|
|
end
|
|
package.loaded["ui/bidi"] = {}
|
|
package.loaded["ui/renderimage"] = {}
|
|
package.loaded["device"] = { screen = {} }
|
|
package.loaded["bookorbit_board_icons"] = {}
|
|
package.loaded["bookorbit_board_metrics"] = { INK = {}, px = function(n) return n end }
|
|
|
|
local BoardUI = require("bookorbit_board_ui")
|
|
local function child(height)
|
|
return { getSize = function() return { w = 50, h = height } end }
|
|
end
|
|
local function stack(height, strict)
|
|
return BoardUI.vstack({ w = 100, h = 100, pad = 16, strict_padding = strict }, {
|
|
child(height), BoardUI.flex(10),
|
|
})
|
|
end
|
|
|
|
assert(BoardUI.fits(function() return stack(58, true) end), "content may exactly fill the padded interior")
|
|
assert(not BoardUI.fits(function() return stack(59, true) end), "content must not consume reserved bottom padding")
|
|
assert(BoardUI.fits(function() return stack(60, false) end), "other widgets may overhang the bottom padding by 2dp")
|
|
assert(not BoardUI.fits(function() return stack(61, false) end), "no widget runs further into its bottom padding")
|
|
local selected
|
|
BoardUI.pick({
|
|
function() selected = "crowded" return stack(70, true) end,
|
|
function() selected = "compact" return stack(50, true) end,
|
|
})
|
|
assert(selected == "compact", "a crowded card must select a layout that preserves padding")
|
|
local fitted = stack(50, true)
|
|
local group = fitted[1][2]
|
|
assert(group[#group].width == 16, "the bottom inset is preserved in the actual layout")
|
|
print("bookorbit_board_padding_test: passed")
|