From cf8b422899f198ae713b5a2a35e2ea737521b053 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 2 Oct 2022 21:05:15 +0200 Subject: Checkbox list now receives a function pointer to call when the setting has changed. This allow to remove the dependency between CheckBoxList (UI component) with SettingController. --- .../screens/settings/SettingWatchFace.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/displayapp/screens/settings/SettingWatchFace.cpp') diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 411cc898..ce1efaa2 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -3,8 +3,6 @@ #include "displayapp/DisplayApp.h" #include "displayapp/screens/CheckboxList.h" #include "displayapp/screens/Screen.h" -#include "displayapp/screens/Styles.h" -#include "displayapp/screens/Symbols.h" #include "components/settings/Settings.h" using namespace Pinetime::Applications::Screens; @@ -16,7 +14,7 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine : Screen(app), settingsController {settingsController}, screens {app, - settingsController.GetWatchfacesMenu(), + 0, {[this]() -> std::unique_ptr { return CreateScreen1(); }, @@ -28,7 +26,6 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine SettingWatchFace::~SettingWatchFace() { lv_obj_clean(lv_scr_act()); - settingsController.SaveSettings(); } bool SettingWatchFace::OnTouchEvent(Pinetime::Applications::TouchEvents event) { @@ -40,11 +37,13 @@ std::unique_ptr SettingWatchFace::CreateScreen1() { return std::make_unique(0, 2, app, - settingsController, title, symbol, - &Controllers::Settings::SetClockFace, - &Controllers::Settings::GetClockFace, + settingsController.GetClockFace(), + [&settings = settingsController](uint32_t clockFace) { + settings.SetClockFace(clockFace); + settings.SaveSettings(); + }, watchfaces); } @@ -53,10 +52,12 @@ std::unique_ptr SettingWatchFace::CreateScreen2() { return std::make_unique(1, 2, app, - settingsController, title, symbol, - &Controllers::Settings::SetClockFace, - &Controllers::Settings::GetClockFace, + settingsController.GetClockFace(), + [&settings = settingsController](uint32_t clockFace) { + settings.SetClockFace(clockFace); + settings.SaveSettings(); + }, watchfaces); } -- cgit v1.2.3-70-g09d2