2020-10-18 17:35:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-11-15 16:49:36 +01:00
|
|
|
#include <lvgl/lvgl.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
2021-10-13 22:08:35 +02:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2020-11-15 16:49:36 +01:00
|
|
|
#include "components/ble/NotificationManager.h"
|
2021-08-01 13:13:32 +02:00
|
|
|
#include "components/motor/MotorController.h"
|
2020-10-18 17:35:36 +02:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2021-01-24 17:27:48 +01:00
|
|
|
namespace Controllers {
|
|
|
|
class AlertNotificationService;
|
|
|
|
}
|
2020-10-18 17:35:36 +02:00
|
|
|
namespace Applications {
|
|
|
|
namespace Screens {
|
2021-01-24 17:27:48 +01:00
|
|
|
|
2020-10-18 17:35:36 +02:00
|
|
|
class Notifications : public Screen {
|
2021-04-24 11:00:45 +02:00
|
|
|
public:
|
2021-04-18 19:28:14 +02:00
|
|
|
enum class Modes { Normal, Preview };
|
|
|
|
explicit Notifications(DisplayApp* app,
|
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager,
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2021-08-01 13:13:32 +02:00
|
|
|
Pinetime::Controllers::MotorController& motorController,
|
2021-04-18 19:28:14 +02:00
|
|
|
Modes mode);
|
|
|
|
~Notifications() override;
|
2020-10-18 17:35:36 +02:00
|
|
|
|
2021-07-19 15:26:12 +02:00
|
|
|
void Refresh() override;
|
2021-04-18 19:28:14 +02:00
|
|
|
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
2020-10-18 17:35:36 +02:00
|
|
|
|
2021-01-24 17:22:39 +01:00
|
|
|
class NotificationItem {
|
2021-04-24 11:00:45 +02:00
|
|
|
public:
|
2021-04-18 19:28:14 +02:00
|
|
|
NotificationItem(const char* title,
|
|
|
|
const char* msg,
|
|
|
|
uint8_t notifNr,
|
|
|
|
Controllers::NotificationManager::Categories,
|
|
|
|
uint8_t notifNb,
|
|
|
|
Modes mode,
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService);
|
2021-01-24 17:22:39 +01:00
|
|
|
~NotificationItem();
|
2021-08-01 12:05:48 +02:00
|
|
|
bool IsRunning() const {
|
|
|
|
return running;
|
2021-04-18 19:28:14 +02:00
|
|
|
}
|
2021-08-01 12:05:48 +02:00
|
|
|
void OnCallButtonEvent(lv_obj_t*, lv_event_t event);
|
2021-01-24 17:22:39 +01:00
|
|
|
|
2021-04-24 11:00:45 +02:00
|
|
|
private:
|
2021-01-24 17:22:39 +01:00
|
|
|
lv_obj_t* container1;
|
|
|
|
lv_obj_t* bt_accept;
|
2021-01-27 13:45:06 +01:00
|
|
|
lv_obj_t* bt_mute;
|
2021-01-24 17:22:39 +01:00
|
|
|
lv_obj_t* bt_reject;
|
|
|
|
lv_obj_t* label_accept;
|
2021-01-27 13:45:06 +01:00
|
|
|
lv_obj_t* label_mute;
|
2021-01-24 17:22:39 +01:00
|
|
|
lv_obj_t* label_reject;
|
|
|
|
Modes mode;
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
2021-08-01 12:05:48 +02:00
|
|
|
bool running = true;
|
2021-01-24 17:22:39 +01:00
|
|
|
};
|
|
|
|
|
2021-04-24 11:00:45 +02:00
|
|
|
private:
|
2021-04-18 19:28:14 +02:00
|
|
|
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;
|
|
|
|
bool validDisplay = false;
|
2020-10-20 20:57:39 +02:00
|
|
|
|
2021-04-18 19:28:14 +02:00
|
|
|
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
|
2021-08-01 12:05:48 +02:00
|
|
|
lv_obj_t* timeoutLine = nullptr;
|
2021-04-18 19:28:14 +02:00
|
|
|
uint32_t timeoutTickCountStart;
|
|
|
|
uint32_t timeoutTickCountEnd;
|
2021-07-19 15:26:12 +02:00
|
|
|
|
|
|
|
lv_task_t* taskRefresh;
|
2020-10-18 17:35:36 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|