Wifi app improvements (#107)
This commit is contained in:
committed by
GitHub
parent
50ee77d572
commit
422bc01fdb
@@ -14,14 +14,16 @@ namespace tt::app::wificonnect {
|
||||
|
||||
#define TAG "wifi_connect"
|
||||
|
||||
std::shared_ptr<WifiConnect> _Nullable optWifiConnect();
|
||||
|
||||
void View::resetErrors() {
|
||||
lv_obj_add_flag(password_error, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(ssid_error, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(connection_error, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
static void onConnect(lv_event_t* event) {
|
||||
auto* wifi = (WifiConnect*)lv_event_get_user_data(event);
|
||||
static void onConnect(TT_UNUSED lv_event_t* event) {
|
||||
auto wifi = optWifiConnect();
|
||||
auto& view = wifi->getView();
|
||||
|
||||
wifi->getState().setConnectionError(false);
|
||||
@@ -78,7 +80,7 @@ void View::setLoading(bool loading) {
|
||||
}
|
||||
}
|
||||
|
||||
void View::createBottomButtons(WifiConnect* wifi, lv_obj_t* parent) {
|
||||
void View::createBottomButtons(lv_obj_t* parent) {
|
||||
lv_obj_t* button_container = lv_obj_create(parent);
|
||||
lv_obj_set_width(button_container, LV_PCT(100));
|
||||
lv_obj_set_height(button_container, LV_SIZE_CONTENT);
|
||||
@@ -103,11 +105,11 @@ void View::createBottomButtons(WifiConnect* wifi, lv_obj_t* parent) {
|
||||
lv_obj_t* connect_label = lv_label_create(connect_button);
|
||||
lv_label_set_text(connect_label, "Connect");
|
||||
lv_obj_align(connect_button, LV_ALIGN_RIGHT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(connect_button, &onConnect, LV_EVENT_CLICKED, wifi);
|
||||
lv_obj_add_event_cb(connect_button, &onConnect, LV_EVENT_CLICKED, nullptr);
|
||||
}
|
||||
|
||||
// TODO: Standardize dialogs
|
||||
void View::init(AppContext& app, WifiConnect* wifiConnect, lv_obj_t* parent) {
|
||||
void View::init(AppContext& app, lv_obj_t* parent) {
|
||||
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lvgl::toolbar_create(parent, app);
|
||||
@@ -180,7 +182,7 @@ void View::init(AppContext& app, WifiConnect* wifiConnect, lv_obj_t* parent) {
|
||||
lv_obj_add_flag(connection_error, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
// Bottom buttons
|
||||
createBottomButtons(wifiConnect, wrapper);
|
||||
createBottomButtons(wrapper);
|
||||
|
||||
// Keyboard bindings
|
||||
service::gui::keyboardAddTextArea(ssid_textarea);
|
||||
@@ -201,10 +203,7 @@ void View::init(AppContext& app, WifiConnect* wifiConnect, lv_obj_t* parent) {
|
||||
}
|
||||
}
|
||||
|
||||
void View::update(
|
||||
TT_UNUSED Bindings* bindings,
|
||||
State* state
|
||||
) {
|
||||
void View::update() {
|
||||
if (state->hasConnectionError()) {
|
||||
setLoading(false);
|
||||
resetErrors();
|
||||
|
||||
Reference in New Issue
Block a user