Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions packages/core/src/platform/createApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { createElement, memo, useRef, useEffect } from 'react'
import * as ReactNative from 'react-native'
import { initAppProvides } from './export/inject'
import { NavigationContainer, createNativeStackNavigator, SafeAreaProvider, GestureHandlerRootView } from './env/navigationHelper'
import MpxNav from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/nav'
import { NavSharedProvider } from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-nav-container'
import MpxNav from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-nav'

const appHooksMap = makeMap(mergeLifecycle(LIFECYCLE).app)

Expand Down Expand Up @@ -68,7 +67,7 @@ export default function createApp (options) {
}
},
createElement(MpxNav, {
pageConfig: pageConfig,
pageConfig,
navigation
}),
children
Expand Down Expand Up @@ -246,13 +245,13 @@ export default function createApp (options) {
onStateChange,
onUnhandledAction
},
createElement(NavSharedProvider, null, createElement(Stack.Navigator,
createElement(Stack.Navigator,
{
initialRouteName,
screenOptions: navScreenOpts
},
...getPageScreens(initialRouteName, initialParams)
))
)
)
)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/platform/patch/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
RouteContext
} from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/context'
import { PortalHost, useSafeAreaInsets } from '../env/navigationHelper'
import { useInnerHeaderHeight } from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/nav'
import { useInnerHeaderHeight } from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-nav'

const ProviderContext = createContext(null)
function getSystemInfo () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const fixComponentName = require('./fix-component-name')
const rootPortal = require('./root-portal')
const stickyHeader = require('./sticky-header')
const stickySection = require('./sticky-section')
const navContainer = require('./nav-container')

module.exports = function getComponentConfigs ({ warn, error }) {
/**
Expand Down Expand Up @@ -130,7 +129,6 @@ module.exports = function getComponentConfigs ({ warn, error }) {
component(),
rootPortal({ print }),
stickyHeader({ print }),
stickySection({ print }),
navContainer({ print })
stickySection({ print })
]
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,3 @@ export const ScrollViewContext = createContext<ScrollViewContextValue>({ gesture
export const PortalContext = createContext<PortalContextValue>(null as any)

export const StickyContext = createContext<StickyContextValue>({ registerStickyHeader: noop, unregisterStickyHeader: noop })

export const NavSharedContext = createContext<NavSharedValue>(null as any)
24 changes: 15 additions & 9 deletions packages/webpack-plugin/lib/runtime/components/react/mpx-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
setKeyboardAvoidContext()
}

if (bindfocus && keyboardAvoid?.current) {
if (bindfocus) {
const focusAction = () => {
bindfocus(
getCustomEvent(
Expand All @@ -308,24 +308,30 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
{
detail: {
value: tmpValue.current || '',
height: keyboardAvoid.current?.keyboardHeight,
height: keyboardAvoid?.current?.keyboardHeight
},
layoutRef
},
props
)
)
if (keyboardAvoid.current?.onKeyboardShow) {
if (keyboardAvoid?.current?.onKeyboardShow) {
keyboardAvoid.current.onKeyboardShow = undefined
}
}
if (keyboardAvoid.current.keyboardHeight) {
// iOS: keyboard 获取高度时机 keyboardWillShow 在 input focus 之前,可以立即执行
focusAction()
if (keyboardAvoid?.current) {
// 有 keyboardAvoiding
if (keyboardAvoid.current.keyboardHeight) {
// iOS: keyboard 获取高度时机 keyboardWillShow 在 input focus 之前,可以立即执行
focusAction()
} else {
// Android,Harmony: keyboard 获取高度时机 keyboardDidShow 在 input focus 之后,需要延迟回调
evt.persist()
keyboardAvoid.current.onKeyboardShow = focusAction
}
} else {
// Android,Harmony: keyboard 获取高度时机 keyboardDidShow 在 input focus 之后,需要延迟回调
evt.persist()
keyboardAvoid.current.onKeyboardShow = focusAction
// 无 keyboardAvoiding,直接执行 focus 回调
focusAction()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable space-before-function-paren */
import React, { ReactNode, useContext, useEffect, useRef } from 'react'
import { DimensionValue, EmitterSubscription, Keyboard, View, ViewStyle, NativeSyntheticEvent, NativeTouchEvent } from 'react-native'
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing, cancelAnimation } from 'react-native-reanimated'
Expand Down Expand Up @@ -84,16 +85,17 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
function calculateOffset() {
// enableNativeKeyboardAvoding 默认开启
if (enableNativeKeyboardAvoiding && isAndroid) {
const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
return aboveOffset > 0 ? belowValue : aboveValue;
const aboveOffset = pageY + height - endCoordinates.screenY
const belowOffset = endCoordinates.height - aboveOffset
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
const belowValue = Math.min(belowOffset, cursorSpacing)
return aboveOffset > 0 ? belowValue : aboveValue
}

const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
return aboveOffset > 0 ? belowValue : aboveValue;
const aboveOffset = offset.value + pageY + height - endCoordinates.screenY
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing)
return aboveOffset > 0 ? belowValue : aboveValue
}

cancelAnimation(offset)
Expand All @@ -104,8 +106,8 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
}
})
})
};
(isIOS ? () => (timerRef.current = setTimeout(callback)) : callback)();
}
;(isIOS ? () => (timerRef.current = setTimeout(callback)) : callback)()
}
}

Expand All @@ -117,10 +119,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
Keyboard.addListener('keyboardWillHide', resetKeyboard)
]
} else {
subscriptions = [
Keyboard.addListener('keyboardDidShow', keybaordAvoding),
Keyboard.addListener('keyboardDidHide', resetKeyboard)
]
subscriptions = [Keyboard.addListener('keyboardDidShow', keybaordAvoding), Keyboard.addListener('keyboardDidHide', resetKeyboard)]
}

return () => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable space-before-function-paren */
import { createElement, useState, useMemo, memo, useContext, useLayoutEffect } from 'react'
import { useState, useMemo, memo } from 'react'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { StatusBar, processColor, TouchableWithoutFeedback, Image, View, StyleSheet, Text } from 'react-native'
import { useNavShared } from './useNavShared'

function convertToHex(color?: string) {
try {
Expand Down Expand Up @@ -89,7 +88,6 @@ const BACK_ICON =

const MpxNav = memo(({ pageConfig, navigation }: MpxNavProps) => {
const [innerPageConfig, setPageConfig] = useState<PageConfig>(pageConfig || {})
const [customNav] = useNavShared()
const safeAreaTop = useSafeAreaInsets()?.top || 0

navigation.setPageConfig = (config: PageConfig) => {
Expand All @@ -105,13 +103,7 @@ const MpxNav = memo(({ pageConfig, navigation }: MpxNavProps) => {
barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>
)

if (isCustom)
return (
<>
{statusBarElement}
{customNav}
</>
)
if (isCustom) return statusBarElement
// 假设是栈导航,获取栈的长度
const stackLength = navigation.getState()?.routes?.length
const onStackTopBack = mpxGlobal?.__mpx?.config?.rnConfig?.onStackTopBack
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions packages/webpack-plugin/lib/utils/dom-tag-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const isBuildInWebTag = makeMap(
'mpx-swiper,mpx-view,mpx-checkbox-group,mpx-movable-area,mpx-radio-group,' +
'mpx-switch,mpx-web-view,mpx-checkbox,mpx-movable-view,mpx-radio,' +
'mpx-tab-bar-container,mpx-form,mpx-navigator,mpx-rich-text,mpx-tab-bar,' +
'mpx-icon,mpx-picker-view-column,mpx-scroll-view,mpx-text,mpx-nav-container'
'mpx-icon,mpx-picker-view-column,mpx-scroll-view,mpx-text'
)

/**
Expand All @@ -91,7 +91,7 @@ const isBuildInReactTag = makeMap(
'mpx-movable-area,mpx-label,mpx-keyboard-avoiding-view,mpx-input,mpx-inline-text,' +
'mpx-image,mpx-form,mpx-checkbox,mpx-checkbox-group,mpx-button,' +
'mpx-rich-text,mpx-portal,mpx-popup,mpx-picker-view-column,mpx-picker-view,mpx-picker,' +
'mpx-icon,mpx-canvas,mpx-nav-container'
'mpx-icon,mpx-canvas'
)

const isSpace = makeMap('ensp,emsp,nbsp')
Expand Down
1 change: 1 addition & 0 deletions packages/webpack-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"strictNullChecks": true,
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"lib": [
Expand Down
Loading