Combine Date and Time Settings (#1465)

Replace separate SettingSetDate and SettingSetTime with a combined screenlist.
Add DotIndicators. Similar to PageIndicator, but for use when separating screens instead of pages of a list.

Co-authored-by: Riku Isokoski <riksu9000@gmail.com>
This commit is contained in:
John Quigley
2023-01-14 14:50:21 -05:00
committed by GitHub
parent 6f6ea68aca
commit a7f8b59bfb
12 changed files with 170 additions and 35 deletions

View File

@@ -1,4 +1,5 @@
#include "displayapp/screens/settings/SettingSetDate.h"
#include "displayapp/screens/settings/SettingSetDateTime.h"
#include <lvgl/lvgl.h>
#include <hal/nrf_rtc.h>
#include <nrf_log.h>
@@ -44,8 +45,11 @@ namespace {
}
}
SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController)
: Screen(app), dateTimeController {dateTimeController} {
SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::DateTime& dateTimeController,
Pinetime::Applications::Screens::SettingSetDateTime& settingSetDateTime)
: Screen(app), dateTimeController {dateTimeController}, settingSetDateTime {settingSetDateTime} {
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(title, "Set current date");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
@@ -82,8 +86,6 @@ SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, Pinetime
lblSetTime = lv_label_create(btnSetTime, nullptr);
lv_label_set_text_static(lblSetTime, "Set");
lv_obj_set_event_cb(btnSetTime, event_handler);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
lv_obj_set_state(lblSetTime, LV_STATE_DISABLED);
}
SettingSetDate::~SettingSetDate() {
@@ -103,13 +105,10 @@ void SettingSetDate::HandleButtonPress() {
dateTimeController.Minutes(),
dateTimeController.Seconds(),
nrf_rtc_counter_get(portNRF_RTC_REG));
lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
lv_obj_set_state(lblSetTime, LV_STATE_DISABLED);
settingSetDateTime.Advance();
}
void SettingSetDate::CheckDay() {
const int maxDay = MaximumDayOfMonth(monthCounter.GetValue(), yearCounter.GetValue());
dayCounter.SetMax(maxDay);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
lv_obj_set_state(lblSetTime, LV_STATE_DEFAULT);
}