Skip to content

Commit

Permalink
Extract apply button handling to local method
Browse files Browse the repository at this point in the history
  • Loading branch information
Master92 committed Nov 11, 2024
1 parent 7d1b87a commit fb7b0e5
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions src/ui/page_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,21 @@ static void page_wifi_on_roller(uint8_t key) {
}
}

/**
* Common handling method of the three "apply settings" buttons.
*/
static void page_wifi_handle_apply_button(lv_obj_t* apply_button) {
if (page_wifi.confirm_settings) {
lv_label_set_text(apply_button, "#FF0000 Updating WiFi...#");
page_wifi_apply_settings_timer = lv_timer_create(page_wifi_apply_settings_timer_cb, 1000, NULL);
lv_timer_set_repeat_count(page_wifi_apply_settings_timer, 1);
page_wifi.confirm_settings = 2;
} else {
lv_label_set_text(apply_button, "#FFFF00 Click to confirm or Scroll to cancel...#");
page_wifi.confirm_settings = 1;
}
}

/**
* Main input selection routine for this page.
*/
Expand Down Expand Up @@ -930,16 +945,8 @@ static void page_wifi_on_click(uint8_t key, int sel) {
}
break;
case 2:
if (page_wifi.confirm_settings) {
lv_label_set_text(page_wifi.page_3.apply_settings, "#FF0000 Updating WiFi...#");
page_wifi_apply_settings_timer = lv_timer_create(page_wifi_apply_settings_timer_cb, 1000, NULL);
lv_timer_set_repeat_count(page_wifi_apply_settings_timer, 1);
page_wifi.confirm_settings = 2;
} else {
lv_label_set_text(page_wifi.page_3.apply_settings, "#FFFF00 Click to confirm or Scroll to cancel...#");
page_wifi.confirm_settings = 1;
}
break;
page_wifi_handle_apply_button(page_wifi.page_3.apply_settings);
break;
}
break;
case 4:
Expand All @@ -966,15 +973,7 @@ static void page_wifi_on_click(uint8_t key, int sel) {
case 5:
switch (btn_group_get_sel(&page_wifi.page_select.button)) {
case 0:
if (page_wifi.confirm_settings) {
lv_label_set_text(page_wifi.page_1.apply_settings, "#FF0000 Updating WiFi...#");
page_wifi_apply_settings_timer = lv_timer_create(page_wifi_apply_settings_timer_cb, 1000, NULL);
lv_timer_set_repeat_count(page_wifi_apply_settings_timer, 1);
page_wifi.confirm_settings = 2;
} else {
lv_label_set_text(page_wifi.page_1.apply_settings, "#FFFF00 Click to confirm or Scroll to cancel...#");
page_wifi.confirm_settings = 1;
}
page_wifi_handle_apply_button(page_wifi.page_1.apply_settings);
break;
case 1:
if (!keyboard_active()) {
Expand Down Expand Up @@ -1005,15 +1004,7 @@ static void page_wifi_on_click(uint8_t key, int sel) {
case 7:
switch (btn_group_get_sel(&page_wifi.page_select.button)) {
case 1:
if (page_wifi.confirm_settings) {
lv_label_set_text(page_wifi.page_2.apply_settings, "#FF0000 Updating WiFi...#");
page_wifi_apply_settings_timer = lv_timer_create(page_wifi_apply_settings_timer_cb, 1000, NULL);
lv_timer_set_repeat_count(page_wifi_apply_settings_timer, 1);
page_wifi.confirm_settings = 2;
} else {
lv_label_set_text(page_wifi.page_2.apply_settings, "#FFFF00 Click to confirm or Scroll to cancel...#");
page_wifi.confirm_settings = 1;
}
page_wifi_handle_apply_button(page_wifi.page_2.apply_settings);
break;
}
break;
Expand Down

0 comments on commit fb7b0e5

Please sign in to comment.