Repository navigation
api-proxy适配customDimensions - #2621
Merged
Merged
Conversation
mackwang112
reviewed
Nov 17, 2026
| 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 |
|
|
||
| let isLoadingShow | ||
| const styles = StyleSheet.create({ | ||
| toastContent: { |
| subscription = Dimensions.addEventListener( | ||
| 'change', | ||
| ({ window }) => { | ||
| const dimensionsWindow = global.getDimensionsInfo?.('window') || window |
Collaborator
There was a problem hiding this comment.
这个需要测试一下如果用户是先onWindowResize的,再开始渲染组件,可能导致你这个change回调先执行,导致此时getDimensionsInfo还是旧值。
| } | ||
| const ModalView = <View style={styles.modalTask}> | ||
| <View style={styles.modalContent}> | ||
| const ModalView = <View style={[styles.modalTask, { width, height }]}> |
Collaborator
There was a problem hiding this comment.
如果改成固定高宽,应该还需要监听屏幕尺寸变化才行
| let safeArea = {} | ||
| const { top = 0, left = 0, bottom = 0, right = 0 } = insets | ||
| const layout = navigation.layout || {} | ||
| const customLayout = mpx.config.rnConfig.customLayout?.() || {} |
Collaborator
There was a problem hiding this comment.
移除customLayout的话,对应customLayout的文档和unit test代码也一起移除吧
| if (this.windowRect) return this.windowRect | ||
| const navigation = getFocusedNavigation() || {} | ||
| const screen = Dimensions.get('screen') | ||
| const dimensions = global.getDimensionsInfo?.() |
Collaborator
There was a problem hiding this comment.
这个?.不用加,因为下面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?.()) |
Collaborator
There was a problem hiding this comment.
这个没使用到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 }) |
Collaborator
There was a problem hiding this comment.
不需要判断高宽是否变化,不变化不会触发onWindowResize的
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.