2023-04-12 16:40:13 +00:00
|
|
|
--
|
|
|
|
-- Connection Waiting Spinner
|
|
|
|
--
|
|
|
|
|
|
|
|
local style = require("pocket.ui.style")
|
|
|
|
|
|
|
|
local core = require("graphics.core")
|
|
|
|
|
|
|
|
local Div = require("graphics.elements.div")
|
|
|
|
local TextBox = require("graphics.elements.textbox")
|
|
|
|
|
|
|
|
local WaitingAnim = require("graphics.elements.animations.waiting")
|
|
|
|
|
2023-05-07 01:27:36 +00:00
|
|
|
local TEXT_ALIGN = core.TEXT_ALIGN
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2023-05-07 01:27:36 +00:00
|
|
|
local cpair = core.cpair
|
2023-04-12 16:40:13 +00:00
|
|
|
|
|
|
|
-- create a waiting view
|
|
|
|
---@param parent graphics_element parent
|
|
|
|
---@param y integer y offset
|
|
|
|
local function init(parent, y, is_api)
|
2023-04-20 00:35:42 +00:00
|
|
|
-- root div
|
|
|
|
local root = Div{parent=parent,x=1,y=1}
|
|
|
|
|
2023-04-12 16:40:13 +00:00
|
|
|
-- bounding box div
|
2023-04-20 00:35:42 +00:00
|
|
|
local box = Div{parent=root,x=1,y=y,height=5}
|
2023-04-12 16:40:13 +00:00
|
|
|
|
|
|
|
local waiting_x = math.floor(parent.width() / 2) - 1
|
|
|
|
|
|
|
|
if is_api then
|
2023-04-20 00:35:42 +00:00
|
|
|
WaitingAnim{parent=box,x=waiting_x,y=1,fg_bg=cpair(colors.blue,style.root.bkg)}
|
|
|
|
TextBox{parent=box,text="Connecting to API",alignment=TEXT_ALIGN.CENTER,y=5,height=1,fg_bg=cpair(colors.white,style.root.bkg)}
|
2023-04-12 16:40:13 +00:00
|
|
|
else
|
2023-04-20 00:35:42 +00:00
|
|
|
WaitingAnim{parent=box,x=waiting_x,y=1,fg_bg=cpair(colors.green,style.root.bkg)}
|
|
|
|
TextBox{parent=box,text="Connecting to Supervisor",alignment=TEXT_ALIGN.CENTER,y=5,height=1,fg_bg=cpair(colors.white,style.root.bkg)}
|
2023-04-12 16:40:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return root
|
|
|
|
end
|
|
|
|
|
|
|
|
return init
|