- 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.
86 lines
2.0 KiB
C++
86 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "lvgl.h"
|
|
#include "esp_err.h"
|
|
#include <string>
|
|
#include "ui/events.h"
|
|
#include "ui/apps/iotdis/bridge/bridge.h"
|
|
#include "ui/interaction_handler.h"
|
|
|
|
// Voice state enumeration
|
|
enum class VoiceState {
|
|
UNKNOWN,
|
|
MUTED,
|
|
UNMUTED,
|
|
ERROR
|
|
};
|
|
|
|
// Forward declarations
|
|
class InteractionHandler;
|
|
|
|
/**
|
|
* @brief Main UI for Discord app
|
|
*
|
|
* Displays:
|
|
* - Current voice state (muted/unmuted/error/unknown)
|
|
* - Large status icon
|
|
* - Status text
|
|
* - Mute toggle button
|
|
* - Error notification banner (when connection lost)
|
|
* - Settings button
|
|
* - Configuration prompt (if not configured)
|
|
*/
|
|
class MainUI {
|
|
public:
|
|
MainUI() = default;
|
|
~MainUI();
|
|
|
|
esp_err_t init(lv_obj_t* parent, InteractionHandler* interaction_handler);
|
|
esp_err_t deinit(void);
|
|
|
|
/**
|
|
* @brief Register callback for settings button clicks
|
|
* @param cb Callback function
|
|
* @param user_data User data to pass to callback
|
|
*/
|
|
esp_err_t register_on_settings_button_clicked(lv_event_cb_t cb, void* user_data);
|
|
|
|
/**
|
|
* @brief Register callback for mute button clicks
|
|
* @param cb Callback function
|
|
* @param user_data User data to pass to callback
|
|
*/
|
|
esp_err_t register_on_mute_button_clicked(lv_event_cb_t cb, void* user_data);
|
|
|
|
/**
|
|
* @brief Update status display with current voice state
|
|
* @param state Current voice state
|
|
*/
|
|
void update_status(VoiceState state);
|
|
|
|
/**
|
|
* @brief Show or hide error notification banner
|
|
* @param show true to show, false to hide
|
|
*/
|
|
void show_error_notification(bool show);
|
|
|
|
/**
|
|
* @brief Update configuration prompt visibility
|
|
* @param configured true if settings are configured
|
|
*/
|
|
void update_config_prompt(bool configured);
|
|
|
|
private:
|
|
void create_ui_(lv_obj_t* parent);
|
|
|
|
lv_obj_t* container_ = nullptr;
|
|
|
|
// UI elements
|
|
lv_obj_t* error_notification_ = nullptr;
|
|
lv_obj_t* status_icon_label_ = nullptr;
|
|
lv_obj_t* status_text_label_ = nullptr;
|
|
lv_obj_t* mute_button_ = nullptr;
|
|
lv_obj_t* settings_button_ = nullptr;
|
|
lv_obj_t* config_prompt_ = nullptr;
|
|
};
|