ref: e5b73212f6addcfdb5e306df63d7135e543c4f8d
src/displayapp/screens/ApplicationList.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
#include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/Tile.h" #include <lvgl/lvgl.h> #include <functional> #include <algorithm> #include "components/settings/Settings.h" using namespace Pinetime::Applications::Screens; 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; } ApplicationList::ApplicationList(DisplayApp* app, Pinetime::Controllers::Settings& settingsController, const Pinetime::Controllers::Battery& batteryController, const Pinetime::Controllers::Ble& bleController, Controllers::DateTime& dateTimeController, Pinetime::Controllers::FS& filesystem, std::array<Tile::Applications, UserAppTypes::Count>&& apps) : app {app}, settingsController {settingsController}, batteryController {batteryController}, bleController {bleController}, dateTimeController {dateTimeController}, filesystem {filesystem}, apps {std::move(apps)}, screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} { } ApplicationList::~ApplicationList() { lv_obj_clean(lv_scr_act()); } bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) { return screens.OnTouchEvent(event); } std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) const { std::array<Tile::Applications, appsPerScreen> pageApps; for (int i = 0; i < appsPerScreen; i++) { if (i + (screenNum * appsPerScreen) >= apps.size()) { pageApps[i] = {"", Pinetime::Applications::Apps::None, false}; } else { pageApps[i] = apps[i + (screenNum * appsPerScreen)]; } } return std::make_unique<Screens::Tile>(screenNum, nScreens, app, settingsController, batteryController, bleController, dateTimeController, pageApps); } |