refactor(companion): hoist screen entry into virtual UIScreen::onShow()

Replace the ad-hoc enter()/markClean() entry methods (which lived outside
the UIScreen interface and were invoked via casts from each gotoX) with a
virtual onShow() lifecycle hook called centrally by setCurrScreen().

This removes the "forgot to call enter() in a new navigator" footgun and
the unchecked cast smell: 12 navigators collapse to one-line
setCurrScreen(x) calls, and override enforces signature match. Two entries
that carry a parameter/variant keep an explicit typed call after
setCurrScreen(): RingtoneEditor::selectSlot(slot) and TrailScreen::showMapView().

Behaviour-preserving: only screens that previously had enter() get an
onShow() override; Splash/Home/QuickMsg/Diag keep no reset as before.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-06-29 18:37:04 +02:00
co-authored by Claude Opus 4.8
parent bcca97a848
commit eedd47d1e1
15 changed files with 55 additions and 85 deletions
@@ -96,7 +96,7 @@ public:
TrailScreen(UITask* task, TrailStore* store)
: _task(task), _store(store), _wp(task, store) {}
void enter() {
void onShow() override {
_view = V_SUMMARY;
_summary_scroll = 0;
_list_scroll = 0;
@@ -107,9 +107,10 @@ public:
_wp.reset();
}
// Enter straight into the Map view (used by the Home "Map" page). Remembers
// that we came from Home so KEY_CANCEL returns there, not to Tools.
void enterMap() { enter(); _view = V_MAP; _return_home = true; }
// Switch straight into the Map view (used by the Home "Map" page). Layered on
// top of onShow()'s reset by gotoMapScreen(); remembers we came from Home so
// KEY_CANCEL returns there, not to Tools.
void showMapView() { _view = V_MAP; _return_home = true; }
int render(DisplayDriver& display) override {
display.setTextSize(1);