Skip to content

Commit

Permalink
Merge pull request #18851 from hellohublot/Fix_Modal_Border_PDF_Width
Browse files Browse the repository at this point in the history
Remove borderWidth of fullScreen smallScreen modal and modify PDF width
  • Loading branch information
MonilBhavsar authored May 16, 2023
2 parents 080f228 + c32e848 commit 46d27b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/components/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {View, FlatList} from 'react-native';
import {View, FlatList, PixelRatio} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
Expand Down Expand Up @@ -244,8 +244,8 @@ class AttachmentCarousel extends React.Component {
renderCell(props) {
// Use window width instead of layout width to address the issue in https://github.com/Expensify/App/issues/17760
// considering horizontal margin and border width in centered modal
const modalStyles = styles.centeredModalStyles(this.props.isSmallScreenWidth);
const style = [props.style, styles.h100, {width: this.props.windowWidth - (modalStyles.marginHorizontal + modalStyles.borderWidth) * 2 + 1}];
const modalStyles = styles.centeredModalStyles(this.props.isSmallScreenWidth, true);
const style = [props.style, styles.h100, {width: PixelRatio.roundToNearestPixel(this.props.windowWidth - (modalStyles.marginHorizontal + modalStyles.borderWidth) * 2)}];

return (
<View
Expand Down Expand Up @@ -289,7 +289,7 @@ class AttachmentCarousel extends React.Component {
return (
<View
style={[styles.attachmentModalArrowsContainer, styles.flex1]}
onLayout={({nativeEvent}) => this.setState({containerWidth: nativeEvent.layout.width + 1})}
onLayout={({nativeEvent}) => this.setState({containerWidth: PixelRatio.roundToNearestPixel(nativeEvent.layout.width)})}
onMouseEnter={() => !this.canUseTouchScreen && this.toggleArrowsVisibility(true)}
onMouseLeave={() => !this.canUseTouchScreen && this.toggleArrowsVisibility(false)}
>
Expand Down
3 changes: 1 addition & 2 deletions src/components/PDFView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ class PDFView extends Component {
render() {
const pdfContainerWidth = this.state.windowWidth - 100;
const pageWidthOnLargeScreen = pdfContainerWidth <= variables.pdfPageMaxWidth ? pdfContainerWidth : variables.pdfPageMaxWidth;
const pageWidth = this.props.isSmallScreenWidth ? this.state.windowWidth - 30 : pageWidthOnLargeScreen;

const pageWidth = this.props.isSmallScreenWidth ? this.state.windowWidth : pageWidthOnLargeScreen;
const outerContainerStyle = [styles.w100, styles.h100, styles.justifyContentCenter, styles.alignItemsCenter];

// If we're requesting a password then we need to hide - but still render -
Expand Down
8 changes: 4 additions & 4 deletions src/styles/getModalStyles/getBaseModalStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ 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,
const getCenteredModalStyles = (windowWidth, isSmallScreenWidth, isFullScreenWhenSmall = false) => ({
borderWidth: styles.centeredModalStyles(isSmallScreenWidth, isFullScreenWhenSmall).borderWidth,
width: isSmallScreenWidth ? '100%' : windowWidth - styles.centeredModalStyles(isSmallScreenWidth, isFullScreenWhenSmall).marginHorizontal * 2,
});

export default (type, windowDimensions, popoverAnchorPosition = {}, innerContainerStyle = {}, outerStyle = {}) => {
Expand Down Expand Up @@ -118,7 +118,7 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, innerContain
marginBottom: isSmallScreenWidth ? 0 : 20,
borderRadius: isSmallScreenWidth ? 0 : 12,
overflow: 'hidden',
...getCenteredModalStyles(windowWidth, isSmallScreenWidth),
...getCenteredModalStyles(windowWidth, isSmallScreenWidth, true),
};
swipeDirection = undefined;
animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn';
Expand Down
4 changes: 2 additions & 2 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1979,8 +1979,8 @@ const styles = {
backgroundColor: themeColors.modalBackdrop,
},

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

Expand Down

0 comments on commit 46d27b8

Please sign in to comment.