From a18d10d3accbaa05a26b7c6238439d5e5cfa9980 Mon Sep 17 00:00:00 2001 From: zhuzhh Date: Thu, 21 Nov 2024 20:24:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8DAndroid=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../patch/react/getDefaultOptions.ios.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js index 2ccee98d8..3f4371554 100644 --- a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js +++ b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js @@ -447,24 +447,19 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { useLayoutEffect(() => { const isCustom = pageConfig.navigationStyle === 'custom' - const opt = {} - if (__mpx_mode__ === 'android') { - // opt = { - // statusBarTranslucent: isCustom, - // statusBarStyle: pageConfig.statusBarStyle, // 枚举值 'auto' | 'dark' | 'light' 控制statusbar字体颜色 - // statusBarColor: isCustom ? 'transparent' : pageConfig.statusBarColor // 控制statusbar背景颜色 - // } - } navigation.setOptions({ headerShown: !isCustom, title: pageConfig.navigationBarTitleText || '', headerStyle: { backgroundColor: pageConfig.navigationBarBackgroundColor || '#000000' }, - // headerTitleAlign: 'center', - headerTintColor: pageConfig.navigationBarTextStyle || 'white', - ...opt + headerTintColor: pageConfig.navigationBarTextStyle || 'white' }) + if (__mpx_mode__ === 'android') { + ReactNative.StatusBar.setBarStyle(pageConfig.barStyle || 'dark-content') // 控制statusbar背景颜色 + ReactNative.StatusBar.setTranslucent(isCustom) // 控制statusbar是否占位 + ReactNative.StatusBar.setBackgroundColor(isCustom ? 'transparent' : pageConfig.statusBarColor) // 控制statusbar背景颜色 + } }, []) const rootRef = useRef(null) From d41a8aa687e106b42b619f48da29a6582b123074 Mon Sep 17 00:00:00 2001 From: zhuzhh Date: Fri, 22 Nov 2024 11:45:22 +0800 Subject: [PATCH 2/3] feat: fix setBackgroundColor waring --- .../core/src/platform/patch/react/getDefaultOptions.ios.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js index 3f4371554..28bee5fa9 100644 --- a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js +++ b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js @@ -458,7 +458,8 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { if (__mpx_mode__ === 'android') { ReactNative.StatusBar.setBarStyle(pageConfig.barStyle || 'dark-content') // 控制statusbar背景颜色 ReactNative.StatusBar.setTranslucent(isCustom) // 控制statusbar是否占位 - ReactNative.StatusBar.setBackgroundColor(isCustom ? 'transparent' : pageConfig.statusBarColor) // 控制statusbar背景颜色 + const color = isCustom ? 'transparent' : pageConfig.statusBarColor + color && ReactNative.StatusBar.setBackgroundColor(color) // 控制statusbar背景颜色 } }, []) From 2a72f25c182d86e5673491af7d185b5b76d882e9 Mon Sep 17 00:00:00 2001 From: zhuzhh Date: Fri, 22 Nov 2024 11:47:52 +0800 Subject: [PATCH 3/3] feat: fix code --- .../core/src/platform/patch/react/getDefaultOptions.ios.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js index 28bee5fa9..02e42f597 100644 --- a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js +++ b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js @@ -456,10 +456,10 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { headerTintColor: pageConfig.navigationBarTextStyle || 'white' }) if (__mpx_mode__ === 'android') { - ReactNative.StatusBar.setBarStyle(pageConfig.barStyle || 'dark-content') // 控制statusbar背景颜色 + ReactNative.StatusBar.setBarStyle(pageConfig.barStyle || 'dark-content') ReactNative.StatusBar.setTranslucent(isCustom) // 控制statusbar是否占位 const color = isCustom ? 'transparent' : pageConfig.statusBarColor - color && ReactNative.StatusBar.setBackgroundColor(color) // 控制statusbar背景颜色 + color && ReactNative.StatusBar.setBackgroundColor(color) } }, [])