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-10-04 03:16:46 +00:00
|
|
|
local ALIGN = core.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
|
2024-06-27 23:57:43 +00:00
|
|
|
local box = Div{parent=root,x=1,y=y,height=6}
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2023-05-30 23:51:10 +00:00
|
|
|
local waiting_x = math.floor(parent.get_width() / 2) - 1
|
2023-04-12 16:40:13 +00:00
|
|
|
|
|
|
|
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)}
|
2024-06-27 23:57:43 +00:00
|
|
|
TextBox{parent=box,text="Connecting to API",alignment=ALIGN.CENTER,y=5,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)}
|
2024-06-27 23:57:43 +00:00
|
|
|
TextBox{parent=box,text="Connecting to Supervisor",alignment=ALIGN.CENTER,y=5,fg_bg=cpair(colors.white,style.root.bkg)}
|
2023-04-12 16:40:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return root
|
|
|
|
end
|
|
|
|
|
|
|
|
return init
|