Skip to content

api-proxy适配customDimensions - #2621

Merged
mackwang112 merged 7 commits into
fix-drn-2.10.18from
fix-drn-2.10.18-api-duo-v2
Nov 19, 2026
Merged

mackwang112 merged 7 commits into
fix-drn-2.10.18from
fix-drn-2.10.18-api-duo-v2

Conversation

@wangxiaokou

Copy link
Copy Markdown
Collaborator

No description provided.

const fallbackWindowWidth = customLayout.width || (__mpx_mode__ === 'ios' ? dimensionsWindow.width : screenWidth)
const fallbackWindowHeight = customLayout.height || (__mpx_mode__ === 'ios' ? dimensionsWindow.height : screenHeight)
const windowHeight = layoutHeight || fallbackWindowHeight
const fallbackWindowWidth = __mpx_mode__ === 'ios' ? dimensionsWindow.width : screenWidth

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

尽量不区分平台


let isLoadingShow
const styles = StyleSheet.create({
toastContent: {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

同样不抽离不区分平台。

subscription = Dimensions.addEventListener(
'change',
({ window }) => {
const dimensionsWindow = global.getDimensionsInfo?.('window') || window

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个需要测试一下如果用户是先onWindowResize的,再开始渲染组件,可能导致你这个change回调先执行,导致此时getDimensionsInfo还是旧值。

}
const ModalView = <View style={styles.modalTask}>
<View style={styles.modalContent}>
const ModalView = <View style={[styles.modalTask, { width, height }]}>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

如果改成固定高宽,应该还需要监听屏幕尺寸变化才行

let safeArea = {}
const { top = 0, left = 0, bottom = 0, right = 0 } = insets
const layout = navigation.layout || {}
const customLayout = mpx.config.rnConfig.customLayout?.() || {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

移除customLayout的话,对应customLayout的文档和unit test代码也一起移除吧

if (this.windowRect) return this.windowRect
const navigation = getFocusedNavigation() || {}
const screen = Dimensions.get('screen')
const dimensions = global.getDimensionsInfo?.()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个?.不用加,因为下面dimensions.width也没有判空dimensions,所以如果getDimensionsInfo不存在的话即使加了?.下面取值还是会报错,不如不加

function ActionSheet ({ itemColor, height, success, fail, complete, alertText, itemList }) {
function ActionSheet ({ itemColor, success, fail, complete, alertText, itemList }) {
const { bottom = 0 } = useSafeAreaInsets()
const [, setDimensionsWindow] = useState(() => global.getDimensionsInfo?.())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个没使用到Dimensions为啥要这个

const [dimensionsWindow, setDimensionsWindow] = useState(() => global.getDimensionsInfo?.())
useEffect(() => {
const resize = ({ size: { windowWidth: width, windowHeight: height } }) => {
setDimensionsWindow(prev => prev.width === width && prev.height === height ? prev : { width, height })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

不需要判断高宽是否变化,不变化不会触发onWindowResize的

@mackwang112
mackwang112 merged commit 42086d7 into fix-drn-2.10.18 Nov 19, 2026
0 of 6 checks passed
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