feat: add DemoApp and ShutdownApp classes for interactive UI components and shutdown management

This commit is contained in:
GW_MC
2026-01-24 10:39:37 +08:00
parent 0c26d91565
commit ccae9e89da
2 changed files with 92 additions and 0 deletions

53
main/ui/apps/demo_app.h Normal file
View File

@@ -0,0 +1,53 @@
#pragma once
#include "ui/ui_app.h"
#include "ui/app_registry.h"
/**
* @brief Demo application - counter and brightness slider
*
* Demonstrates interactive UI components with touch input:
* - Counter display with increment/decrement buttons
* - Brightness slider
*/
class DemoApp : public UIApp {
public:
DemoApp() = default;
virtual ~DemoApp() = default;
esp_err_t init(lv_obj_t* container) override;
esp_err_t deinit(void) override;
std::string get_name(void) const override;
private:
// UI components
lv_obj_t* _label_header= nullptr;
lv_obj_t* _label_counter= nullptr;
lv_obj_t* _btn_increment= nullptr;
lv_obj_t* _btn_decrement= nullptr;
lv_obj_t* _slider_brightness= nullptr;
lv_obj_t* _label_slider_value= nullptr;
// State
int _counter= 0;
// Event callbacks
static void btn_increment_event_cb(lv_event_t* e);
static void btn_decrement_event_cb(lv_event_t* e);
static void slider_event_cb(lv_event_t* e);
};
/**
* @brief AppDescriptor for DemoApp
*
* Registers the demo app with the AppRegistry and provides
* icon rendering functionality.
*/
class DemoAppDescriptor : public AppDescriptor {
public:
DemoAppDescriptor();
void draw_icon(lv_obj_t* parent) override;
private:
static DemoApp* _app_instance;
};

View File

@@ -0,0 +1,39 @@
#pragma once
#include "ui/ui_app.h"
#include "ui/app_registry.h"
/**
* @brief Shutdown application - displays shutdown message
*
* Shown when the system is about to enter deep sleep or power off.
* Displays a message and optionally a spinner animation.
*/
class ShutdownApp : public UIApp {
public:
ShutdownApp(std::string message = "");
virtual ~ShutdownApp() = default;
esp_err_t init(lv_obj_t* container) override;
esp_err_t deinit(void) override;
std::string get_name(void) const override;
private:
std::string _message;
lv_obj_t* _label_message = nullptr;
};
/**
* @brief AppDescriptor for ShutdownApp
*
* Note: Shutdown app is typically not shown in the navigation bar
* as it's only used during system shutdown.
*/
class ShutdownAppDescriptor : public AppDescriptor {
public:
ShutdownAppDescriptor();
void draw_icon(lv_obj_t* parent) override;
private:
static ShutdownApp* _app_instance;
};