Refactor RootLayout and UIHandler for improved structure and functionality

- Updated RootLayout to manage layout initialization and deinitialization more effectively.
- Removed unnecessary dependencies and streamlined event handling for keyboard events.
- Enhanced UIHandler to utilize shared pointers for app descriptors, improving memory management.
- Added methods for showing and hiding navigation elements in RootLayout.
- Introduced textarea widget with instant response by disabling animations.
- Improved error handling and logging throughout the UI components.
This commit is contained in:
GW_MC
2026-02-01 13:03:56 +08:00
parent 237a3a96c5
commit 06e81301b2
22 changed files with 880 additions and 2198 deletions

View File

@@ -18,10 +18,7 @@
#include "display/eink_display_handler.h"
#include "display/lvgl_handler.h"
#include "ui/ui_handler.h"
#include "ui/app_registry.h"
#include "ui/apps/shutdown_app.h"
#include "ui/apps/discord_app.h"
#include "ui/apps/mtr_app.h"
#include "ui/apps/registry.h"
#include <tick/lv_tick.h>
#include "esp_lvgl_port.h"
#include "lvgl.h"
@@ -103,7 +100,7 @@ void app_main(void) {
);
ESP_LOGI(TAG, "System is ready. Starting main application...\n");
DiscordAppDescriptor::instance();
// DiscordAppDescriptor::instance();
UIHandler ui_handler;
err = ui_handler.init();
if (err != ESP_OK) {
@@ -116,61 +113,6 @@ void app_main(void) {
// Allow LVGL system to stabilize before creating objects
vTaskDelay(pdMS_TO_TICKS(100));
// Create main screen and button for random rectangle demo
// lv_obj_t* scr = lv_scr_act();
// // Create a button
// lv_obj_t* btn = lv_btn_create(scr);
// lv_obj_set_size(btn, 200, 60);
// lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, 20);
// lv_obj_set_style_border_width(btn, 2, 0);
// lv_obj_set_style_border_color(btn, lv_color_make(0, 0, 0), 0);
// // Add label to button
// lv_obj_t* label = lv_label_create(btn);
// lv_label_set_text(label, "Create Random Rect");
// lv_obj_center(label);
// lv_obj_set_style_text_color(label, lv_color_make(0, 0, 0), 0);
// // Event handler for button - creates random rectangles
// auto btn_event_cb = [](lv_event_t* e) {
// lv_obj_t* scr = lv_scr_act();
// // Create a random rectangle
// lv_obj_t* rect = lv_obj_create(scr);
// // Random size (30-100 pixels)
// lv_coord_t width = 30 + (esp_random() % 70);
// lv_coord_t height = 30 + (esp_random() % 70);
// lv_obj_set_size(rect, width, height);
// // Random position (avoid top 100px where button is)
// lv_coord_t x = esp_random() % (LV_HOR_RES - width);
// lv_coord_t y = 100 + (esp_random() % (LV_VER_RES - 100 - height));
// lv_obj_set_pos(rect, x, y);
// lv_obj_set_style_bg_color(rect, lv_color_make(0, 0, 0), 0);
// lv_obj_set_style_bg_opa(rect, LV_OPA_COVER, 0);
// // Make rectangle clickable
// lv_obj_add_flag(rect, LV_OBJ_FLAG_CLICKABLE);
// // Event handler to delete rectangle when clicked
// auto rect_event_cb = [](lv_event_t* e) {
// lv_obj_t* rect = static_cast<lv_obj_t*>(lv_event_get_target(e));
// lv_obj_del(rect);
// ESP_LOGI(TAG, "Rectangle deleted");
// };
// lv_obj_add_event_cb(rect, rect_event_cb, LV_EVENT_CLICKED, NULL);
// ESP_LOGI(TAG, "Created rectangle at (%d, %d) with size %dx%d", x, y, width, height);
// };
// lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL);
// ESP_LOGI(TAG, "Random rectangle demo initialized. Tap button to create rectangles.\n");
// wait for shutdown signal
ESP_LOGI(TAG, "Waiting for shutdown signal...\n");
EventBits_t bits = xEventGroupWaitBits(