From 26906d10d6a1d0ef5c0ec1402de6925c4e3524ce Mon Sep 17 00:00:00 2001 From: Mikayla Date: Sat, 12 Oct 2024 04:36:20 +0000 Subject: [PATCH] added go_home alias function for pocket navigation --- pocket/pocket.lua | 3 +++ pocket/ui/apps/control.lua | 6 +++--- pocket/ui/apps/guide.lua | 6 +++--- pocket/ui/apps/unit.lua | 6 +++--- pocket/ui/main.lua | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pocket/pocket.lua b/pocket/pocket.lua index 4b0de9d..6d34cae 100644 --- a/pocket/pocket.lua +++ b/pocket/pocket.lua @@ -288,6 +288,9 @@ function pocket.init_nav(smem) end end + -- go home (open the home screen app) + function nav.go_home() nav.open_app(APP_ID.ROOT) end + -- open the app that was blocked on connecting function nav.on_loader_connected() if self.loader_return then diff --git a/pocket/ui/apps/control.lua b/pocket/ui/apps/control.lua index a74866b..3e835cb 100644 --- a/pocket/ui/apps/control.lua +++ b/pocket/ui/apps/control.lua @@ -58,7 +58,7 @@ local function new_view(root) local load_pane = MultiPane{parent=main,x=1,y=1,panes={load_div,main}} - app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end } }) + app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home } }) local btn_fg_bg = cpair(colors.green, colors.black) local btn_active = cpair(colors.white, colors.black) @@ -68,7 +68,7 @@ local function new_view(root) -- set sidebar to display unit-specific fields based on a specified unit local function set_sidebar() local list = { - { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end }, + { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home }, { label = "FAC", color = core.cpair(colors.black, colors.orange), callback = function () app.switcher(db.facility.num_units + 1) end } } @@ -215,7 +215,7 @@ local function new_view(root) page_div = nil end - app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end } }) + app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home } }) app.delete_pages() -- show loading screen diff --git a/pocket/ui/apps/guide.lua b/pocket/ui/apps/guide.lua index 5e4ae31..2efb862 100644 --- a/pocket/ui/apps/guide.lua +++ b/pocket/ui/apps/guide.lua @@ -56,14 +56,14 @@ local function new_view(root) local btn_active = cpair(colors.white, colors.black) local btn_disable = cpair(colors.gray, colors.black) - app.set_sidebar({{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end }}) + app.set_sidebar({{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home }}) local page_div = nil ---@type Div|nil -- load the app (create the elements) local function load() local list = { - { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end }, + { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home }, { label = " \x14 ", color = core.cpair(colors.black, colors.cyan), callback = function () app.switcher(1) end }, { label = "__?", color = core.cpair(colors.black, colors.lightGray), callback = function () app.switcher(2) end } } @@ -263,7 +263,7 @@ local function new_view(root) page_div = nil end - app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end } }) + app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home } }) app.delete_pages() -- show loading screen diff --git a/pocket/ui/apps/unit.lua b/pocket/ui/apps/unit.lua index 2f97bf9..bc34d5f 100644 --- a/pocket/ui/apps/unit.lua +++ b/pocket/ui/apps/unit.lua @@ -63,7 +63,7 @@ local function new_view(root) local load_pane = MultiPane{parent=main,x=1,y=1,panes={load_div,main}} - app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end } }) + app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home } }) local btn_fg_bg = cpair(colors.yellow, colors.black) local btn_active = cpair(colors.white, colors.black) @@ -76,7 +76,7 @@ local function new_view(root) local unit = db.units[id] local list = { - { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end }, + { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home }, { label = "U-" .. id, color = core.cpair(colors.black, colors.yellow), callback = function () app.switcher(id) end }, { label = " \x13 ", color = core.cpair(colors.black, colors.red), callback = nav_links[id].alarm }, { label = "RPS", tall = true, color = core.cpair(colors.black, colors.cyan), callback = nav_links[id].rps }, @@ -383,7 +383,7 @@ local function new_view(root) page_div = nil end - app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end } }) + app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home } }) app.delete_pages() -- show loading screen diff --git a/pocket/ui/main.lua b/pocket/ui/main.lua index eb9c7f1..20774a7 100644 --- a/pocket/ui/main.lua +++ b/pocket/ui/main.lua @@ -78,7 +78,7 @@ local function init(main) PushButton{parent=main_pane,x=1,y=19,text="\x1b",min_width=3,fg_bg=cpair(colors.white,colors.gray),active_fg_bg=cpair(colors.gray,colors.black),callback=db.nav.nav_up} - db.nav.open_app(APP_ID.ROOT) + db.nav.go_home() -- done with initial render, lets go! root_pane.set_value(2)