Repository navigation
适配iphone duo - #2596
适配iphone duo#2596
Conversation
| bottom: screenHeight - bottom, | ||
| height: screenHeight - top - bottom, | ||
| width: screenWidth - left - right | ||
| bottom: fallbackWindowHeight - bottom, |
There was a problem hiding this comment.
[P1] 请同步修改 PopupBase 的底部安全区计算。这里将 safeArea.bottom 改成基于窗口高度,但 packages/webpack-plugin/lib/runtime/components/react/mpx-popup/popupBase.tsx:19 仍通过 screenHeight - safeArea.bottom 计算 paddingBottom,mpx-picker 正在复用该容器。当 iOS 屏幕高度为 844、窗口高度为 600、bottom inset 为 34 时,safeArea.bottom 为 566,PopupBase 的底部 padding 就会变成 278,而不是 34,导致 Picker 弹层出现大块底部空白。本 PR 已调整 ActionSheet 的同类计算,PopupBase 也需要同步使用实际的底部 inset。
| const initialWindowMetricsInset = initialWindowMetrics?.insets || {} | ||
| const navigationInsets = navigation.insets || {} | ||
| const insets = Object.assign({}, initialWindowMetricsInset, navigationInsets) | ||
| const bottom = insets.bottom |
There was a problem hiding this comment.
[P2] 请为 bottom 保留 0 兜底。模块加载时若 initialWindowMetrics 为 null,且页面 navigation 尚未初始化,两处 insets 都会回退为 {},这里的 bottom 就是 undefined,后续 paddingBottom: bottom + 10 和弹出动画的 height 都会变成 NaN。原实现通过 getWindowInfo() 中的默认值将 bottom 兜底为 0;这里至少应使用 insets.bottom ?? 0。
| let isLoadingShow | ||
| const dimensionsScreen = Dimensions.get('screen') | ||
| const screenHeight = dimensionsScreen.height | ||
| const dimensionsWindow = Dimensions.get('window') |
There was a problem hiding this comment.
[P2] 窗口尺寸不能只在模块加载时读取一次。这里的 dimensionsWindow、screenHeight、contentTop 及 toastContent.marginTop 都是模块级常量,旋转屏幕或调整窗口大小后不会重新计算;即使关闭后再次调用 showToast,仍按首次加载时的高度定位,可能导致 Toast 偏移,窗口缩小时甚至超出可视区域。原先缓存 screen 尺寸也存在旋转问题,本次窗口适配仍未解决动态尺寸变化。建议将 Toast 内容抽成组件,通过 useWindowDimensions() 获取当前高度并生成动态样式,使正在展示的 Toast 也能响应窗口变化。
| const navigation = getFocusedNavigation() || {} | ||
| const initialWindowMetricsInset = initialWindowMetrics?.insets || {} | ||
| const navigationInsets = navigation.insets || {} | ||
| const insets = Object.assign({}, initialWindowMetricsInset, navigationInsets) |
There was a problem hiding this comment.
[P2] 请在展示或渲染 ActionSheet 时获取当前安全区,避免模块级缓存。这里的 navigation、navigationInsets、insets 和 bottom 仅在模块首次加载时计算;initialWindowMetrics 又只是启动快照。旋转屏幕后 bottom inset 可能变化,但按钮的 paddingBottom 和 showActionSheet 中计算的动画 height 都会一直使用旧值;模块加载时若还没有 navigation,后续也不会改用页面的实时 insets。建议在 ActionSheet 组件中使用 useSafeAreaInsets(),同步更新底部样式与动画高度计算。
(cherry picked from commit 3bdecb3)
No description provided.