Skip to content

Commit

Permalink
fix: 支持ios用nativestack&android用stack
Browse files Browse the repository at this point in the history
  • Loading branch information
human committed Jan 13, 2025
1 parent 7ecaa3d commit e186b2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/core/src/platform/createApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,23 @@ export default function createApp (options) {

const { initialRouteName, initialParams } = initialRouteRef.current
const headerBackImageProps = Mpx.config.rnConfig.headerBackImageProps || null
const headerBackImageSource = Mpx.config.rnConfig.headerBackImageSource || null
const navScreenOpts = {
// 7.x替换headerBackTitleVisible
// headerBackButtonDisplayMode: 'minimal',
headerBackTitleVisible: false,
// 安卓上会出现初始化时闪现导航条的问题
headerShown: false
headerShown: false,
headerShadowVisible: false
}
if (headerBackImageProps) {
navScreenOpts.headerBackImage = () => {
return createElement(Image, headerBackImageProps)
}
}
if (headerBackImageSource) {
navScreenOpts.headerBackImageSource = headerBackImageSource
}
return createElement(SafeAreaProvider,
null,
createElement(NavigationContainer,
Expand Down
6 changes: 3 additions & 3 deletions packages/webpack-plugin/lib/react/processScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ module.exports = function (script, {
localPagesMap
}, callback) {
let scriptSrcMode = srcMode
const mode = loaderContext.getMpx().mode
if (script) {
scriptSrcMode = script.mode || scriptSrcMode
} else {
script = { tag: 'script' }
}

let output = '/* script */\n'
if (ctorType === 'app') {
output += `
import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPath)}
import { NavigationContainer, StackActions } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
${mode === 'ios' ? "import { createNativeStackNavigator } from '@react-navigation/native-stack'" : "import { createStackNavigator } from '@react-navigation/stack'" }
import Provider from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-provider'
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
global.__navigationHelper = {
NavigationContainer: NavigationContainer,
createStackNavigator: createNativeStackNavigator,
createStackNavigator: ${mode === 'ios' ? 'createNativeStackNavigator' : 'createStackNavigator'},
StackActions: StackActions,
GestureHandlerRootView: GestureHandlerRootView,
Provider: Provider,
Expand Down

0 comments on commit e186b2b

Please sign in to comment.