Skip to content

Commit

Permalink
Merge pull request #1713 from didi/feat-rn-statusbar
Browse files Browse the repository at this point in the history
feat: 适配Android自定义导航
  • Loading branch information
hiyuki authored Nov 22, 2024
2 parents 6e549b0 + 2a72f25 commit 4f7a0d1
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/core/src/platform/patch/react/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,24 +447,20 @@ 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')
ReactNative.StatusBar.setTranslucent(isCustom) // 控制statusbar是否占位
const color = isCustom ? 'transparent' : pageConfig.statusBarColor
color && ReactNative.StatusBar.setBackgroundColor(color)
}
}, [])

const rootRef = useRef(null)
Expand Down

0 comments on commit 4f7a0d1

Please sign in to comment.