Timer Reader with normal time format (#3244)

pull/3256/head
Robert 7 years ago committed by Frans de Jonge
parent c770d71f14
commit 88aba421cb

@ -5,7 +5,7 @@ local FrameContainer = require("ui/widget/container/framecontainer")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Font = require("ui/font") local Font = require("ui/font")
local InputContainer = require("ui/widget/container/inputcontainer") local InputContainer = require("ui/widget/container/inputcontainer")
local TextWidget = require("ui/widget/textboxwidget") local InputDialog = require("ui/widget/inputdialog")
local RenderText = require("ui/rendertext") local RenderText = require("ui/rendertext")
local Size = require("ui/size") local Size = require("ui/size")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
@ -108,12 +108,50 @@ function NumberPickerWidget:paintWidget()
value = string.format(self.precision, value) value = string.format(self.precision, value)
end end
local text_value = TextWidget:new{ local input
local callback_input = nil
if self.value_table == nil then
callback_input = function()
input = InputDialog:new{
title = _("Enter number"),
input_type = "number",
buttons = {
{
{
text = _("Cancel"),
callback = function()
UIManager:close(input)
end,
},
{
text = _("OK"),
is_enter_default = true,
callback = function()
input:closeInputDialog()
local input_value = tonumber(input:getInputText())
if input_value and input_value >= self.value_min and input_value <= self.value_max then
self.value = input_value
self:update()
end
UIManager:close(input)
end,
},
},
},
}
input:onShowKeyboard()
UIManager:show(input)
end
end
local text_value = Button:new{
text = value, text = value,
alignment = "center", bordersize = 0,
face = self.spinner_face, padding = 0,
bold = true, text_font_face = self.spinner_face_font,
text_font_size = self.spinner_face_size,
width = self.width, width = self.width,
callback = callback_input,
} }
return VerticalGroup:new{ return VerticalGroup:new{
align = "center", align = "center",

@ -26,6 +26,7 @@ local TimeWidget = InputContainer:new{
width = nil, width = nil,
height = nil, height = nil,
hour = 0, hour = 0,
hour_max = 23,
min = 0, min = 0,
ok_text = _("OK"), ok_text = _("OK"),
cancel_text = _("Cancel"), cancel_text = _("Cancel"),
@ -64,7 +65,7 @@ function TimeWidget:update()
width = self.screen_width * 0.2, width = self.screen_width * 0.2,
value = self.hour, value = self.hour,
value_min = 0, value_min = 0,
value_max = 23, value_max = self.hour_max,
value_step = 1, value_step = 1,
value_hold_step = 4, value_hold_step = 4,
} }

Loading…
Cancel
Save