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
|
import React from 'react';
import {Image, StyleSheet} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import {AVATAR_DIM, AVATAR_GRADIENT_DIM, TAGGS_GRADIENT} from '../../constants';
import {AuthContext, ProfileContext} from '../../routes/';
/**
* An image component that returns the <Image> of the icon for a specific social media platform.
*/
type AvatarTitleProps = {
isProfileView: boolean;
};
const AvatarTitle: React.FC<AvatarTitleProps> = ({isProfileView}) => {
const {avatar} = isProfileView
? React.useContext(ProfileContext)
: React.useContext(AuthContext);
return (
<LinearGradient
colors={[TAGGS_GRADIENT.start, TAGGS_GRADIENT.end]}
useAngle={true}
angle={154.72}
angleCenter={{x: 0.5, y: 0.5}}
style={[styles.gradient]}>
<Image
style={styles.avatar}
source={
avatar
? {uri: avatar}
: require('../../assets/images/avatar-placeholder.png')
}
/>
</LinearGradient>
);
};
const styles = StyleSheet.create({
gradient: {
width: AVATAR_GRADIENT_DIM,
height: AVATAR_GRADIENT_DIM,
borderRadius: AVATAR_GRADIENT_DIM / 2,
justifyContent: 'center',
alignItems: 'center',
},
avatar: {
width: AVATAR_DIM,
height: AVATAR_DIM,
borderRadius: AVATAR_DIM / 2,
},
});
export default AvatarTitle;
|