summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-10-22 15:39:20 +0200
committerJF <jf@codingfield.com>2020-10-22 15:39:20 +0200
commit5983e33b8d7702800dc91a3229b9a7cee75eb006 (patch)
tree3a9ef5bfc4c586089022335b02b5c420fbcc79c9 /src
parent07b6812f61cf5b7726fbf6015c2c60caa12c7f20 (diff)
Notifications : Replace the label "notificationNr/notificationNb" by a grey border on the bottom that is displayed when there are other notifications to available.
Diffstat (limited to 'src')
-rw-r--r--src/displayapp/screens/Notifications.cpp28
-rw-r--r--src/displayapp/screens/Notifications.h1
2 files changed, 17 insertions, 12 deletions
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 38a28e12..85848b2f 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -11,10 +11,10 @@ Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::Notificatio
auto notification = notificationManager.GetLastNotification();
if(notification.valid) {
currentId = notification.id;
- currentItem.reset(new NotificationItem("Notification", notification.message.data(), notification.index, notificationManager.NbNotifications(), mode));
+ currentItem.reset(new NotificationItem("\nNotification", notification.message.data(), notification.index, notificationManager.NbNotifications(), mode));
validDisplay = true;
} else {
- currentItem.reset(new NotificationItem("Notification", "No notification to display", 0, notificationManager.NbNotifications(), Modes::Preview));
+ currentItem.reset(new NotificationItem("\nNotification", "No notification to display", 0, notificationManager.NbNotifications(), Modes::Preview));
}
if(mode == Modes::Preview) {
@@ -71,7 +71,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
currentId = previousNotification.id;
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
- currentItem.reset(new NotificationItem("Notification", previousNotification.message.data(), previousNotification.index, notificationManager.NbNotifications(), mode));
+ currentItem.reset(new NotificationItem("\nNotification", previousNotification.message.data(), previousNotification.index, notificationManager.NbNotifications(), mode));
}
return true;
case Pinetime::Applications::TouchEvents::SwipeDown: {
@@ -87,7 +87,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
currentId = nextNotification.id;
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
- currentItem.reset(new NotificationItem("Notification", nextNotification.message.data(), nextNotification.index, notificationManager.NbNotifications(), mode));
+ currentItem.reset(new NotificationItem("\nNotification", nextNotification.message.data(), nextNotification.index, notificationManager.NbNotifications(), mode));
}
return true;
default:
@@ -104,7 +104,6 @@ bool Notifications::OnButtonPushed() {
Notifications::NotificationItem::NotificationItem(const char *title, const char *msg, uint8_t notifNr, uint8_t notifNb, Modes mode)
: notifNr{notifNr}, notifNb{notifNb}, mode{mode} {
-
container1 = lv_cont_create(lv_scr_act(), nullptr);
static lv_style_t contStyle;
lv_style_copy(&contStyle, lv_cont_get_style(container1, LV_CONT_STYLE_MAIN));
@@ -140,14 +139,15 @@ Notifications::NotificationItem::NotificationItem(const char *title, const char
lv_label_set_body_draw(t1, true);
lv_obj_set_width(t1, LV_HOR_RES - (titleStyle.body.padding.left + titleStyle.body.padding.right));
lv_label_set_text(t1, title);
- lv_obj_set_pos(t1, titleStyle.body.padding.left, titleStyle.body.padding.top);
+ static constexpr int16_t offscreenOffset = -20 ;
+ lv_obj_set_pos(t1, titleStyle.body.padding.left, offscreenOffset);
auto titleHeight = lv_obj_get_height(t1);
l1 = lv_label_create(container1, nullptr);
lv_label_set_style(l1, LV_LABEL_STYLE_MAIN, &textStyle);
lv_obj_set_pos(l1, textStyle.body.padding.left,
- titleHeight + titleStyle.body.padding.bottom + textStyle.body.padding.bottom +
+ titleHeight + offscreenOffset + textStyle.body.padding.bottom +
textStyle.body.padding.top);
lv_label_set_long_mode(l1, LV_LABEL_LONG_BREAK);
@@ -156,11 +156,15 @@ Notifications::NotificationItem::NotificationItem(const char *title, const char
lv_label_set_text(l1, msg);
if(mode == Modes::Normal) {
- lv_obj_t *bottomlabel = lv_label_create(container1, nullptr);
- lv_label_set_style(bottomlabel, LV_LABEL_STYLE_MAIN, &bottomStyle);
- lv_obj_align(bottomlabel, container1, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
- snprintf(pageText, 4, "%d/%d", notifNr, notifNb);
- lv_label_set_text(bottomlabel, pageText);
+ if(notifNr < notifNb) {
+ bottomPlaceholder = lv_label_create(container1, nullptr);
+ lv_label_set_style(bottomPlaceholder, LV_LABEL_STYLE_MAIN, &titleStyle);
+ lv_label_set_long_mode(bottomPlaceholder, LV_LABEL_LONG_BREAK);
+ lv_label_set_body_draw(bottomPlaceholder, true);
+ lv_obj_set_width(bottomPlaceholder, LV_HOR_RES - (titleStyle.body.padding.left + titleStyle.body.padding.right));
+ lv_label_set_text(bottomPlaceholder, " ");
+ lv_obj_set_pos(bottomPlaceholder, titleStyle.body.padding.left, LV_VER_RES - 5);
+ }
}
}
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index 0f797ea6..fb4e1ef2 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -37,6 +37,7 @@ namespace Pinetime {
lv_obj_t* container1;
lv_obj_t* t1;
lv_obj_t* l1;
+ lv_obj_t* bottomPlaceholder;
Modes mode;
};