|
| 1 | +#include "Error.h" |
| 2 | + |
| 3 | +using namespace Pinetime::Applications::Screens; |
| 4 | + |
| 5 | +namespace { |
| 6 | + void ButtonEventCallback(lv_obj_t* obj, lv_event_t /*event*/) { |
| 7 | + auto* errorScreen = static_cast<Error*>(obj->user_data); |
| 8 | + errorScreen->ButtonEventHandler(); |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error) |
| 13 | + : Screen(app) { |
| 14 | + |
| 15 | + lv_obj_t* warningLabel = lv_label_create(lv_scr_act(), nullptr); |
| 16 | + lv_obj_set_style_local_text_color(warningLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); |
| 17 | + lv_label_set_text_static(warningLabel, "Warning"); |
| 18 | + lv_obj_align(warningLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0); |
| 19 | + |
| 20 | + lv_obj_t* causeLabel = lv_label_create(lv_scr_act(), nullptr); |
| 21 | + lv_label_set_long_mode(causeLabel, LV_LABEL_LONG_BREAK); |
| 22 | + lv_obj_set_width(causeLabel, LV_HOR_RES); |
| 23 | + lv_obj_align(causeLabel, warningLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); |
| 24 | + |
| 25 | + if (error == System::BootErrors::TouchController) { |
| 26 | + lv_label_set_text_static(causeLabel, "Touch controller error detected."); |
| 27 | + } |
| 28 | + |
| 29 | + lv_obj_t* tipLabel = lv_label_create(lv_scr_act(), nullptr); |
| 30 | + lv_label_set_long_mode(tipLabel, LV_LABEL_LONG_BREAK); |
| 31 | + lv_obj_set_width(tipLabel, LV_HOR_RES); |
| 32 | + lv_label_set_text_static(tipLabel, "If you encounter problems and your device is under warranty, contact the devices seller."); |
| 33 | + lv_obj_align(tipLabel, causeLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); |
| 34 | + |
| 35 | + btnOk = lv_btn_create(lv_scr_act(), nullptr); |
| 36 | + btnOk->user_data = this; |
| 37 | + lv_obj_set_event_cb(btnOk, ButtonEventCallback); |
| 38 | + lv_obj_set_size(btnOk, LV_HOR_RES, 50); |
| 39 | + lv_obj_align(btnOk, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0); |
| 40 | + lv_obj_set_style_local_value_str(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Proceed"); |
| 41 | + lv_obj_set_style_local_bg_color(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); |
| 42 | +} |
| 43 | + |
| 44 | +void Error::ButtonEventHandler() { |
| 45 | + running = false; |
| 46 | +} |
| 47 | + |
| 48 | +Error::~Error() { |
| 49 | + lv_obj_clean(lv_scr_act()); |
| 50 | +} |
| 51 | + |
| 52 | +bool Error::Refresh() { |
| 53 | + return running; |
| 54 | +} |
0 commit comments