-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
index.tsx
67 lines (61 loc) · 2.88 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React from 'react';
import {View} from 'react-native';
import {Circle, Rect} from 'react-native-svg';
import type {ValueOf} from 'type-fest';
import SkeletonViewContentLoader from '@components/SkeletonViewContentLoader';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import CONST from '@src/CONST';
type CurrentUserPersonalDetailsSkeletonViewProps = {
/** Whether to animate the skeleton view */
shouldAnimate?: boolean;
/** The size of the avatar */
avatarSize?: ValueOf<typeof CONST.AVATAR_SIZE>;
/** Background color of the skeleton view */
backgroundColor?: string;
/** Foreground color of the skeleton view */
foregroundColor?: string;
};
function CurrentUserPersonalDetailsSkeletonView({shouldAnimate = true, avatarSize = CONST.AVATAR_SIZE.LARGE, backgroundColor, foregroundColor}: CurrentUserPersonalDetailsSkeletonViewProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const avatarPlaceholderSize = StyleUtils.getAvatarSize(avatarSize);
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={shouldAnimate}
backgroundColor={backgroundColor ?? theme.highlightBG}
foregroundColor={foregroundColor ?? theme.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';
export default CurrentUserPersonalDetailsSkeletonView;