diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 9d66e437..507b60d6 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -996,11 +996,12 @@ void BMPView::focus() { button_done.focus(); } -BMPView::BMPView(NavigationView& nav) { +BMPView::BMPView(NavigationView& nav) + : nav_(nav) { add_children({&button_done}); - button_done.on_select = [this, &nav](Button&) { - nav.pop(); + button_done.on_select = [this](Button&) { + handle_pop(); }; } @@ -1009,6 +1010,36 @@ void BMPView::paint(Painter&) { portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, true); } +bool BMPView::on_touch(const TouchEvent event) { + /* the event thing were resolved by HTotoo, talked here https://discord.com/channels/719669764804444213/956561375155589192/1287756910950486027 + * the touch screen policy can be better, talked here https://discord.com/channels/719669764804444213/956561375155589192/1198926225897443328 + */ + + if (!nav_.is_valid()) { + return false; + } + + switch (event.type) { + case TouchEvent::Type::Start: + return true; + + case TouchEvent::Type::End: + handle_pop(); + return true; + + default: + break; + } + + return false; +} + +void BMPView::handle_pop() { + if (nav_.is_valid()) { + nav_.pop(); + } +} + /* NotImplementedView ****************************************************/ /*NotImplementedView::NotImplementedView(NavigationView& nav) { diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index 2311b17e..8f9d4791 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -343,7 +343,11 @@ class BMPView : public View { void paint(Painter&) override; void focus() override; + bool on_touch(const TouchEvent event) override; + void handle_pop(); + private: + NavigationView& nav_; Button button_done{ {240, 0, 1, 1}, ""};