-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Changes from 7 commits
8dba8e6
1917af2
53cbcf6
ac4511e
cee6581
babaa26
cc0b570
bb8a612
c9952ee
29b0ad8
17e1d3f
ce04075
28f509e
8beeb85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
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 = {}) => { | ||
export default ({shouldModalAddTopSafeAreaPadding = {}}) => (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => { | ||
const {isSmallScreenWidth, windowWidth} = windowDimensions; | ||
|
||
let modalStyle = { | ||
|
@@ -16,7 +16,7 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty | |
let animationOut; | ||
let hideBackdrop = false; | ||
let shouldAddBottomSafeAreaPadding = false; | ||
let shouldAddTopSafeAreaPadding = false; | ||
const shouldAddTopSafeAreaPadding = shouldModalAddTopSafeAreaPadding[type] || false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This where |
||
|
||
switch (type) { | ||
case CONST.MODAL.MODAL_TYPE.CONFIRM: | ||
|
@@ -83,7 +83,6 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty | |
swipeDirection = ['down', 'right']; | ||
animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn'; | ||
animationOut = isSmallScreenWidth ? 'slideOutRight' : 'fadeOut'; | ||
shouldAddTopSafeAreaPadding = true; | ||
break; | ||
case CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE: | ||
// A centered modal that cannot be dismissed with a swipe. | ||
|
@@ -114,7 +113,6 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty | |
swipeDirection = undefined; | ||
animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn'; | ||
animationOut = isSmallScreenWidth ? 'slideOutRight' : 'fadeOut'; | ||
shouldAddTopSafeAreaPadding = true; | ||
break; | ||
case CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED: | ||
modalStyle = { | ||
|
@@ -196,7 +194,6 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, containerSty | |
}; | ||
swipeDirection = undefined; | ||
shouldAddBottomSafeAreaPadding = true; | ||
shouldAddTopSafeAreaPadding = true; | ||
break; | ||
default: | ||
modalStyle = {}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import CONST from '../../CONST'; | ||
import getModalStyles from './getModalStyles'; | ||
|
||
export default getModalStyles({ | ||
shouldModalAddTopSafeAreaPadding: { | ||
[CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED]: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only need to set |
||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import CONST from '../../CONST'; | ||
import getModalStyles from './getModalStyles'; | ||
|
||
export default getModalStyles({ | ||
shouldModalAddTopSafeAreaPadding: { | ||
[CONST.MODAL.MODAL_TYPE.CENTERED]: true, | ||
[CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE]: true, | ||
[CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED]: true, | ||
}, | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This are the default value before refactoring. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I modified the current function with a new function that accept parameters that can be determined what modal type should apply the top padding.
The previous code has
shouldAddTopSafeAreaPadding
returningtrue
onCONST.MODAL.MODAL_TYPE.CENTERED
,CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE
, andCONST.MODAL.MODAL_TYPE.RIGHT_DOCKED
. For android we can specifiedCONST.MODAL.MODAL_TYPE.CENTERED
andCONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE
no to add top padding by returningshouldAddTopSafeAreaPadding
withfalse
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @Santhosh-Sellavel @AndrewGable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mollfpr
I think
shouldAddSafeAreaPadding
could be a library where computations can happen in platform-specific files.Could be added inside the getModalStyle folder itself.
Any thoughts @AndrewGable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Santhosh-Sellavel Can you outline your suggested fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Santhosh-Sellavel Can you outline your suggested fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndrewGable
Suggestion 1
Could be as simple as the library name
shouldAddSafeAreaPadding
whereindex.ios.js
returns true andindex.js
returnsfalse
. And call it from the appropriate line (as per the proposed solution).Suggestion 2
Could be as simple as the library name
shouldAddSafeAreaPadding
whereindex.ios.js
index.android.js
index.js
returns
appropriate boolean value based onMODAL_TYPE
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think suggestion 2 will be good solution.