-
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
Conversation
src/styles/getModalStyles.js
Outdated
shouldAddTopSafeAreaPadding = true; | ||
|
||
// Only apply top padding on iOS since only iOS using SafeAreaView and the top insets is not apply | ||
shouldAddTopSafeAreaPadding = Platform.OS === 'ios'; |
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.
please use getPlatform
to compare CONST.OS
constants to compare platform.
@mollfpr cc: @AndrewGable |
Updated! I'm using |
Reviewing this now |
Everything looks good tests well. Just comment here seems incomplete to me! cc: @mollfpr @AndrewGable |
Co-authored-by: Santhoshkumar Sellavel <85645967+Santhosh-Sellavel@users.noreply.github.com>
Sorry I didn't catch this earlier in the proposal but I posted a question in our Slack channel about this PR https://expensify.slack.com/archives/C01GTK53T8Q/p1651544907690039 I thought that the specific platform checks were not allowed, but will discuss with the team and get back to you on this PR. |
|
||
export default (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => { | ||
export default ({shouldModalAddTopSafeAreaPadding = {}}) => (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => { |
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
returning true
on CONST.MODAL.MODAL_TYPE.CENTERED
, CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE
, and CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED
. For android we can specified CONST.MODAL.MODAL_TYPE.CENTERED
and CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE
no to add top padding by returning shouldAddTopSafeAreaPadding
with false
.
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.
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 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.
Suggestion 1
Could be as simple as the library name shouldAddSafeAreaPadding
where index.ios.js
returns true and index.js
returns false
. And call it from the appropriate line (as per the proposed solution).
Suggestion 2
Could be as simple as the library name shouldAddSafeAreaPadding
where
index.ios.js
index.android.js
index.js
returns
appropriate boolean value based on MODAL_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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This where shouldAddTopSafeAreaPadding
will have according to what value we want from specific platform.
src/styles/getModalStyles/index.js
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
This are the default value before refactoring.
|
||
export default getModalStyles({ | ||
shouldModalAddTopSafeAreaPadding: { | ||
[CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED]: true, |
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.
We only need to set CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED
to true
since that's the only thing that doesn't no break on android.
|
||
export default (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => { | ||
export default ({shouldModalAddTopSafeAreaPadding = {}}) => (type, windowDimensions, popoverAnchorPosition = {}, containerStyle = {}) => { |
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 shouldAddSafeAreaPadding
could be a library where computations can happen in platform-specific files.
Could be added inside the getModalStyle folder itself.
Any thoughts @AndrewGable?
I just create a function called |
@Santhosh-Sellavel - Happy to defer to you here on specific design of the platform specific design 👍 |
Hey @Santhosh-Sellavel is my latest commit correct? |
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.
getModalStyles
folder should stay in the styles folder only. @mollfpr
also, rename the existing getModalStyles.js
file to baseGetModalStyles.js
.
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.
Sorry for the back and forth @mollfpr,
Just one small suggestion, rename baseGetModalStyles
to getBaseModalStyles
,
Everything else looks good, and tests well!
@AndrewGable I'll leave it to you for the final review!
PR Reviewer Checklist
|
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.
Asking to update the comments, otherwise looks good, and tests well!
cc: @AndrewGable
Co-authored-by: Santhoshkumar Sellavel <85645967+Santhosh-Sellavel@users.noreply.github.com>
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.
Looks good, and tests well!
@AndrewGable All you!
@AndrewGable bump 👆 |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by @AndrewGable in version: 1.1.63-0 🚀
|
🚀 Deployed to staging by @AndrewGable in version: 1.1.63-0 🚀
|
🚀 Deployed to production by @AndrewGable in version: 1.1.63-2 🚀
|
This PR is partly responsible for a regression here #15288. The |
Details
ImageView
is not calculated right. UseonLayout
to get the height of view and use the height to get the correct aspect ratio of the image and the container.shouldAddTopSafeAreaPadding
only on iOS.Fixed Issues
$ #8115
Tests
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followed/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)QA Steps
Screenshots
Web
screen-recording-2022-04-28-at-001441_OPmDjIIA.mp4
Mobile Web
screen-recording-2022-04-28-at-002128_HCHQXpgR.mp4
screen-recording-2022-04-28-at-002226_lavPlAEH.mp4
Desktop
screen-recording-2022-04-28-at-002457_SGBSqGvX.mp4
iOS
screen-recording-2022-04-28-at-003039_YbCTeXb8.mp4
Android
screen-recording-2022-04-28-at-005258_PFsJEebF.mp4