@mpxjs/core 2.10.18-beta.14 → 2.10.18-beta.15
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,6 +535,24 @@ function getLayoutData (headerHeight) {
|
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
+
let hasRenderedSafeAreaInsets = false
|
|
539
|
+
|
|
540
|
+
function getSafeAreaInsetsWithInitialTop (safeAreaInsets) {
|
|
541
|
+
if (ReactNative.Platform.OS === 'android' && !hasRenderedSafeAreaInsets) {
|
|
542
|
+
hasRenderedSafeAreaInsets = true
|
|
543
|
+
const initialTop = initialWindowMetrics?.insets?.top || 0
|
|
544
|
+
if (safeAreaInsets?.top === 0 && initialTop) {
|
|
545
|
+
// Android 首次渲染时 top 可能暂时为 0,仅全局兜底一次,后续使用 useSafeAreaInsets 的真实更新。
|
|
546
|
+
// 返回新对象,避免修改 useSafeAreaInsets/context 产出的 insets 引用。
|
|
547
|
+
return {
|
|
548
|
+
...safeAreaInsets,
|
|
549
|
+
top: initialTop
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return safeAreaInsets
|
|
554
|
+
}
|
|
555
|
+
|
|
538
556
|
export function PageWrapperHOC (WrappedComponent, pageConfig = {}) {
|
|
539
557
|
return function PageWrapperCom ({ navigation, route, ...props }) {
|
|
540
558
|
const keyboardAvoidRef = useRef(null)
|
|
@@ -583,8 +601,8 @@ export function PageWrapperHOC (WrappedComponent, pageConfig = {}) {
|
|
|
583
601
|
)
|
|
584
602
|
)
|
|
585
603
|
}
|
|
586
|
-
//
|
|
587
|
-
navigation.insets = useSafeAreaInsets()
|
|
604
|
+
// Android 全局首次渲染时对 safe area top 做兜底,避免 navigation.insets.top 短暂写入 0。
|
|
605
|
+
navigation.insets = getSafeAreaInsetsWithInitialTop(useSafeAreaInsets())
|
|
588
606
|
return withKeyboardAvoidingView(
|
|
589
607
|
createElement(ReactNative.View,
|
|
590
608
|
{
|