-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
支持提前向screen注入页面配置&stack的layout计算更新 #1910
Conversation
@@ -586,7 +591,6 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { | |||
}) | |||
usePageStatus(navigation, currentPageId) | |||
useLayoutEffect(() => { | |||
const isCustom = pageConfig.navigationStyle === 'custom' | |||
navigation.setOptions({ | |||
headerShown: !isCustom, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headerShown不用再设置
@@ -577,6 +579,9 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { | |||
if (type === 'page') { | |||
const { PortalHost, useSafeAreaInsets, GestureHandlerRootView, useHeaderHeight } = global.__navigationHelper | |||
const pageConfig = Object.assign({}, global.__mpxPageConfig, currentInject.pageConfig) | |||
const isCustom = pageConfig.navigationStyle === 'custom' | |||
const windowDimensions = ReactNative.Dimensions.get('window') | |||
const screenDimensions = ReactNative.Dimensions.get('screen') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放在模块顶部或者放在页面生命周期内,放在这个位置执行次数多且没有意义,会上来重复执行n次
height: screenDimensions.height - bottomVirtualHeight - headerHeight | ||
} | ||
} | ||
if (__mpx_mode__ === 'android' && bottomVirtualHeight === -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
鸿蒙也需要把,判断!==ios
setTimeout(() => { | ||
const headerHeight = useHeaderHeight() | ||
const onLayout = () => { | ||
if (bottomVirtualHeight !== -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
走mode来判断,不需要搞-1这个特殊值
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
判断-1主要是因为第一次推算出来底部高度,后面路由切换的时候进行固定计算,所以需要有个标识,不想添加一个额外的标识所以加了一个-1
// 沉浸模式的计算方式 | ||
bottomVirtualHeight = screenDimensions.height - height - headerHeight | ||
// 非沉浸模式计算方式, 现在默认是全用沉浸模式,所以先不算这个 | ||
// bottomVirtualHeight = windowDimensions.height - height - headerHeight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥不加?
@@ -652,7 +675,8 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { | |||
flex: 1, | |||
backgroundColor: pageConfig.backgroundColor || '#ffffff' | |||
}, | |||
ref: rootRef | |||
ref: rootRef, | |||
onLayout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确定一下键盘弹起时是不是会触发onLayout
configObj[key] = this.jsonObj[key] | ||
} | ||
}) | ||
if (Object.keys(configObj).length) mpx.pageConfigMap[pagePath] = configObj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用isEmptyObject
packages/webpack-plugin/lib/index.js
Outdated
if (isRuntime) { | ||
source.add('// inject pageconfigmap for screen\n' + | ||
'var context = (function() { return this })() || Function("return this")();\n') | ||
source.add(`context.pageConfigMap = ${JSON.stringify(mpx.pageConfigMap)};\n`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改为context.__mpxPageConfigsMap
packages/webpack-plugin/lib/index.js
Outdated
@@ -656,6 +660,8 @@ class MpxWebpackPlugin { | |||
__vfs, | |||
// app信息,便于获取appName | |||
appInfo: {}, | |||
// pageConfig信息 | |||
pageConfigMap: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageConfigsMap
if (!jsonContent) { | ||
return callback() | ||
} | ||
try { | ||
jsonObj = JSON5.parse(jsonContent) | ||
if (isPage) { | ||
loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordPageConfigMapDependency(parseRequest(loaderContext.resource)?.resourcePath, jsonObj)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放到runRules转换完成后再记录
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以及记录的时候就选取有效信息,没有必要全量记录
No description provided.