2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/ApplicationList.h"
|
2020-11-15 10:49:36 -05:00
|
|
|
#include <lvgl/lvgl.h>
|
2022-06-16 15:41:54 -04:00
|
|
|
#include <functional>
|
2020-11-15 10:49:36 -05:00
|
|
|
#include "displayapp/Apps.h"
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/DisplayApp.h"
|
2020-08-14 03:46:37 -04:00
|
|
|
|
|
|
|
using namespace Pinetime::Applications::Screens;
|
|
|
|
|
2022-06-16 15:41:54 -04:00
|
|
|
constexpr std::array<Tile::Applications, ApplicationList::applications.size()> ApplicationList::applications;
|
|
|
|
|
|
|
|
auto ApplicationList::CreateScreenList() const {
|
|
|
|
std::array<std::function<std::unique_ptr<Screen>()>, nScreens> screens;
|
|
|
|
for (size_t i = 0; i < screens.size(); i++) {
|
|
|
|
screens[i] = [this, i]() -> std::unique_ptr<Screen> {
|
|
|
|
return CreateScreen(i);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return screens;
|
|
|
|
}
|
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp* app,
|
|
|
|
Pinetime::Controllers::Settings& settingsController,
|
|
|
|
Pinetime::Controllers::Battery& batteryController,
|
2022-07-21 12:27:52 -04:00
|
|
|
Pinetime::Controllers::Ble& bleController,
|
2021-04-18 13:28:14 -04:00
|
|
|
Controllers::DateTime& dateTimeController)
|
|
|
|
: Screen(app),
|
|
|
|
settingsController {settingsController},
|
|
|
|
batteryController {batteryController},
|
2022-07-21 12:27:52 -04:00
|
|
|
bleController {bleController},
|
2021-04-18 13:28:14 -04:00
|
|
|
dateTimeController {dateTimeController},
|
2022-06-16 15:41:54 -04:00
|
|
|
screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
2021-04-18 13:28:14 -04:00
|
|
|
}
|
2020-08-14 03:46:37 -04:00
|
|
|
|
|
|
|
ApplicationList::~ApplicationList() {
|
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
|
|
|
return screens.OnTouchEvent(event);
|
|
|
|
}
|
|
|
|
|
2022-06-16 15:41:54 -04:00
|
|
|
std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) const {
|
|
|
|
std::array<Tile::Applications, appsPerScreen> apps;
|
|
|
|
for (int i = 0; i < appsPerScreen; i++) {
|
|
|
|
apps[i] = applications[screenNum * appsPerScreen + i];
|
|
|
|
}
|
2020-08-14 03:46:37 -04:00
|
|
|
|
2022-07-21 12:27:52 -04:00
|
|
|
return std::make_unique<Screens::Tile>(screenNum,
|
|
|
|
nScreens,
|
|
|
|
app,
|
|
|
|
settingsController,
|
|
|
|
batteryController,
|
|
|
|
bleController,
|
|
|
|
dateTimeController,
|
|
|
|
apps);
|
2020-08-14 03:46:37 -04:00
|
|
|
}
|