- P1:list_rebuild() 在 set_item_renderer/set_item_tier 后调用 meow_listview_set_container(g_lv,1), 修正 SDK 默认 container=0(扁平满幅+分隔线)与任务要求的 MD3 圆角卡观感不一致 - P2:reader/lock/settings 桩头补接缝注释——on_create 在 meow_view_create 内运行且 activity 栈空, 非根页控件须 lazy 到 on_enter 或 push→建→pop;lock 另注明必须由自身 view on_event 消费 SWIPE, 否则左缘滑动绕过 PIN - 复验:宿主测试 46/46 PASS;交叉构建静态 MIPS32r2 ELF、-Wall -Wextra 零警告
92 lines
3.2 KiB
C
92 lines
3.2 KiB
C
/* ui/reader/reader.c — 阅读器页(ACT_READER,全屏)M3 骨架。
|
||
*
|
||
* M4 在此实现翻页/图片显示;本批只落可编译桩 + 既有接缝:
|
||
* - 书库经 mr_reader_open_dir(path) 导航进来(app.c/library.c 不改);
|
||
* - 方向状态走 logic/reader 的 mr_reader_get/set_direction(默认 RTL)。
|
||
* 绘制走 view on_draw(注册表驱动),主题切换由 app.c 的 listener invalidate 全屏重画。
|
||
*
|
||
* 接缝注意(M4):meow_view 的 on_create 在 meow_view_create 内运行(此时 activity 栈空),
|
||
* 本页是非根页——控件必须 lazy 到 on_enter 建,或照 hello demo_init 的模式
|
||
* meow_ui_activity_push(ACT_READER) → 建控件 → meow_ui_activity_pop()
|
||
* (examples/hello/ui/demo/demo.c:515-522);否则控件 owner 绑到 ACT_LIBRARY,
|
||
* 造成跨页命中/绘制泄漏(§6.1)。
|
||
*/
|
||
#include "tuku_internal.h"
|
||
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
|
||
static mr_page_ctrl g_ctrl;
|
||
static char g_dir[MR_PATH_MAX];
|
||
|
||
const char *mr_reader_dir(void)
|
||
{
|
||
return g_dir;
|
||
}
|
||
|
||
void mr_reader_open_dir(const char *path)
|
||
{
|
||
if (!path) return;
|
||
snprintf(g_dir, sizeof g_dir, "%s", path);
|
||
meow_log(MEOW_LOG_INFO, "reader open: %s", g_dir);
|
||
meow_view_page_push(ACT_READER);
|
||
}
|
||
|
||
void reader_on_tap(int x, int y)
|
||
{
|
||
(void)x; (void)y;
|
||
if (!g_ctrl.active) return;
|
||
mr_reader_set_direction(mr_reader_get_direction() == MR_DIR_RTL ? MR_DIR_LTR : MR_DIR_RTL);
|
||
meow_ui_invalidate(0, 0, meow_ui_width(), meow_ui_height());
|
||
}
|
||
|
||
static void reader_draw(meow_view *v, const meow_theme *th, void *ctx)
|
||
{
|
||
(void)v; (void)ctx;
|
||
int w = meow_ui_width();
|
||
const char *dir = g_dir[0] ? g_dir : "(no directory)";
|
||
size_t n = strlen(dir);
|
||
if (n > 64) dir += n - 64;
|
||
|
||
meow_ui_text_center(w / 2, 160, "READER", th->font_title, th->primary);
|
||
meow_ui_text_center(w / 2, 200, "(M4 will render pages here)", th->font_body,
|
||
th->onSurfaceVariant);
|
||
meow_ui_text_center(w / 2, 280, "Folder:", th->font_body, th->onSurfaceVariant);
|
||
meow_ui_text_center(w / 2, 308, dir, th->font_body, th->onSurface);
|
||
meow_ui_text_center(w / 2, 372,
|
||
mr_reader_get_direction() == MR_DIR_RTL ? "Direction: RTL" : "Direction: LTR",
|
||
th->font_body, th->onSurface);
|
||
meow_ui_text_center(w / 2, 420, "tap = toggle direction", th->font_body, th->onSurfaceVariant);
|
||
meow_ui_text_center(w / 2, 448, "left-edge swipe = back", th->font_body, th->onSurfaceVariant);
|
||
}
|
||
|
||
static void reader_page_enter(meow_view *v, void *ctx)
|
||
{
|
||
((mr_page_ctrl *)ctx)->active = 1;
|
||
v->x = 0;
|
||
v->y = 0;
|
||
v->w = meow_ui_width();
|
||
v->h = meow_ui_height();
|
||
meow_ui_set_fullscreen(1); /* app.json route.reader.fullscreen 的运行时兜底 */
|
||
meow_ui_set_page_bg(meow_theme_get()->bg);
|
||
mr_nav_report();
|
||
meow_ui_paint_full();
|
||
}
|
||
|
||
static void reader_page_leave(meow_view *v, void *ctx)
|
||
{
|
||
(void)v;
|
||
((mr_page_ctrl *)ctx)->active = 0;
|
||
meow_ui_set_fullscreen(0);
|
||
}
|
||
|
||
meow_view *reader_view_create(void)
|
||
{
|
||
static const meow_view_hooks h = {
|
||
.on_enter = reader_page_enter,
|
||
.on_leave = reader_page_leave,
|
||
.on_draw = reader_draw,
|
||
};
|
||
return meow_view_create(ACT_READER, MEOW_VIEW_ACTIVITY, &h, &g_ctrl);
|
||
}
|