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

remove extra spaces on attachment modal #12130

Merged
merged 3 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,6 @@ class AttachmentModal extends PureComponent {
? addEncryptedAuthTokenToURL(this.state.sourceURL)
: this.state.sourceURL;

// When the confirm button is visible we don't need bottom padding on the attachment view.
const attachmentViewPaddingStyles = this.props.onConfirm
? [styles.pl5, styles.pr5, styles.pt5]
: styles.p5;

const attachmentViewStyles = this.props.isSmallScreenWidth || this.props.isMediumScreenWidth
? [styles.imageModalImageCenterContainer]
: [styles.imageModalImageCenterContainer, attachmentViewPaddingStyles];

const {fileName, fileExtension} = FileUtils.splitExtensionFromFileName(this.props.originalFileName || lodashGet(this.state, 'file.name', ''));

return (
Expand Down Expand Up @@ -272,7 +263,7 @@ class AttachmentModal extends PureComponent {
/>
) : ''}
/>
<View style={attachmentViewStyles}>
<View style={styles.imageModalImageCenterContainer}>
{this.state.sourceURL && (
<AttachmentView
sourceURL={sourceURL}
Expand Down
6 changes: 6 additions & 0 deletions src/components/Modal/BaseModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class BaseModal extends PureComponent {
swipeDirection,
animationIn,
animationOut,
shouldAddTopSafeAreaMargin,
shouldAddBottomSafeAreaMargin,
shouldAddTopSafeAreaPadding,
shouldAddBottomSafeAreaPadding,
hideBackdrop,
Expand Down Expand Up @@ -128,8 +130,12 @@ class BaseModal extends PureComponent {
safeAreaPaddingBottom,
safeAreaPaddingLeft,
safeAreaPaddingRight,
shouldAddBottomSafeAreaMargin,
shouldAddTopSafeAreaMargin,
shouldAddBottomSafeAreaPadding,
shouldAddTopSafeAreaPadding,
modalContainerStyleMarginTop: modalContainerStyle.marginTop,
modalContainerStyleMarginBottom: modalContainerStyle.marginBottom,
modalContainerStylePaddingTop: modalContainerStyle.paddingTop,
modalContainerStylePaddingBottom: modalContainerStyle.paddingBottom,
});
Expand Down
6 changes: 3 additions & 3 deletions src/pages/signin/SignInPageLayout/SignInPageContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const SignInPageContent = props => (
<KeyboardAvoidingView
behavior="position"
style={[
props.isSmallScreenWidth ? styles.signInPageNarrowContentMargin : {},
!props.isMediumScreenWidth || (props.isMediumScreenWidth && props.windowHeight < variables.minHeightToShowGraphics) ? styles.signInPageWideLeftContentMargin : {},
styles.mb3,
StyleUtils.getModalPaddingStyles({
shouldAddBottomSafeAreaPadding: true,
modalContainerStylePaddingBottom: 20,
safeAreaPaddingBottom: props.insets.bottom,
}),
props.isSmallScreenWidth ? styles.signInPageNarrowContentMargin : {},
!props.isMediumScreenWidth || (props.isMediumScreenWidth && props.windowHeight < variables.minHeightToShowGraphics) ? styles.signInPageWideLeftContentMargin : {},
styles.mb3,
]}
>
<View style={[
Expand Down
6 changes: 6 additions & 0 deletions src/styles/StyleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,22 @@ function getWidthAndHeightStyle(width, height) {
* @returns {Object}
*/
function getModalPaddingStyles({
shouldAddBottomSafeAreaMargin,
shouldAddTopSafeAreaMargin,
shouldAddBottomSafeAreaPadding,
shouldAddTopSafeAreaPadding,
safeAreaPaddingTop,
safeAreaPaddingBottom,
safeAreaPaddingLeft,
safeAreaPaddingRight,
modalContainerStyleMarginTop,
modalContainerStyleMarginBottom,
modalContainerStylePaddingTop,
modalContainerStylePaddingBottom,
}) {
return {
marginTop: (modalContainerStyleMarginTop || 0) + (shouldAddTopSafeAreaMargin ? safeAreaPaddingTop : 0),
marginBottom: (modalContainerStyleMarginBottom || 0) + (shouldAddBottomSafeAreaMargin ? safeAreaPaddingBottom : 0),
paddingTop: shouldAddTopSafeAreaPadding
? (modalContainerStylePaddingTop || 0) + safeAreaPaddingTop
: modalContainerStylePaddingTop || 0,
Expand Down
16 changes: 12 additions & 4 deletions src/styles/getModalStyles/getBaseModalStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty
let animationIn;
let animationOut;
let hideBackdrop = false;
let shouldAddBottomSafeAreaMargin = false;
let shouldAddTopSafeAreaMargin = false;
let shouldAddBottomSafeAreaPadding = false;
let shouldAddTopSafeAreaPadding = false;

Expand Down Expand Up @@ -83,8 +85,10 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty
swipeDirection = ['down', 'right'];
animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn';
animationOut = isSmallScreenWidth ? 'slideOutRight' : 'fadeOut';
shouldAddTopSafeAreaPadding = true;
shouldAddBottomSafeAreaPadding = true;
shouldAddTopSafeAreaMargin = !isSmallScreenWidth;
shouldAddBottomSafeAreaMargin = !isSmallScreenWidth;
shouldAddTopSafeAreaPadding = isSmallScreenWidth;
shouldAddBottomSafeAreaPadding = false;
break;
case CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE:
// A centered modal that cannot be dismissed with a swipe.
Expand Down Expand Up @@ -115,8 +119,10 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty
swipeDirection = undefined;
animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn';
animationOut = isSmallScreenWidth ? 'slideOutRight' : 'fadeOut';
shouldAddTopSafeAreaPadding = true;
shouldAddBottomSafeAreaPadding = true;
shouldAddTopSafeAreaMargin = !isSmallScreenWidth;
shouldAddBottomSafeAreaMargin = !isSmallScreenWidth;
shouldAddTopSafeAreaPadding = isSmallScreenWidth;
shouldAddBottomSafeAreaPadding = false;
break;
case CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED:
modalStyle = {
Expand Down Expand Up @@ -217,6 +223,8 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty
animationIn,
animationOut,
hideBackdrop,
shouldAddTopSafeAreaMargin,
shouldAddBottomSafeAreaMargin,
shouldAddBottomSafeAreaPadding,
shouldAddTopSafeAreaPadding,
};
Expand Down
1 change: 1 addition & 0 deletions src/styles/getModalStyles/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ 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),
shouldAddTopSafeAreaMargin: false,
shouldAddTopSafeAreaPadding: false,
});