Files
FruitServer/docs/plans/2026-10-21-K86.21-composer-stable-inset.md

47 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# K86.21 评论输入浮层稳定定位实施计划
## 目标
修复 Android 收起评论输入键盘时,输入浮层因键盘收起动画中的瞬时 inset 被逐帧 `max` 抬高而向上跳动的问题。评论列表面板、输入内容和关闭规则保持不变。
## 根因
- `CommentComposerSheet.build` 每次重建都用 `math.max` 累积当前 effective keyboard inset。
- IME 收起动画期间可能出现高于稳定值的瞬时 inset,累计后永久抬高 `_pinnedKeyboardInset`。
- 面板布局随后按更高的 pinned 值重新定位,造成输入浮层向上跳一小段。
## 范围
- ReelShort `lib/pages/player/widgets/comment_composer_sheet.dart`
- ReelShort `test/comment/drama_comments_sheet_test.dart`
- FruitServer `docs/plans/PROGRESS.md`
## 实现计划
1. 移除 `build` 中逐帧更新 `_pinnedKeyboardInset` 的逻辑,新增键盘可见状态和 80ms 稳定捕获 Timer。
2. effective inset 从 0 变为正数时启动 Timer;Timer 触发时只读取一次当前 inset,并取整后写入 pinned。
3. 键盘持续可见期间,后续 inset 变大或变小都不更新 pinned;inset 归零只取消 Timer 并重置可见状态,下一次弹起可重新捕获。
4. pinned 上限为屏幕高度的 60%;非有限值、负值或超过上限的异常值忽略,保证 pinned 不小于 0。
5. 保持 `Positioned(bottom: 0)`、白色 Material 铺到屏幕底部及 `Padding(bottom: pinned)` 布局,不使用位移或回落动画。
6. 返回键/IME 下箭头只收键盘;透明外部点击和发表成功仍为关闭入口。
## 测试计划
- 先新增失败测试:2200 高视口模拟 `0 → 1100(稳定)→ 1150(收起瞬时峰值)→ 600 → 0`,断言 1100 捕获后输入浮层 top、bottom、高度均保持不变。
- 运行旧实现确认红灯,记录实际偏移。
- 新实现后运行定向测试、完整评论面板测试文件、`dart analyze lib test` 和全量 `flutter test --no-pub`。
## 风险与处理
- 80ms 可能早于极慢 IME 动画结束;按任务要求采用固定稳定窗口,不在后续可见阶段继续累计。
- 超过屏幕 60% 的异常值被忽略后,需等下一次 0 → 正数弹起再捕获,避免错误定位。
- Timer 在 dispose 时取消,避免 Overlay 关闭后回调访问已卸载 State。
## Git
- ReelShort 从 `develop` 创建 `fix/composer-stable-inset`。
- 提交:`fix(player): 固定评论输入浮层位置避免收键盘跳动`。
- 作者:`Zhou Weidong <502333560@qq.com>`。
- `--no-ff` 合回 `develop` 并 push,不使用 force push,不执行 `git add -A`。
- FruitServer 追加 PROGRESS 留痕;不安装真机,完成后等待用户验收。