mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-28 15:58:12 +00:00
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:
@@ -57,5 +57,10 @@ public:
|
||||
virtual int render(DisplayDriver& display) =0; // return value is number of millis until next render
|
||||
virtual bool handleInput(char c) { return false; }
|
||||
virtual void poll() { }
|
||||
// Called by UITask::setCurrScreen() each time this screen becomes current —
|
||||
// the place to reset per-visit state (selection, dirty flag, sub-views).
|
||||
// Default no-op for screens that keep state across visits. Because it's
|
||||
// invoked centrally, a new screen can't "forget" to be reset on show.
|
||||
virtual void onShow() { }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user