InfiniTime/src/displayapp/screens/Notifications.h

86 lines
2.9 KiB
C
Raw Normal View History

#pragma once
2020-11-15 15:49:36 +00:00
#include <lvgl/lvgl.h>
2022-01-01 14:22:35 +00:00
#include <FreeRTOS.h>
2020-11-15 15:49:36 +00:00
#include <cstdint>
#include <memory>
#include "displayapp/screens/Screen.h"
2020-11-15 15:49:36 +00:00
#include "components/ble/NotificationManager.h"
2021-08-01 11:13:32 +00:00
#include "components/motor/MotorController.h"
2022-01-01 14:22:35 +00:00
#include "systemtask/SystemTask.h"
namespace Pinetime {
namespace Controllers {
class AlertNotificationService;
}
namespace Applications {
namespace Screens {
class Notifications : public Screen {
2021-04-24 09:00:45 +00:00
public:
enum class Modes { Normal, Preview };
explicit Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
2021-08-01 11:13:32 +00:00
Pinetime::Controllers::MotorController& motorController,
2022-01-01 14:22:35 +00:00
System::SystemTask& systemTask,
Modes mode);
~Notifications() override;
2021-07-19 13:26:12 +00:00
void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
2022-01-01 14:22:35 +00:00
void OnPreviewInteraction();
class NotificationItem {
2021-04-24 09:00:45 +00:00
public:
NotificationItem(const char* title,
const char* msg,
uint8_t notifNr,
Controllers::NotificationManager::Categories,
uint8_t notifNb,
Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService);
~NotificationItem();
2021-08-01 10:05:48 +00:00
bool IsRunning() const {
return running;
}
2021-08-01 10:05:48 +00:00
void OnCallButtonEvent(lv_obj_t*, lv_event_t event);
2021-04-24 09:00:45 +00:00
private:
lv_obj_t* container1;
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;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
2021-08-01 10:05:48 +00:00
bool running = true;
};
2021-04-24 09:00:45 +00:00
private:
struct NotificationData {
const char* title;
const char* text;
};
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
2022-01-01 14:22:35 +00:00
System::SystemTask& systemTask;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId;
bool validDisplay = false;
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
2021-08-01 10:05:48 +00:00
lv_obj_t* timeoutLine = nullptr;
2022-01-01 14:22:35 +00:00
TickType_t timeoutTickCountStart;
static const TickType_t timeoutLength = pdMS_TO_TICKS(7000);
bool interacted = true;
2021-07-19 13:26:12 +00:00
lv_task_t* taskRefresh;
};
}
}
}