Fixes based on code reviews

This commit is contained in:
Maxim Leshchenko 2021-09-29 19:15:23 +03:00
parent d86ae69961
commit 05f8850acf
2 changed files with 9 additions and 8 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
@ -176,10 +173,7 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
bool Alarm::OnButtonPushed() { bool Alarm::OnButtonPushed() {
if (txtMessage != nullptr && btnMessage != nullptr) { if (txtMessage != nullptr && btnMessage != nullptr) {
lv_obj_del(txtMessage); HideInfo();
lv_obj_del(btnMessage);
txtMessage = nullptr;
btnMessage = nullptr;
return true; return true;
} }
return false; return false;
@ -235,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

@ -47,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();
}; };