- 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.
60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "ui/apps/app.h"
|
|
#include <map>
|
|
#include <string>
|
|
#include "esp_log.h"
|
|
#include <memory>
|
|
|
|
class AppRegistry {
|
|
public:
|
|
static AppRegistry& instance() {
|
|
static AppRegistry registry;
|
|
return registry;
|
|
}
|
|
|
|
/**
|
|
* @brief Initialize the app registry with built-in apps
|
|
*
|
|
*/
|
|
esp_err_t init(void);
|
|
|
|
void register_app(std::unique_ptr<AppDescriptor> app_descriptor) {
|
|
if (app_descriptors_.find(app_descriptor->get_name()) != app_descriptors_.end()) {
|
|
// App already registered
|
|
ESP_LOGW("AppRegistry", "App '%s' is already registered", app_descriptor->get_name().c_str());
|
|
return;
|
|
}
|
|
app_descriptors_.emplace(app_descriptor->get_name(), std::move(app_descriptor));
|
|
}
|
|
|
|
size_t size() const {
|
|
return app_descriptors_.size();
|
|
}
|
|
|
|
// iterators to access registered apps
|
|
auto begin() { return app_descriptors_.begin(); }
|
|
auto begin() const { return app_descriptors_.begin(); }
|
|
auto end() { return app_descriptors_.end(); }
|
|
auto end() const { return app_descriptors_.end(); }
|
|
|
|
// [] operator to get app by name
|
|
AppDescriptor* operator[](const std::string& name) {
|
|
auto it = app_descriptors_.find(name);
|
|
if (it != app_descriptors_.end()) {
|
|
return it->second.get();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
private:
|
|
std::map<std::string, std::unique_ptr<AppDescriptor>> app_descriptors_ = {};
|
|
|
|
AppRegistry() = default;
|
|
// Disable copy and move semantics
|
|
AppRegistry(const AppRegistry&) = delete;
|
|
AppRegistry& operator=(const AppRegistry&) = delete;
|
|
AppRegistry(AppRegistry&&) = delete;
|
|
AppRegistry& operator=(AppRegistry&&) = delete;
|
|
};
|