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

Fix image looks cropped In the Preview page #8804

Merged
merged 14 commits into from
May 17, 2022
Merged
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
8 changes: 8 additions & 0 deletions src/styles/getModalStyles/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import getBaseModalStyles from './getBaseModalStyles';

// Overrides the value of shouldAddTopSafeAreaPadding to false
// Only apply top padding on iOS since it's the only platform using SafeAreaView
mollfpr marked this conversation as resolved.
Show resolved Hide resolved
export default (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => ({
...getBaseModalStyles(type, windowDimensions, popoverAnchorPosition, containerStyle),
shouldAddTopSafeAreaPadding: false,
AndrewGable marked this conversation as resolved.
Show resolved Hide resolved
});
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;