InfiniTime.git

commit 5983e33b8d7702800dc91a3229b9a7cee75eb006

Author: JF <jf@codingfield.com>

Notifications : Replace the label "notificationNr/notificationNb" by a grey border on the bottom that is displayed when there are other notifications to available.

 src/displayapp/screens/Notifications.cpp | 28 ++++++++++++++-----------
 src/displayapp/screens/Notifications.h | 1 


diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 38a28e12f35f980462eed6e7693630993a27a3bb..85848b2f8712c772e52e6b8c7ac9680416c8a7e6 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -11,10 +11,10 @@   notificationManager.ClearNewNotificationFlag();
   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 @@       validDisplay = true;
       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 @@       validDisplay = true;
       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 @@
 
 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 @@   lv_label_set_long_mode(t1, LV_LABEL_LONG_BREAK);
   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 @@   lv_obj_set_width(l1, LV_HOR_RES - (textStyle.body.padding.left + textStyle.body.padding.right));
   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 0f797ea61a07ff1e1fc04026f63825a3de97a801..fb4e1ef2f078c8bbda1c89abc819391e54edc4a3 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -37,6 +37,7 @@
               lv_obj_t* container1;
               lv_obj_t* t1;
               lv_obj_t* l1;
+              lv_obj_t* bottomPlaceholder;
               Modes mode;
           };