From 9b8592e277c0169dab9dd3b3787891748c21ef9c Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 11 Dec 2024 07:28:05 +0800 Subject: [PATCH 1/3] MM-62043 fix image dimensions when iPad screen size changes --- app/utils/images/index.test.ts | 10 ++++------ app/utils/images/index.ts | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/utils/images/index.test.ts b/app/utils/images/index.test.ts index 4e3036a3d59..5c5ef68d04b 100644 --- a/app/utils/images/index.test.ts +++ b/app/utils/images/index.test.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Dimensions} from 'react-native'; +import RNUtils from '@mattermost/rnutils'; import {IMAGE_MAX_HEIGHT} from '@constants/image'; @@ -11,10 +11,8 @@ import { isGifTooLarge, } from './index'; -jest.mock('react-native', () => ({ - Dimensions: { - get: jest.fn(() => ({width: 800, height: 600})), - }, +jest.mock('@mattermost/rnutils', () => ({ + getWindowDimensions: jest.fn(() => ({width: 800, height: 600})), })); jest.mock('@constants/image', () => ({ @@ -100,7 +98,7 @@ describe('calculateDimensions', () => { describe('getViewPortWidth', () => { beforeEach(() => { - (Dimensions.get as jest.Mock).mockReturnValue({width: 800, height: 600}); + (RNUtils.getWindowDimensions as jest.Mock).mockReturnValue({width: 800, height: 600}); }); it('should calculate viewport width for normal post', () => { diff --git a/app/utils/images/index.ts b/app/utils/images/index.ts index 1f2faa4efe6..8d639085f75 100644 --- a/app/utils/images/index.ts +++ b/app/utils/images/index.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Dimensions} from 'react-native'; +import RNUtils from '@mattermost/rnutils'; import {View} from '@constants'; import { @@ -55,7 +55,7 @@ export const calculateDimensions = (height?: number, width?: number, viewPortWid }; export function getViewPortWidth(isReplyPost: boolean, tabletOffset = false, imageAttachmentOffset = false) { - const {width, height} = Dimensions.get('window'); + const {width, height} = RNUtils.getWindowDimensions(); let portraitPostWidth = Math.min(width, height) - VIEWPORT_IMAGE_OFFSET; if (tabletOffset) { From 621ebe068bb41fb69d84486d652194792f585b46 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 11 Dec 2024 07:36:58 +0800 Subject: [PATCH 2/3] MM-61951 fix share feedback screen layout --- app/screens/share_feedback/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/screens/share_feedback/index.tsx b/app/screens/share_feedback/index.tsx index 65a87f3e4cf..90651e3a99e 100644 --- a/app/screens/share_feedback/index.tsx +++ b/app/screens/share_feedback/index.tsx @@ -170,14 +170,14 @@ const ShareFeedback = ({ emphasis={'tertiary'} onPress={onPressNo} text={intl.formatMessage({id: 'share_feedback.button.no', defaultMessage: 'No, thanks'})} - backgroundStyle={styles.leftButton} + buttonContainerStyle={styles.leftButton} />