feat(ui): 重构设置界面为页面控制器架构
- 添加新的UI页面基础架构(ui_page.h),包含页面操作接口 - 创建设置页面控制器(ui_settings_controller.h/.c)来管理页面导航 - 实现具体的设置页面类型:根页面、BLE页面、主题页面 - 修改display_module.c以使用新的页面系统替代旧的状态机 - 移除过时的settings_ui.h头文件和相关状态结构 - 更新事件处理逻辑以使用页面指针而非状态数据传递 - 修改主界面实现以适配统一的页面接口标准
This commit is contained in:
66
inc/ui/ui_page.h
Normal file
66
inc/ui/ui_page.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef BLINKY_UI_PAGE_H_
|
||||
#define BLINKY_UI_PAGE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ui_page;
|
||||
|
||||
struct ui_page_ops {
|
||||
void (*init)(struct ui_page *page);
|
||||
void (*deinit)(struct ui_page *page);
|
||||
void (*refresh)(struct ui_page *page);
|
||||
};
|
||||
|
||||
struct ui_page {
|
||||
const struct ui_page_ops *ops;
|
||||
struct ui_page *parent;
|
||||
bool initialized;
|
||||
};
|
||||
|
||||
static inline void ui_page_init(struct ui_page *page)
|
||||
{
|
||||
if ((page == NULL) || (page->ops == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (page->initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (page->ops->init != NULL) {
|
||||
page->ops->init(page);
|
||||
}
|
||||
page->initialized = true;
|
||||
}
|
||||
|
||||
static inline void ui_page_deinit(struct ui_page *page)
|
||||
{
|
||||
if ((page == NULL) || !page->initialized || (page->ops == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (page->ops->deinit != NULL) {
|
||||
page->ops->deinit(page);
|
||||
}
|
||||
page->initialized = false;
|
||||
}
|
||||
|
||||
static inline void ui_page_refresh(struct ui_page *page)
|
||||
{
|
||||
if ((page == NULL) || !page->initialized ||
|
||||
(page->ops == NULL) || (page->ops->refresh == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
page->ops->refresh(page);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_UI_PAGE_H_ */
|
||||
Reference in New Issue
Block a user