From 5858bf782048afd018e1eac0f92078dee81cb2ed Mon Sep 17 00:00:00 2001 From: zhuzhh Date: Mon, 23 Dec 2024 20:11:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8DAndroid=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E6=9C=BA=E5=9E=8Bstatusbar=E7=8A=B6=E6=80=81=E8=A2=AB?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=A1=B5=E9=9D=A2=E5=BD=B1=E5=93=8D=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../patch/react/getDefaultOptions.ios.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js index 02e42f597f..89c2e070d3 100644 --- a/packages/core/src/platform/patch/react/getDefaultOptions.ios.js +++ b/packages/core/src/platform/patch/react/getDefaultOptions.ios.js @@ -343,6 +343,7 @@ function usePageStatus (navigation, pageId) { }, [navigation]) } +const pageConfigStack = [] export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { rawOptions = mergeOptions(rawOptions, type, false) const components = Object.assign({}, rawOptions.components, currentInject.getComponents()) @@ -455,12 +456,24 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { }, headerTintColor: pageConfig.navigationBarTextStyle || 'white' }) - if (__mpx_mode__ === 'android') { - ReactNative.StatusBar.setBarStyle(pageConfig.barStyle || 'dark-content') + + const setStatusBar = (config) => { + ReactNative.StatusBar.setBarStyle(config.barStyle || 'dark-content') ReactNative.StatusBar.setTranslucent(isCustom) // 控制statusbar是否占位 - const color = isCustom ? 'transparent' : pageConfig.statusBarColor + const color = isCustom ? 'transparent' : config.statusBarColor color && ReactNative.StatusBar.setBackgroundColor(color) } + if (__mpx_mode__ === 'android') { + pageConfigStack.push(pageConfig) + setStatusBar(pageConfig) + } + return () => { + if (__mpx_mode__ === 'android') { + pageConfigStack.pop() + const config = pageConfigStack[pageConfigStack.length - 1] || {} + setStatusBar(config) + } + }; }, []) const rootRef = useRef(null)