feat(ui): 重构设置界面为页面控制器架构
- 添加新的UI页面基础架构(ui_page.h),包含页面操作接口 - 创建设置页面控制器(ui_settings_controller.h/.c)来管理页面导航 - 实现具体的设置页面类型:根页面、BLE页面、主题页面 - 修改display_module.c以使用新的页面系统替代旧的状态机 - 移除过时的settings_ui.h头文件和相关状态结构 - 更新事件处理逻辑以使用页面指针而非状态数据传递 - 修改主界面实现以适配统一的页面接口标准
This commit is contained in:
@@ -31,6 +31,9 @@ struct ui_main_ctx {
|
||||
|
||||
static struct ui_main_ctx g_ui;
|
||||
static bool ui_initialized;
|
||||
static const struct ui_main_model *page_model;
|
||||
static const char *page_date_text;
|
||||
static const char *page_time_text;
|
||||
|
||||
static const char *const status_texts[UI_STATUS_COUNT] = {
|
||||
LV_SYMBOL_USB,
|
||||
@@ -297,15 +300,55 @@ void ui_main_init(const struct ui_main_model *model,
|
||||
ui_initialized = true;
|
||||
}
|
||||
|
||||
void ui_main_set_visible(bool visible)
|
||||
void ui_main_deinit(void)
|
||||
{
|
||||
if (!ui_initialized || (g_ui.content == NULL)) {
|
||||
if (!ui_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
lv_obj_clear_flag(g_ui.content, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(g_ui.content, LV_OBJ_FLAG_HIDDEN);
|
||||
if (g_ui.content != NULL) {
|
||||
lv_obj_delete(g_ui.content);
|
||||
}
|
||||
|
||||
memset(&g_ui, 0, sizeof(g_ui));
|
||||
ui_initialized = false;
|
||||
}
|
||||
|
||||
static void main_page_init(struct ui_page *page)
|
||||
{
|
||||
ARG_UNUSED(page);
|
||||
ui_main_init(page_model, page_date_text, page_time_text);
|
||||
}
|
||||
|
||||
static void main_page_deinit(struct ui_page *page)
|
||||
{
|
||||
ARG_UNUSED(page);
|
||||
ui_main_deinit();
|
||||
}
|
||||
|
||||
static void main_page_refresh(struct ui_page *page)
|
||||
{
|
||||
ARG_UNUSED(page);
|
||||
ui_main_refresh_all(page_model, page_date_text, page_time_text);
|
||||
}
|
||||
|
||||
static const struct ui_page_ops main_page_ops = {
|
||||
.init = main_page_init,
|
||||
.deinit = main_page_deinit,
|
||||
.refresh = main_page_refresh,
|
||||
};
|
||||
|
||||
static struct ui_page main_page = {
|
||||
.ops = &main_page_ops,
|
||||
};
|
||||
|
||||
struct ui_page *ui_main_page_get(const struct ui_main_model *model,
|
||||
const char *date_text,
|
||||
const char *time_text)
|
||||
{
|
||||
page_model = model;
|
||||
page_date_text = date_text;
|
||||
page_time_text = time_text;
|
||||
|
||||
return &main_page;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user