mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Allow closing full screen dialogs with swipe down (#4237)
Mostly all that have a close button at top right, that may be hard to reach or hit for some people: TOC, Bookmarks, History, KeyValuePage (Book information, Statistics...), Book status... Added full refresh on diagonal swipe where it was missing. CoverMenu: removed onSwipe override, as it had become the same as Menu a few months ago.
This commit is contained in:
@@ -5,6 +5,7 @@ local Device = require("device")
|
||||
local Font = require("ui/font")
|
||||
local FrameContainer = require("ui/widget/container/framecontainer")
|
||||
local Geom = require("ui/geometry")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
||||
local HorizontalSpan = require("ui/widget/horizontalspan")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
@@ -61,6 +62,14 @@ function ReaderProgress:init()
|
||||
seqtext = "any key", doc = "close dialog" }
|
||||
}
|
||||
end
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events.Swipe = {
|
||||
GestureRange:new{
|
||||
ges = "swipe",
|
||||
range = function() return self.dimen end,
|
||||
}
|
||||
}
|
||||
end
|
||||
self[1] = FrameContainer:new{
|
||||
width = self.width,
|
||||
height = self.height,
|
||||
@@ -488,6 +497,22 @@ function ReaderProgress:onAnyKeyPressed()
|
||||
return self:onClose()
|
||||
end
|
||||
|
||||
function ReaderProgress:onSwipe(arg, ges_ev)
|
||||
if ges_ev.direction == "south" then
|
||||
-- Allow easier closing with swipe up/down
|
||||
self:onClose()
|
||||
elseif ges_ev.direction == "east" or ges_ev.direction == "west" or ges_ev.direction == "north" then
|
||||
-- no use for now
|
||||
do end -- luacheck: ignore 541
|
||||
else -- diagonal swipe
|
||||
-- trigger full refresh
|
||||
UIManager:setDirty(nil, "full")
|
||||
-- a long diagonal swipe may also be used for taking a screenshot,
|
||||
-- so let it propagate
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderProgress:onClose()
|
||||
UIManager:close(self)
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user