Skip to content

Commit

Permalink
Merge pull request #8804 from mollfpr/fix-8115
Browse files Browse the repository at this point in the history
Fix image looks cropped In the Preview page
  • Loading branch information
AndrewGable authored May 17, 2022
2 parents 101b152 + 8beeb85 commit 44326c9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/components/ImageView/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ImageView extends PureComponent {
imageWidth: undefined,
imageHeight: undefined,
interactionPromise: undefined,
containerHeight: undefined,
};

// Use the default double click interval from the ImageZoom library
Expand Down Expand Up @@ -72,7 +73,7 @@ class ImageView extends PureComponent {
let imageWidth = width;
let imageHeight = height;
const containerWidth = Math.round(this.props.windowWidth);
const containerHeight = Math.round(this.props.windowHeight - variables.contentHeaderHeight);
const containerHeight = Math.round(this.state.containerHeight);

const aspectRatio = Math.min(containerHeight / imageHeight, containerWidth / imageWidth);

Expand Down Expand Up @@ -134,6 +135,12 @@ class ImageView extends PureComponent {
styles.overflowHidden,
styles.errorOutline,
]}
onLayout={(event) => {
const layout = event.nativeEvent.layout;
this.setState({
containerHeight: layout.height,
});
}}
>
<Image
source={{uri: this.props.url}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/BaseModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import themeColors from '../../styles/themes/default';
import {propTypes as modalPropTypes, defaultProps as modalDefaultProps} from './modalPropTypes';
import getModalStyles from '../../styles/getModalStyles';
import * as Modal from '../../libs/actions/Modal';
import getModalStyles from '../../styles/getModalStyles';

const propTypes = {
...modalPropTypes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CONST from '../CONST';
import colors from './colors';
import variables from './variables';
import themeColors from './themes/default';
import CONST from '../../CONST';
import colors from '../colors';
import variables from '../variables';
import themeColors from '../themes/default';

export default (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => {
const {isSmallScreenWidth, windowWidth} = windowDimensions;
Expand Down
7 changes: 7 additions & 0 deletions src/styles/getModalStyles/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import getBaseModalStyles from './getBaseModalStyles';

// Only apply top padding on iOS since it's the only platform using SafeAreaView
export default (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => ({
...getBaseModalStyles(type, windowDimensions, popoverAnchorPosition, containerStyle),
shouldAddTopSafeAreaPadding: false,
});
3 changes: 3 additions & 0 deletions src/styles/getModalStyles/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import getBaseModalStyles from './getBaseModalStyles';

export default getBaseModalStyles;

0 comments on commit 44326c9

Please sign in to comment.