- Added MainUI class for displaying voice state, status icon, and buttons. - Introduced MainUIHandler to manage UI interactions and bridge communication. - Created SettingsUI for displaying QR code and configuration instructions. - Implemented SettingsUIHandler to manage settings and web server interactions. - Developed WebHandler for handling HTTP requests for settings configuration. - Updated AppRegistry to initialize with the new Discord app descriptor. - Enhanced InteractionHandler to support keyboard interactions across app switches. - Updated UIHandler to manage app switching and rendering of app icons. - Enabled QR code support in LVGL configuration.
72 lines
2.0 KiB
C++
72 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "esp_err.h"
|
|
#include "lvgl.h"
|
|
#include "ui/events.h"
|
|
|
|
|
|
|
|
/**
|
|
* @brief Interaction Handler - manages user interactions
|
|
*
|
|
* This class is responsible for handling user inputs
|
|
* such as touch events, button presses, and gestures.
|
|
* It routes these interactions to the appropriate UI components
|
|
* or apps based on the current context. And it also handles the respective UI widgets.
|
|
*
|
|
* For example, it manages:
|
|
* Textarea focus and display of the on-screen keyboard
|
|
*/
|
|
class InteractionHandler {
|
|
public:
|
|
|
|
InteractionHandler() = default;
|
|
~InteractionHandler();
|
|
|
|
/**
|
|
* @brief Initialize the Interaction Handler
|
|
*
|
|
* Sets up necessary event listeners and state.
|
|
*
|
|
* @param parent_container Parent container for keyboard (typically the screen)
|
|
* @return ESP_OK on success, error code otherwise
|
|
*/
|
|
esp_err_t init(lv_obj_t* parent_container);
|
|
|
|
/**
|
|
* @brief Deinitialize the Interaction Handler
|
|
*
|
|
* Cleans up resources and event listeners.
|
|
*
|
|
* @return ESP_OK on success, error code otherwise
|
|
*/
|
|
esp_err_t deinit(void);
|
|
|
|
/**
|
|
* @brief Add keyboard support to a textarea widget
|
|
*
|
|
* @param text_area Pointer to the textarea lvgl object
|
|
* @return esp_err_t ESP_OK on success, error code otherwise
|
|
*/
|
|
esp_err_t register_text_area_keyboard_support(lv_obj_t* text_area);
|
|
|
|
private:
|
|
|
|
// Event handler for keyboard show/hide events
|
|
// It should be registered with event callbacks of the keyboard object
|
|
void on_keyboard_event_(lv_event_t* e);
|
|
|
|
esp_err_t show_keyboard_for_textarea_(lv_obj_t* textarea);
|
|
esp_err_t hide_keyboard_(void);
|
|
|
|
// Parent container (typically screen), reference only
|
|
lv_obj_t* parent_container_ = nullptr;
|
|
// owned keyboard object
|
|
lv_obj_t* keyboard_ = nullptr;
|
|
// Currently focused textarea, reference only
|
|
lv_obj_t* focused_textarea_ = nullptr;
|
|
|
|
InteractionHandler(const InteractionHandler&) = delete;
|
|
InteractionHandler& operator=(const InteractionHandler&) = delete;
|
|
};
|