add warn when enable stealth mode & add nav valid check (#1823)

* add warn when enable stealth

* change FLASH ERROR to FLASH ERR cuz previous one were overlapped with date

* check if nav is valid
This commit is contained in:
ʎʞsʌoʞᴉɐɥɔꓕ ɹʇoʎꓒ 2024-01-30 13:58:40 +08:00 committed by GitHub
parent a4f6bbda5e
commit 8068517808
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -315,8 +315,15 @@ SystemStatusView::SystemStatusView(
refresh(); refresh();
}; };
toggle_stealth.on_change = [this](bool v) { toggle_stealth.on_change = [this, &nav](bool v) {
pmem::set_stealth_mode(v); pmem::set_stealth_mode(v);
if (nav.is_valid() && v) {
nav.display_modal(
"Stealth",
"You just enabled stealth mode.\n"
"When you transmit,\n"
"screen will turn off;\n");
}
refresh(); refresh();
}; };
@ -553,7 +560,7 @@ InformationView::InformationView(
#endif #endif
if (firmware_checksum_error()) { if (firmware_checksum_error()) {
version.set("FLASH ERROR"); version.set("FLASH ERR");
version.set_style(&Styles::red); version.set_style(&Styles::red);
} }
@ -585,6 +592,10 @@ bool NavigationView::is_top() const {
return view_stack.size() == 1; return view_stack.size() == 1;
} }
bool NavigationView::is_valid() const {
return view_stack.size() != 0; // work around to check if nav is valid, not elegant i know. so TODO
}
View* NavigationView::push_view(std::unique_ptr<View> new_view) { View* NavigationView::push_view(std::unique_ptr<View> new_view) {
free_view(); free_view();

View File

@ -94,6 +94,7 @@ class NavigationView : public View {
NavigationView& operator=(NavigationView&&) = delete; NavigationView& operator=(NavigationView&&) = delete;
bool is_top() const; bool is_top() const;
bool is_valid() const;
template <class T, class... Args> template <class T, class... Args>
T* push(Args&&... args) { T* push(Args&&... args) {