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 - On increasing the screen size the user can see the previous image in the list #17760 #18615

Merged
merged 9 commits into from
May 12, 2023
5 changes: 4 additions & 1 deletion src/components/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ class AttachmentCarousel extends React.Component {
* @returns {JSX.Element}
*/
renderCell(props) {
const style = [props.style, styles.h100, {width: this.state.containerWidth}];
// We are using a new style for central modals to address the issue in https://github.com/Expensify/App/issues/17760
AmjedNazzal marked this conversation as resolved.
Show resolved Hide resolved
// Keep in mind that the +1 is to keep the layout stylings the exact same to prevent regressions
AmjedNazzal marked this conversation as resolved.
Show resolved Hide resolved
const modalStyles = styles.centeredModalStyles(this.props.isSmallScreenWidth);
const style = [props.style, styles.h100, {width: this.props.windowWidth - (modalStyles.marginHorizontal + modalStyles.borderWidth) * 2 + 1}];

// eslint-disable-next-line react/jsx-props-no-spreading
return <View {...props} style={style} />;
Expand Down
13 changes: 9 additions & 4 deletions src/styles/getModalStyles/getBaseModalStyles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import CONST from '../../CONST';
import variables from '../variables';
import themeColors from '../themes/default';
import styles from '../styles';


const getCenteredModalStyles = (windowWidth, isSmallScreenWidth) => ({
borderWidth: styles.centeredModalStyles(isSmallScreenWidth).borderWidth,
width: isSmallScreenWidth ? '100%' : windowWidth - styles.centeredModalStyles(isSmallScreenWidth).marginHorizontal * 2,
});

export default (type, windowDimensions, popoverAnchorPosition = {}, innerContainerStyle = {}, outerStyle = {}) => {
const {isSmallScreenWidth, windowWidth} = windowDimensions;
Expand Down Expand Up @@ -76,9 +83,8 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, innerContain
marginTop: isSmallScreenWidth ? 0 : 20,
marginBottom: isSmallScreenWidth ? 0 : 20,
borderRadius: isSmallScreenWidth ? 0 : 12,
borderWidth: isSmallScreenWidth ? 1 : 0,
overflow: 'hidden',
width: isSmallScreenWidth ? '100%' : windowWidth - 40,
...getCenteredModalStyles(windowWidth, isSmallScreenWidth),
};

// Allow this modal to be dismissed with a swipe down or swipe right
Expand Down Expand Up @@ -112,9 +118,8 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, innerContain
marginTop: isSmallScreenWidth ? 0 : 20,
marginBottom: isSmallScreenWidth ? 0 : 20,
borderRadius: isSmallScreenWidth ? 0 : 12,
borderWidth: isSmallScreenWidth ? 1 : 0,
overflow: 'hidden',
width: isSmallScreenWidth ? '100%' : windowWidth - 40,
...getCenteredModalStyles(windowWidth, isSmallScreenWidth),
};
swipeDirection = undefined;
animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn';
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1967,6 +1967,11 @@ const styles = {
backgroundColor: themeColors.modalBackdrop,
},

centeredModalStyles: (isSmallScreenWidth) => ({
borderWidth: isSmallScreenWidth ? 1 : 0,
marginHorizontal: isSmallScreenWidth ? 0 : 20,
}),

imageModalImageCenterContainer: {
alignItems: 'center',
flex: 1,
Expand Down