Implemented Files app (#33)

- Created Files app to browse PC and ESP32 files.
- Refactored toolbars so it's now a proper widget and allows for changing its properties from the app
- Toolbar now has extra action buttons
- Settings app now has a proper icon
- Minor cleanup in Desktop app
This commit is contained in:
Ken Van Hoeylandt
2024-02-06 23:18:34 +01:00
committed by GitHub
parent 93e4378a9e
commit 5880e841a3
31 changed files with 689 additions and 117 deletions
@@ -6,6 +6,7 @@
#include "services/wifi/wifi_credentials.h"
#include "ui/spacer.h"
#include "ui/style.h"
#include "ui/toolbar.h"
#include "wifi_connect.h"
#include "wifi_connect_bundle.h"
#include "wifi_connect_state.h"
@@ -69,26 +70,29 @@ void wifi_connect_view_create(App app, void* wifi, lv_obj_t* parent) {
WifiConnectView* view = &wifi_connect->view;
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
tt_lv_obj_set_style_auto_padding(parent);
tt_toolbar_create_for_app(parent, app);
view->root = parent;
lv_obj_t* wrapper = lv_obj_create(parent);
lv_obj_set_width(wrapper, LV_PCT(100));
lv_obj_set_flex_grow(wrapper, 1);
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
lv_obj_t* ssid_label = lv_label_create(parent);
lv_obj_t* ssid_label = lv_label_create(wrapper);
lv_label_set_text(ssid_label, "Network:");
view->ssid_textarea = lv_textarea_create(parent);
view->ssid_textarea = lv_textarea_create(wrapper);
lv_textarea_set_one_line(view->ssid_textarea, true);
tt_lv_spacer_create(parent, 1, 8);
tt_lv_spacer_create(wrapper, 1, 8);
lv_obj_t* password_label = lv_label_create(parent);
lv_obj_t* password_label = lv_label_create(wrapper);
lv_label_set_text(password_label, "Password:");
view->password_textarea = lv_textarea_create(parent);
view->password_textarea = lv_textarea_create(wrapper);
lv_textarea_set_one_line(view->password_textarea, true);
lv_textarea_set_password_mode(view->password_textarea, true);
tt_lv_spacer_create(parent, 1, 8);
tt_lv_spacer_create(wrapper, 1, 8);
wifi_connect_view_create_bottom_buttons(wifi, parent);
wifi_connect_view_create_bottom_buttons(wifi, wrapper);
gui_keyboard_add_textarea(view->ssid_textarea);
gui_keyboard_add_textarea(view->password_textarea);
@@ -9,7 +9,6 @@ extern "C" {
#endif
typedef struct {
lv_obj_t* root;
lv_obj_t* ssid_textarea;
lv_obj_t* password_textarea;
lv_obj_t* connect_button;
@@ -125,7 +125,7 @@ static void app_show(App app, lv_obj_t* parent) {
wifi_manage_lock(wifi);
wifi->view_enabled = true;
strcpy((char*)wifi->state.connect_ssid, "Connected"); // TODO update with proper SSID
wifi_manage_view_create(&wifi->view, &wifi->bindings, parent);
wifi_manage_view_create(app, &wifi->view, &wifi->bindings, parent);
wifi_manage_view_update(&wifi->view, &wifi->bindings, &wifi->state);
wifi_manage_unlock(wifi);
@@ -3,6 +3,7 @@
#include "log.h"
#include "services/wifi/wifi.h"
#include "ui/style.h"
#include "ui/toolbar.h"
#include "wifi_manage_state.h"
#define TAG "wifi_main_view"
@@ -147,14 +148,19 @@ static void update_connected_ap(WifiManageView* view, WifiManageState* state, Wi
// region Main
void wifi_manage_view_create(WifiManageView* view, WifiManageBindings* bindings, lv_obj_t* parent) {
void wifi_manage_view_create(App app, WifiManageView* view, WifiManageBindings* bindings, lv_obj_t* parent) {
view->root = parent;
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
tt_lv_obj_set_style_auto_padding(parent);
tt_toolbar_create_for_app(parent, app);
lv_obj_t* wrapper = lv_obj_create(parent);
lv_obj_set_width(wrapper, LV_PCT(100));
lv_obj_set_flex_grow(wrapper, 1);
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
// Top row: enable/disable
lv_obj_t* switch_container = lv_obj_create(parent);
lv_obj_t* switch_container = lv_obj_create(wrapper);
lv_obj_set_width(switch_container, LV_PCT(100));
lv_obj_set_height(switch_container, LV_SIZE_CONTENT);
tt_lv_obj_set_style_no_padding(switch_container);
@@ -168,7 +174,7 @@ void wifi_manage_view_create(WifiManageView* view, WifiManageBindings* bindings,
lv_obj_add_event_cb(view->enable_switch, on_enable_switch_changed, LV_EVENT_ALL, bindings);
lv_obj_set_align(view->enable_switch, LV_ALIGN_RIGHT_MID);
view->connected_ap_container = lv_obj_create(parent);
view->connected_ap_container = lv_obj_create(wrapper);
lv_obj_set_size(view->connected_ap_container, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_min_height(view->connected_ap_container, SPINNER_HEIGHT, 0);
tt_lv_obj_set_style_no_padding(view->connected_ap_container);
@@ -185,7 +191,7 @@ void wifi_manage_view_create(WifiManageView* view, WifiManageBindings* bindings,
// Networks
lv_obj_t* networks_header = lv_obj_create(parent);
lv_obj_t* networks_header = lv_obj_create(wrapper);
lv_obj_set_size(networks_header, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_min_height(networks_header, SPINNER_HEIGHT, 0);
tt_lv_obj_set_style_no_padding(networks_header);
@@ -201,7 +207,7 @@ void wifi_manage_view_create(WifiManageView* view, WifiManageBindings* bindings,
lv_obj_set_style_pad_bottom(view->scanning_spinner, 4, 0);
lv_obj_align_to(view->scanning_spinner, view->networks_label, LV_ALIGN_OUT_RIGHT_MID, 8, 0);
view->networks_list = lv_obj_create(parent);
view->networks_list = lv_obj_create(wrapper);
lv_obj_set_flex_flow(view->networks_list, LV_FLEX_FLOW_COLUMN);
lv_obj_set_width(view->networks_list, LV_PCT(100));
lv_obj_set_height(view->networks_list, LV_SIZE_CONTENT);
@@ -1,5 +1,6 @@
#pragma once
#include "app.h"
#include "lvgl.h"
#include "wifi_manage_bindings.h"
#include "wifi_manage_state.h"
@@ -18,7 +19,7 @@ typedef struct {
lv_obj_t* connected_ap_label;
} WifiManageView;
void wifi_manage_view_create(WifiManageView* view, WifiManageBindings* bindings, lv_obj_t* parent);
void wifi_manage_view_create(App app, WifiManageView* view, WifiManageBindings* bindings, lv_obj_t* parent);
void wifi_manage_view_update(WifiManageView* view, WifiManageBindings* bindings, WifiManageState* state);
#ifdef __cplusplus