Merge pull request #701 from maksalees/close-info-popup-with-back-button-in-alarm

Alarm: Close the popup with information about the time until alarm with the back button
This commit is contained in:
JF 2021-10-09 19:50:36 +02:00 committed by GitHub
commit 4118f97812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -120,10 +120,7 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
return; return;
} }
if (obj == btnMessage) { if (obj == btnMessage) {
lv_obj_del(txtMessage); HideInfo();
lv_obj_del(btnMessage);
txtMessage = nullptr;
btnMessage = nullptr;
return; return;
} }
// If any other button was pressed, disable the alarm // If any other button was pressed, disable the alarm
@ -174,6 +171,14 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
} }
} }
bool Alarm::OnButtonPushed() {
if (txtMessage != nullptr && btnMessage != nullptr) {
HideInfo();
return true;
}
return false;
}
void Alarm::UpdateAlarmTime() { void Alarm::UpdateAlarmTime() {
lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes); lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
alarmController.SetAlarmTime(alarmHours, alarmMinutes); alarmController.SetAlarmTime(alarmHours, alarmMinutes);
@ -224,6 +229,12 @@ void Alarm::ShowInfo() {
} }
} }
void Alarm::HideInfo() {
lv_obj_del(btnMessage);
txtMessage = nullptr;
btnMessage = nullptr;
}
void Alarm::SetRecurButtonState() { void Alarm::SetRecurButtonState() {
using Pinetime::Controllers::AlarmController; using Pinetime::Controllers::AlarmController;
switch (alarmController.Recurrence()) { switch (alarmController.Recurrence()) {

View file

@ -31,6 +31,7 @@ namespace Pinetime {
~Alarm() override; ~Alarm() override;
void SetAlerting(); void SetAlerting();
void OnButtonEvent(lv_obj_t* obj, lv_event_t event); void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
bool OnButtonPushed() override;
private: private:
bool running; bool running;
@ -46,6 +47,7 @@ namespace Pinetime {
void SetRecurButtonState(); void SetRecurButtonState();
void SetAlarm(); void SetAlarm();
void ShowInfo(); void ShowInfo();
void HideInfo();
void ToggleRecurrence(); void ToggleRecurrence();
void UpdateAlarmTime(); void UpdateAlarmTime();
}; };