Author: Tomas Groth <second@tgc.dk>
Make it possible to dismiss new notifications
src/displayapp/screens/Notifications.cpp | 26 ++++++++++++++++++++++++-- src/displayapp/screens/Notifications.h | 1 +
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 5100ef9b47947240cc0bf3fefa8275e856bea34b..9d126a16092cdca598fdc6903d777e02f4d1941d 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -79,9 +79,12 @@ } else { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - } + + } else if (mode == Modes::Preview && dismissingNotification) { + running = false; + currentItem = std::make_unique<NotificationItem>(alertNotificationService, motorController); - if (dismissingNotification) { + } else if (dismissingNotification) { dismissingNotification = false; auto notification = notificationManager.Get(currentId); if (!notification.valid) { @@ -126,11 +129,30 @@ timeoutLine = nullptr; } } +void Notifications::OnPreviewDismiss() { + notificationManager.Dismiss(currentId); + if (timeoutLine != nullptr) { + lv_obj_del(timeoutLine); + timeoutLine = nullptr; + } + currentItem.reset(nullptr); + dismissingNotification = true; + afterDismissNextMessageFromAbove = true; // show next message coming from below + app->SetFullRefresh(DisplayApp::FullRefreshDirections::RightAnim); + // create black transition screen to let the notification dismiss to blackness + lv_obj_t* blackBox = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(blackBox, LV_HOR_RES, LV_VER_RES); + lv_obj_set_style_local_bg_color(blackBox, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); +} + bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { if (mode != Modes::Normal) { if (!interacted && event == TouchEvents::Tap) { interacted = true; OnPreviewInteraction(); + return true; + } else if (event == Pinetime::Applications::TouchEvents::SwipeRight) { + OnPreviewDismiss(); return true; } return false; diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 9d843a9b1377c72aa23e6bb37b98cab5c6bd7949..586445531679bf078bb28bdf355a708c66f22a53 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -30,6 +30,7 @@ void Refresh() override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; void OnPreviewInteraction(); + void OnPreviewDismiss(); class NotificationItem { public: