Make it possible to dismiss new notifications

This commit is contained in:
Tomas Groth 2022-09-14 22:10:00 +02:00 committed by JF
parent b071422f91
commit bef65bcd55
2 changed files with 25 additions and 2 deletions

View file

@ -79,9 +79,12 @@ void Notifications::Refresh() {
timeoutLinePoints[1].x = pos; timeoutLinePoints[1].x = pos;
lv_line_set_points(timeoutLine, timeoutLinePoints, 2); lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
} }
}
if (dismissingNotification) { } else if (mode == Modes::Preview && dismissingNotification) {
running = false;
currentItem = std::make_unique<NotificationItem>(alertNotificationService, motorController);
} else if (dismissingNotification) {
dismissingNotification = false; dismissingNotification = false;
auto notification = notificationManager.Get(currentId); auto notification = notificationManager.Get(currentId);
if (!notification.valid) { if (!notification.valid) {
@ -126,12 +129,31 @@ void Notifications::OnPreviewInteraction() {
} }
} }
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) { bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if (mode != Modes::Normal) { if (mode != Modes::Normal) {
if (!interacted && event == TouchEvents::Tap) { if (!interacted && event == TouchEvents::Tap) {
interacted = true; interacted = true;
OnPreviewInteraction(); OnPreviewInteraction();
return true; return true;
} else if (event == Pinetime::Applications::TouchEvents::SwipeRight) {
OnPreviewDismiss();
return true;
} }
return false; return false;
} }

View file

@ -30,6 +30,7 @@ namespace Pinetime {
void Refresh() override; void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
void OnPreviewInteraction(); void OnPreviewInteraction();
void OnPreviewDismiss();
class NotificationItem { class NotificationItem {
public: public: