@mpxjs/core 2.10.18-beta.15 → 2.10.18-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -535,21 +535,25 @@ function getLayoutData (headerHeight) {
|
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
let
|
|
538
|
+
let hasResolvedSafeAreaTop = false
|
|
539
539
|
|
|
540
540
|
function getSafeAreaInsetsWithInitialTop (safeAreaInsets) {
|
|
541
|
-
if (ReactNative.Platform.OS
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
541
|
+
if (ReactNative.Platform.OS !== 'android' || hasResolvedSafeAreaTop) {
|
|
542
|
+
return safeAreaInsets
|
|
543
|
+
}
|
|
544
|
+
const initialTop = initialWindowMetrics?.insets?.top || 0
|
|
545
|
+
if (safeAreaInsets?.top === 0 && initialTop) {
|
|
546
|
+
// Android 初始化时 top 可能连续为 0(如红米 10 的 bottom 已更新但 top 仍为 0),此时持续兜底并保留其他 insets 的最新值。
|
|
547
|
+
// 返回新对象,避免修改 useSafeAreaInsets/context 返回的引用。
|
|
548
|
+
return {
|
|
549
|
+
...safeAreaInsets,
|
|
550
|
+
top: initialTop
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
+
if (safeAreaInsets?.top > 0 || !initialTop) {
|
|
554
|
+
// 拿到真实 top 或没有可用初始值后,后续完全使用 useSafeAreaInsets 的更新。
|
|
555
|
+
hasResolvedSafeAreaTop = true
|
|
556
|
+
}
|
|
553
557
|
return safeAreaInsets
|
|
554
558
|
}
|
|
555
559
|
|
|
@@ -601,7 +605,7 @@ export function PageWrapperHOC (WrappedComponent, pageConfig = {}) {
|
|
|
601
605
|
)
|
|
602
606
|
)
|
|
603
607
|
}
|
|
604
|
-
// Android
|
|
608
|
+
// Android 初始化期间持续兜底 safe area top,直到 useSafeAreaInsets 返回真实值。
|
|
605
609
|
navigation.insets = getSafeAreaInsetsWithInitialTop(useSafeAreaInsets())
|
|
606
610
|
return withKeyboardAvoidingView(
|
|
607
611
|
createElement(ReactNative.View,
|