fix(mobile): 同步键盘避让与输入卡片动画 - #3945
Conversation
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
| Filename | Overview |
|---|---|
| apps/mobile/src/session/useMobileKeyboardState.ts | 扩展共享键盘状态以跟踪 iOS frame 几何、系统动画、挂载校正和浮动键盘例外。 |
| apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx | 新增跨平台避让容器,iOS 使用共享遮挡高度,Android 保留原生 KeyboardAvoidingView。 |
| apps/mobile/src/session/mobileNativeShellLayout.ts | 将内容密度阈值与输入区实际遮挡偏移分离,使绝对输入层连续跟随键盘。 |
| apps/mobile/src/session/useComposerCardTransition.ts | 让输入卡片尺寸动画遵循动效 token、减少动态效果偏好及键盘动画所有权。 |
| apps/mobile/app/sessions/[sessionId].tsx | 会话页接入共享键盘避让和动画状态,并保持消息区域与绝对输入层的职责分离。 |
| apps/mobile/app/sessions/new.tsx | 新建页接入共享避让容器,并扣除外层 SafeAreaView 已消费的底部安全区。 |
| apps/mobile/src/tests/composerKeyboard.test.tsx | 覆盖键盘改高、交互式收起、浮动键盘、跨淡化、事件去重、挂载校正、动效偏好和 Android 回退。 |
| apps/mobile/src/tests/mobileNativeShellLayout.test.ts | 增加从完整遮挡到零遮挡的输入区连续避让边界测试。 |
Sequence Diagram
sequenceDiagram
participant IOS as iOS 键盘事件
participant State as useMobileKeyboardState
participant Motion as LayoutAnimation
participant KAV as ComposerKeyboardAvoidingView
participant Card as 输入卡片与消息区域
IOS->>State: willShow / willChangeFrame / willHide
State->>State: 计算窗口底部实际遮挡
State->>Motion: 使用系统事件时序配置下一次布局
State-->>KAV: height、visible、transition
KAV-->>Card: 更新底部留白
State-->>Card: 更新尺寸与绝对定位偏移
Card->>Motion: 仅在键盘未拥有动画时配置 200ms 过渡
Reviews (1): Last reviewed commit: "fix(mobile): 同步键盘避让与输入卡片动画" | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bcf19e11d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
命中 UI 路径(apps/mobile/app/sessions/[sessionId].tsx / apps/mobile/app/sessions/new.tsx / apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx 等)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
MagicLizi
left a comment
There was a problem hiding this comment.
独立审查通过:键盘避让与输入卡片动画仅 JS/layout,不触发冷更;几何与 reduce-motion 与测试一致。无 P0/P1。
|
键盘跟着系统避让走,输入卡片也不再和键盘抢位置,手机上打字会顺很多。 |
这次改了什么
摘要
任务页和新建页的 iOS 键盘避让、输入卡片尺寸和消息区域共用键盘几何与动画时序。切换输入法、候选栏改高、交互式收起时更新底部实际遮挡,避免只监听显示/隐藏以及固定 250ms 卡片动画造成不同步。
变更类型
fix缺陷修复feat新功能refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
UI 变化
docs/design-rules/DESIGN.md§14.4 Motion & Transitions:独立尺寸变化使用motionDuration.base(200ms),iOS 键盘联动使用系统事件时序,减少动态效果开启或偏好尚未查明时不添加动画;§10 Theme System & Token Reference:沿用现有语义主题样式,Light/Dark 共用几何和动效逻辑,无新增颜色。Keyboard.scheduleLayoutAnimation配置同次布局;零时长事件直接更新,卡片不覆盖键盘动画。悬浮键盘不抬起整个页面,保留系统 cross-fade 特例并忽略过期异步查询结果。KeyboardAvoidingView与 did 事件,不叠加 iOS 底部偏移;卡片独立动画由 250ms 改为 200ms,并遵循减少动态效果偏好。怎么验证的
自动验证
手工验证
只读检查了 React Native 本地 Keyboard / KeyboardAvoidingView 与 iOS 事件桥接源码,核对事件时序、metrics 缓存更新时机、零时长动画和坐标体系;复查任务页绝对输入层与新建页 SafeAreaView 的实际布局关系。两轮独立源码复查发现的 80pt 跳变和 will/did 之间挂载残留占位问题均已修复,并加入回归测试。
未执行的验证
dash/mobile-keyboard-sync;worktree:/Users/dash/Code/Cindy/cindy-mobile-keyboard-sync。本轮未启动或接管 Metro,因此无 Metro 归属与__DEV__build label 证据。风险
风险分类
影响与回滚
提交前检查
git commit -s)