-
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: Settings page: remove code preventing rendering before currentUserPersonalDetails is ready #22329
Merged
amyevans
merged 5 commits into
Expensify:main
from
kowczarz:fix/18569-settings-page-remove-code-blocking-rendering
Jul 13, 2023
Merged
Fix: Settings page: remove code preventing rendering before currentUserPersonalDetails is ready #22329
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eb30bbd
Prevent rendering personal details before data loaded
kowczarz 376f44b
Add personal detail skeleton view
kowczarz 87ced9c
Fix skeleton height on mobile devices
kowczarz 077f950
Fix lint issues
kowczarz 1529447
Code review changes
kowczarz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/components/CurrentUserPersonalDetailsSkeletonView/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import SkeletonViewContentLoader from 'react-content-loader/native'; | ||
import {Circle, Rect} from 'react-native-svg'; | ||
import {View} from 'react-native'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import CONST from '../../CONST'; | ||
import themeColors from '../../styles/themes/default'; | ||
import variables from '../../styles/variables'; | ||
import styles from '../../styles/styles'; | ||
|
||
const propTypes = { | ||
/** Whether to animate the skeleton view */ | ||
shouldAnimate: PropTypes.bool, | ||
}; | ||
|
||
const defaultProps = { | ||
shouldAnimate: true, | ||
}; | ||
|
||
function CurrentUserPersonalDetailsSkeletonView(props) { | ||
const avatarPlaceholderSize = StyleUtils.getAvatarSize(CONST.AVATAR_SIZE.LARGE); | ||
const avatarPlaceholderRadius = avatarPlaceholderSize / 2; | ||
const spaceBetweenAvatarAndHeadline = styles.mb3.marginBottom + styles.mt1.marginTop + (variables.lineHeightXXLarge - variables.fontSizeXLarge) / 2; | ||
const headlineSize = variables.fontSizeXLarge; | ||
const spaceBetweenHeadlineAndLabel = styles.mt1.marginTop + (variables.lineHeightXXLarge - variables.fontSizeXLarge) / 2; | ||
const labelSize = variables.fontSizeLabel; | ||
return ( | ||
<View style={styles.avatarSectionWrapperSkeleton}> | ||
<SkeletonViewContentLoader | ||
animate={props.shouldAnimate} | ||
backgroundColor={themeColors.highlightBG} | ||
foregroundColor={themeColors.border} | ||
height={avatarPlaceholderSize + spaceBetweenAvatarAndHeadline + headlineSize + spaceBetweenHeadlineAndLabel + labelSize} | ||
> | ||
<Circle | ||
cx="50%" | ||
cy={avatarPlaceholderRadius} | ||
r={avatarPlaceholderRadius} | ||
/> | ||
<Rect | ||
x="20%" | ||
y={avatarPlaceholderSize + spaceBetweenAvatarAndHeadline} | ||
width="60%" | ||
height={headlineSize} | ||
/> | ||
<Rect | ||
x="15%" | ||
y={avatarPlaceholderSize + spaceBetweenAvatarAndHeadline + headlineSize + spaceBetweenHeadlineAndLabel} | ||
width="70%" | ||
height={labelSize} | ||
/> | ||
</SkeletonViewContentLoader> | ||
</View> | ||
); | ||
} | ||
|
||
CurrentUserPersonalDetailsSkeletonView.displayName = 'CurrentUserPersonalDetailsSkeletonView'; | ||
CurrentUserPersonalDetailsSkeletonView.propTypes = propTypes; | ||
CurrentUserPersonalDetailsSkeletonView.defaultProps = defaultProps; | ||
export default CurrentUserPersonalDetailsSkeletonView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
desktop.mov
There's a little height difference because height of TextView is actually lineHeight, not fontSize.
The correct height should be
variables.lineHeightXXLarge
.But according to #18569 (comment), I am not too much concerned about this inconsistency and this is not a blocker.
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 there's enough of a height difference that we should address it.
The skeleton has a height of 155:

And once loaded it's 162:

Furthermore,
const headlineMarginTop = 16;
andconst labelMarginTop = 4;
are kind of "magic" numbers at the moment and could get out of sync if we were to change the styles of the real components.I think it'd be better to replace these 2 with something more precise, e.g. instead of
headlineMarginTop
, do something like:and then similarly for
labelMarginTop
, with some comments explaining the calculations.Thoughts?
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.
The reason why I didn't persist to fix this because we don't know exact height of TextView when
lineHeight
is not set.fontSize
itself cannot determine the height. i.e.textLabelSupporting
. Dynamic calculation (i.e. onLayout callback) is the only way. Or setlineHeight
for this purpose, which will change design.I also thought about that but that code feels like unused pattern in our codebase. But I don't see any harm with this and so agree with suggestion.