InfiniTime/src/displayapp/screens/ApplicationList.cpp

86 lines
2.2 KiB
C++
Raw Normal View History

#include "ApplicationList.h"
2020-11-15 15:49:36 +00:00
#include <lvgl/lvgl.h>
#include <array>
#include "Symbols.h"
2020-11-15 15:49:36 +00:00
#include "Tile.h"
#include "displayapp/Apps.h"
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
2021-02-01 12:14:49 +00:00
ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp *app) :
Screen(app),
screens{app, {
[this]() -> std::unique_ptr<Screen> { return CreateScreen1(); },
[this]() -> std::unique_ptr<Screen> { return CreateScreen2(); },
//[this]() -> std::unique_ptr<Screen> { return CreateScreen3(); }
}
}
2021-01-28 17:13:28 +00:00
{
}
2021-01-28 17:13:28 +00:00
ApplicationList::~ApplicationList()
{
lv_obj_clean(lv_scr_act());
}
2021-01-28 17:13:28 +00:00
bool ApplicationList::Refresh()
{
if (running)
running = screens.Refresh();
return running;
}
2021-01-28 17:13:28 +00:00
bool ApplicationList::OnButtonPushed()
{
running = false;
app->StartApp(Apps::Clock);
return true;
}
2021-01-28 17:13:28 +00:00
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event)
{
return screens.OnTouchEvent(event);
}
2021-01-28 17:13:28 +00:00
std::unique_ptr<Screen> ApplicationList::CreateScreen1()
{
std::array<Screens::Tile::Applications, 6> applications{
{{Symbols::clock, Apps::Clock},
{Symbols::music, Apps::Music},
{Symbols::sun, Apps::Brightness},
{Symbols::list, Apps::SysInfo},
{Symbols::check, Apps::FirmwareValidation},
{Symbols::heartBeat, Apps::HeartRate}}
};
return std::unique_ptr<Screen>(new Screens::Tile(app, applications));
}
2021-01-28 17:13:28 +00:00
std::unique_ptr<Screen> ApplicationList::CreateScreen2()
{
std::array<Screens::Tile::Applications, 6> applications{
{{Symbols::map, Apps::Navigation},
{Symbols::asterisk, Apps::Meter},
{Symbols::paintbrush, Apps::Paint},
{Symbols::info, Apps::Notifications},
{Symbols::paddle, Apps::Paddle},
{"2", Apps::Twos}}};
return std::unique_ptr<Screen>(new Screens::Tile(app, applications));
}
2021-01-28 17:13:28 +00:00
std::unique_ptr<Screen> ApplicationList::CreateScreen3()
{
std::array<Screens::Tile::Applications, 6> applications{
{{"A", Apps::Meter},
2021-02-01 12:14:49 +00:00
{"B", Apps::None},
2021-01-28 17:13:28 +00:00
{"C", Apps::Clock},
{"D", Apps::Music},
{"E", Apps::SysInfo},
{"F", Apps::Brightness}}};
return std::unique_ptr<Screen>(new Screens::Tile(app, applications));
}