修复沉浸光感底栏与 Flutter 底栏重叠显示的问题 - #135
Merged
Merged
Conversation
MainController.useNativeTabs 由 _initHdsBar 异步赋值(需等 getDeviceInfo 走完 method channel),首帧一定是按 false 构建的,此时 Flutter 底栏已经建出来了。 为规避 ObxError 去掉了 Scaffold.bottomNavigationBar 外层的 Obx,useNativeTabs 就绪后不再有任何东西触发重建,Flutter 底栏就一直留在原生 HDS底栏下面,两条底栏同时显示(冷启动进首页即可复现,直到有别的原因触发重建——切页面、转屏——才会消失)。 - main/view.dart:initState 中的 ever 改为在 useNativeTabs 置真时 setState,与通知原生显示底栏是同一时机,两条底栏一进一出不留空档;worker 存起来在 dispose 中释放。_bottomNav 保持非响应式读取(提前返回分支不读 Rx,包 Obx 会抛 ObxError),在注释里写明重建来源,避免以后又被改回 Obx。 - 顺带补发首帧因 useNativeTabs 未就绪而跳过的显隐同步:横屏(侧栏布局)启动或就绪前已有子页面覆盖主页时,原生底栏不该跟着冒出来。 - shell_bars_observer.dart:onOrientationChanged 去掉“有子页面时直接返回”与 didPop/didRemove 里清零 _orientationHidden 的兜底——两者配合会让方向标记过期:横屏下进子页面再返回,标记被清成竖屏,原生底栏又和侧栏一起显示。现在方向变化一律记录,显隐由“路由栈深度 > 1 || 非底栏布局”统一决定。 行为变化:横屏(侧栏布局)下原生 HDS 底栏统一不显示,导航交给左侧 NavigationRail。此前只在横屏冷启动、或横屏下进子页面再返回这两条路径会漏出底栏,属于状态不一致,现统一为隐藏。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MainController.useNativeTabs 由 _initHdsBar 异步赋值(需等 getDeviceInfo 走完 method channel),首帧一定是按 false 构建的,此时 Flutter 底栏已经建出来了。 为规避 ObxError 去掉了 Scaffold.bottomNavigationBar 外层的 Obx,useNativeTabs 就绪后不再有任何东西触发重建,Flutter 底栏就一直留在原生 HDS底栏下面,两条底栏同时显示(冷启动进首页即可复现,直到有别的原因触发重建——切页面、转屏——才会消失)。
行为变化:横屏(侧栏布局)下原生 HDS 底栏统一不显示,导航交给左侧 NavigationRail。此前只在横屏冷启动、或横屏下进子页面再返回这两条路径会漏出底栏,属于状态不一致,现统一为隐藏。