@@ -36,7 +36,7 @@ const { useSafeAreaInsets } = global.__navigationHelper
36
36
function PageWrapper ( {
37
37
children,
38
38
navigation,
39
- pageConfig = { } ,
39
+ pageConfig,
40
40
route,
41
41
pageStatusMap
42
42
} ) {
@@ -47,37 +47,41 @@ function PageWrapper ({
47
47
navigation,
48
48
pageId
49
49
} )
50
- console . log ( 'route_____ 测试 route' , route , navigation )
51
50
const currentPageId = useMemo ( ( ) => ++ pageId , [ ] )
52
- usePageStatus ( navigation , currentPageId , pageStatusMap )
53
- useLayoutEffect ( ( ) => {
54
- const isCustom = pageConfig . navigationStyle === 'custom'
55
- navigation . setOptions ( {
56
- headerShown : ! isCustom ,
57
- title : pageConfig . navigationBarTitleText ?. trim ( ) || '' ,
58
- headerStyle : {
59
- backgroundColor : pageConfig . navigationBarBackgroundColor || '#000000'
60
- } ,
61
- headerTintColor : pageConfig . navigationBarTextStyle || 'white'
62
- } )
63
51
64
- if ( __mpx_mode__ === 'android' ) {
65
- ReactNative . StatusBar . setBarStyle ( pageConfig . barStyle || 'dark-content' )
66
- ReactNative . StatusBar . setTranslucent ( isCustom ) // 控制statusbar是否占位
67
- const color = isCustom ? 'transparent' : pageConfig . statusBarColor
68
- color && ReactNative . StatusBar . setBackgroundColor ( color )
52
+ if ( navigation ) {
53
+ usePageStatus ( navigation , currentPageId , pageStatusMap )
54
+ if ( pageConfig ) {
55
+ useLayoutEffect ( ( ) => {
56
+ const isCustom = pageConfig . navigationStyle === 'custom'
57
+ navigation . setOptions ( {
58
+ headerShown : ! isCustom ,
59
+ title : pageConfig . navigationBarTitleText ?. trim ( ) || '' ,
60
+ headerStyle : {
61
+ backgroundColor : pageConfig . navigationBarBackgroundColor || '#000000'
62
+ } ,
63
+ headerTintColor : pageConfig . navigationBarTextStyle || 'white'
64
+ } )
65
+
66
+ if ( __mpx_mode__ === 'android' ) {
67
+ ReactNative . StatusBar . setBarStyle ( pageConfig . barStyle || 'dark-content' )
68
+ ReactNative . StatusBar . setTranslucent ( isCustom ) // 控制statusbar是否占位
69
+ const color = isCustom ? 'transparent' : pageConfig . statusBarColor
70
+ color && ReactNative . StatusBar . setBackgroundColor ( color )
71
+ }
72
+ } , [ ] )
69
73
}
70
- } , [ ] )
71
-
72
- useEffect ( ( ) => {
73
- setTimeout ( ( ) => {
74
- rootRef . current ?. measureInWindow ( ( x , y , width , height ) => {
75
- navigation . layout = { x , y , width , height }
76
- } )
77
- } , 100 )
78
- } , [ ] )
79
-
80
- navigation . insets = useSafeAreaInsets ( )
74
+
75
+ useEffect ( ( ) => {
76
+ setTimeout ( ( ) => {
77
+ rootRef . current ?. measureInWindow ( ( x , y , width , height ) => {
78
+ navigation . layout = { x, y, width, height }
79
+ } )
80
+ } , 100 )
81
+ } , [ ] )
82
+ navigation . insets = useSafeAreaInsets ( )
83
+ }
84
+
81
85
82
86
const withKeyboardAvoidingView = ( element ) => {
83
87
return createElement ( KeyboardAvoidContext . Provider ,
@@ -101,7 +105,7 @@ function PageWrapper ({
101
105
return createElement ( GestureHandlerRootView ,
102
106
{
103
107
// https://github.com/software-mansion/react-native-reanimated/issues/6639 因存在此问题,iOS在页面上进行定宽来暂时规避
104
- style : __mpx_mode__ === 'ios' && pageConfig . navigationStyle !== 'custom'
108
+ style : __mpx_mode__ === 'ios' && pageConfig ? .navigationStyle !== 'custom'
105
109
? {
106
110
height : ReactNative . Dimensions . get ( 'screen' ) . height - useHeaderHeight ( )
107
111
}
@@ -114,7 +118,7 @@ function PageWrapper ({
114
118
{
115
119
style : {
116
120
flex : 1 ,
117
- backgroundColor : pageConfig . backgroundColor || '#fff'
121
+ backgroundColor : pageConfig ? .backgroundColor || '#fff'
118
122
} ,
119
123
ref : rootRef
120
124
} ,
0 commit comments