Skip to content

Commit

Permalink
Update UI. Remove "Mild" level button.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchigrin committed Nov 27, 2024
1 parent 92b8cd3 commit b7117c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
28 changes: 10 additions & 18 deletions src/displayapp/screens/FindMyPhone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace {
static constexpr char defaultLabelText[] = "Find my phone";
static constexpr char alertSentLabelText[] = "Alert sent";
static constexpr char noConnectionLabelText[] = "No connection";
static constexpr char noneLabelText[] = "Stop";
static constexpr char highLabelText[] = "Ring";
static constexpr auto restoreLabelTimeoutTicks = pdMS_TO_TICKS(2 * 1000);

void btnImmediateAlertEventHandler(lv_obj_t* obj, lv_event_t event) {
Expand Down Expand Up @@ -44,28 +46,19 @@ FindMyPhone::FindMyPhone(Pinetime::Controllers::ImmediateAlertClient& immediateA
bt_none = lv_btn_create(container, nullptr);
bt_none->user_data = this;
lv_obj_set_event_cb(bt_none, btnImmediateAlertEventHandler);
lv_obj_set_size(bt_none, 76, 76);
lv_obj_set_size(bt_none, 114, 76);
lv_obj_align(bt_none, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label_none = lv_label_create(bt_none, nullptr);
lv_label_set_text_static(label_none, "None");
lv_label_set_text_static(label_none, noneLabelText);
lv_obj_set_style_local_bg_color(bt_none, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);

bt_mild = lv_btn_create(container, nullptr);
bt_mild->user_data = this;
lv_obj_set_event_cb(bt_mild, btnImmediateAlertEventHandler);
lv_obj_set_size(bt_mild, 76, 76);
lv_obj_align(bt_mild, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
label_mild = lv_label_create(bt_mild, nullptr);
lv_label_set_text_static(label_mild, "Mild");
lv_obj_set_style_local_bg_color(bt_mild, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);

bt_high = lv_btn_create(container, nullptr);
bt_high->user_data = this;
lv_obj_set_event_cb(bt_high, btnImmediateAlertEventHandler);
lv_obj_set_size(bt_high, 76, 76);
lv_obj_set_size(bt_high, 114, 76);
lv_obj_align(bt_high, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label_high = lv_label_create(bt_high, nullptr);
lv_label_set_text_static(label_high, "High");
lv_label_set_text_static(label_high, highLabelText);
lv_obj_set_style_local_bg_color(bt_high, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
}

Expand All @@ -77,8 +70,6 @@ void FindMyPhone::OnImmediateAlertEvent(lv_obj_t* obj, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
if (obj == bt_none) {
last_level = Pinetime::Controllers::ImmediateAlertClient::Levels::NoAlert;
} else if (obj == bt_mild) {
last_level = Pinetime::Controllers::ImmediateAlertClient::Levels::MildAlert;
} else if (obj == bt_high) {
last_level = Pinetime::Controllers::ImmediateAlertClient::Levels::HighAlert;
}
Expand All @@ -91,12 +82,13 @@ void FindMyPhone::UpdateImmediateAlerts() {
case Pinetime::Controllers::ImmediateAlertClient::Levels::NoAlert:
lv_obj_set_style_local_text_color(label_title, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
break;
case Pinetime::Controllers::ImmediateAlertClient::Levels::MildAlert:
lv_obj_set_style_local_text_color(label_title, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);
break;
case Pinetime::Controllers::ImmediateAlertClient::Levels::HighAlert:
lv_obj_set_style_local_text_color(label_title, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
break;
case Pinetime::Controllers::ImmediateAlertClient::Levels::MildAlert:
// Not supported.
ASSERT(false);
break;
}
if (immediateAlertClient.sendImmediateAlert(last_level)) {
lv_label_set_text_static(label_title, alertSentLabelText);
Expand Down
2 changes: 0 additions & 2 deletions src/displayapp/screens/FindMyPhone.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ namespace Pinetime {
lv_obj_t* label_title;
lv_obj_t* bt_none;
lv_obj_t* bt_high;
lv_obj_t* bt_mild;
lv_obj_t* label_none;
lv_obj_t* label_high;
lv_obj_t* label_mild;
lv_task_t* taskRestoreLabelText = nullptr;

Pinetime::Controllers::ImmediateAlertClient::Levels last_level;
Expand Down

0 comments on commit b7117c2

Please sign in to comment.