summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/settings/SettingWatchFace.cpp
blob: 217f97b8ea7cb6f6c3312f5ba744436e81b09789 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
#include "displayapp/screens/settings/SettingWatchFace.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/Screen.h"
#include "components/settings/Settings.h"
#include "displayapp/screens/WatchFaceInfineat.h"
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"

using namespace Pinetime::Applications::Screens;

constexpr const char* SettingWatchFace::title;
constexpr const char* SettingWatchFace::symbol;

SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app,
                                   Pinetime::Controllers::Settings& settingsController,
                                   Pinetime::Controllers::FS& filesystem)
  : Screen(app),
    settingsController {settingsController},
    filesystem {filesystem},
    screens {app,
             0,
             {[this]() -> std::unique_ptr<Screen> {
                return CreateScreen1();
              },
              [this]() -> std::unique_ptr<Screen> {
                return CreateScreen2();
              }},
             Screens::ScreenListModes::UpDown} {
}

SettingWatchFace::~SettingWatchFace() {
  lv_obj_clean(lv_scr_act());
}

bool SettingWatchFace::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
  return screens.OnTouchEvent(event);
}

std::unique_ptr<Screen> SettingWatchFace::CreateScreen1() {
  std::array<Screens::CheckboxList::Item, 4> watchfaces {
    {{"Digital face", true}, {"Analog face", true}, {"PineTimeStyle", true}, {"Terminal", true}}};
  return std::make_unique<Screens::CheckboxList>(
    0,
    2,
    app,
    title,
    symbol,
    settingsController.GetClockFace(),
    [&settings = settingsController](uint32_t clockFace) {
      settings.SetClockFace(clockFace);
      settings.SaveSettings();
    },
    watchfaces);
}

std::unique_ptr<Screen> SettingWatchFace::CreateScreen2() {
  std::array<Screens::CheckboxList::Item, 4> watchfaces {
    {{"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)},
     {"Casio G7710", Applications::Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem)},
     {"", false},
     {"", false}}};
  return std::make_unique<Screens::CheckboxList>(
    1,
    2,
    app,
    title,
    symbol,
    settingsController.GetClockFace(),
    [&settings = settingsController](uint32_t clockFace) {
      settings.SetClockFace(clockFace);
      settings.SaveSettings();
    },
    watchfaces);
}