Skip to content

Commit

Permalink
Revert "Merge branch 'fix-drn-nativestack' into fix-drn"
Browse files Browse the repository at this point in the history
This reverts commit 03e3d38, reversing
changes made to 88f6d07.
  • Loading branch information
human committed Jan 16, 2025
1 parent 213c000 commit 0f4e216
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
7 changes: 1 addition & 6 deletions packages/core/src/platform/createApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,18 @@ 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,
headerShadowVisible: false
headerShown: false
}
if (headerBackImageProps) {
navScreenOpts.headerBackImage = () => {
return createElement(Image, headerBackImageProps)
}
}
if (headerBackImageSource) {
navScreenOpts.headerBackImageSource = headerBackImageSource
}
return createElement(SafeAreaProvider,
null,
createElement(NavigationContainer,
Expand Down
21 changes: 12 additions & 9 deletions packages/core/src/platform/patch/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,17 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
}, [])

const rootRef = useRef(null)
const onLayout = useCallback(() => {
setTimeout(() => {
rootRef.current?.measureInWindow((x, y, width, height) => {
navigation.layout = { x, y, width, height }
})
}, 200)
}, [])

useEffect(() => {
const unsubscribe = navigation.addListener('transitionEnd', (e) => {
setTimeout(() => {
rootRef.current?.measureInWindow((x, y, width, height) => {
navigation.layout = { x, y, width, height }
})
}, 200)
});
return unsubscribe;
}, [navigation]);

const withKeyboardAvoidingView = (element) => {
if (__mpx_mode__ === 'ios') {
Expand Down Expand Up @@ -585,8 +589,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
flex: 1,
backgroundColor: pageConfig.backgroundColor || '#ffffff'
},
ref: rootRef,
onLayout
ref: rootRef
},
createElement(RouteContext.Provider,
{
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'
${mode === 'ios' ? "import { createNativeStackNavigator } from '@react-navigation/native-stack'" : "import { createStackNavigator } from '@react-navigation/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: ${mode === 'ios' ? 'createNativeStackNavigator' : 'createStackNavigator'},
createStackNavigator: createStackNavigator,
StackActions: StackActions,
GestureHandlerRootView: GestureHandlerRootView,
Provider: Provider,
Expand Down

0 comments on commit 0f4e216

Please sign in to comment.