1
0
Fork 0
InfiniTime/src/displayapp/screens/Notifications.h

97 lines
3.3 KiB
C
Raw Normal View History

#pragma once
2020-11-15 16:49:36 +01:00
#include <lvgl/lvgl.h>
#include <cstdint>
#include <memory>
#include "Screen.h"
2020-11-15 16:49:36 +01:00
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
namespace Pinetime {
namespace Controllers {
class AlertNotificationService;
}
namespace Applications {
namespace Screens {
class Notifications : public Screen {
2021-04-24 11:00:45 +02:00
public:
enum class Modes { Normal, Preview };
explicit Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Controllers::MotorController& motorController,
Modes mode);
~Notifications() override;
bool Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
class NotificationItem {
2021-04-24 11:00:45 +02:00
public:
NotificationItem(const char* title,
const char* msg,
uint8_t notifNr,
Controllers::NotificationManager::Categories,
uint8_t notifNb,
Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Controllers::MotorController& motorController,
uint32_t* timeoutEnd,
uint32_t* timeoutStart);
~NotificationItem();
bool Refresh() {
return false;
}
void OnAcceptIncomingCall(lv_event_t event);
void OnMuteIncomingCall(lv_event_t event);
void OnRejectIncomingCall(lv_event_t event);
bool timeoutOnHold = false;
2021-04-24 11:00:45 +02:00
private:
void callPreviewInteraction();
uint8_t notifNr = 0;
uint8_t notifNb = 0;
char pageText[4];
lv_obj_t* container1;
lv_obj_t* t1;
lv_obj_t* l1;
lv_obj_t* l2;
lv_obj_t* bt_accept;
lv_obj_t* bt_mute;
lv_obj_t* bt_reject;
lv_obj_t* label_accept;
lv_obj_t* label_mute;
lv_obj_t* label_reject;
lv_obj_t* bottomPlaceholder;
uint32_t* timeoutEnd;
uint32_t* timeoutStart;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Controllers::MotorController& motorController;
};
2021-04-24 11:00:45 +02:00
private:
struct NotificationData {
const char* title;
const char* text;
};
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId;
Controllers::MotorController& motorController;
bool validDisplay = false;
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
lv_obj_t* timeoutLine;
uint32_t timeoutTickCountStart;
uint32_t timeoutTickCountEnd;
};
}
}
}