Skip to content
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

Merged
merged 8 commits into from
Mar 31, 2025

Conversation

thuman
Copy link
Collaborator

@thuman thuman commented Mar 21, 2025

No description provided.

@@ -586,7 +591,6 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
})
usePageStatus(navigation, currentPageId)
useLayoutEffect(() => {
const isCustom = pageConfig.navigationStyle === 'custom'
navigation.setOptions({
headerShown: !isCustom,
Copy link
Collaborator

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')
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

走mode来判断,不需要搞-1这个特殊值

Copy link
Collaborator Author

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

@hiyuki hiyuki Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用isEmptyObject

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`)
Copy link
Collaborator

@hiyuki hiyuki Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改为context.__mpxPageConfigsMap

@@ -656,6 +660,8 @@ class MpxWebpackPlugin {
__vfs,
// app信息,便于获取appName
appInfo: {},
// pageConfig信息
pageConfigMap: {},
Copy link
Collaborator

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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放到runRules转换完成后再记录

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以及记录的时候就选取有效信息,没有必要全量记录

@hiyuki hiyuki merged commit 5b13685 into master Mar 31, 2025
6 checks passed
@hiyuki hiyuki deleted the feat-human-pageconfig branch March 31, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants