|
@@ -12,6 +12,7 @@ import UNIcon from '../../../../../assets/icons/un_icon.svg';
|
|
|
import NMIcon from '../../../../../assets/icons/nm_icon.svg';
|
|
|
import { getOnlineStatus } from 'src/storage';
|
|
|
import * as FileSystem from 'expo-file-system';
|
|
|
+import { AvatarWithInitials } from 'src/components';
|
|
|
|
|
|
type Props = {
|
|
|
avatar: string;
|
|
@@ -39,6 +40,8 @@ export const Profile: FC<Props> = ({
|
|
|
}) => {
|
|
|
const scoreNames = ['NM1301', 'DARE', 'UN', 'UN+', 'TCC', 'YES', 'SLOW', 'WHS', 'KYE'];
|
|
|
const isOnline = getOnlineStatus();
|
|
|
+ const avatarBaseUri = isOnline ? `${API_HOST}/img/avatars/` : `${FileSystem.documentDirectory}avatars/`;
|
|
|
+ const flagBaseUri = isOnline ? `${API_HOST}/img/flags_new/` : `${FileSystem.documentDirectory}flags/`;
|
|
|
|
|
|
return (
|
|
|
<>
|
|
@@ -47,10 +50,18 @@ export const Profile: FC<Props> = ({
|
|
|
<Text style={styles.rankText}>{index + 1}</Text>
|
|
|
</View>
|
|
|
<View>
|
|
|
- <Image
|
|
|
- style={{ borderRadius: 24, width: 48, height: 48 }}
|
|
|
- source={{ uri: isOnline ? API_HOST + '/img/avatars/' + avatar : '' }}
|
|
|
- />
|
|
|
+ {avatar ? (
|
|
|
+ <Image
|
|
|
+ style={{ borderRadius: 24, width: 48, height: 48 }}
|
|
|
+ source={{uri: avatarBaseUri + avatar}}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <AvatarWithInitials
|
|
|
+ text={`${first_name[0]}${last_name[0]}`}
|
|
|
+ flag={flagBaseUri + homebase_flag}
|
|
|
+ size={48}
|
|
|
+ />
|
|
|
+ )}
|
|
|
</View>
|
|
|
<View style={{ gap: 5, width: '75%' }}>
|
|
|
<Text style={[styles.headerText, { fontSize: getFontSize(14), flex: 0 }]}>
|
|
@@ -71,12 +82,12 @@ export const Profile: FC<Props> = ({
|
|
|
Age: {date_of_birth}
|
|
|
</Text>
|
|
|
<Image
|
|
|
- source={{ uri: `${FileSystem.documentDirectory}flags/${homebase_flag}` }}
|
|
|
+ source={{ uri: flagBaseUri + homebase_flag }}
|
|
|
style={styles.countryFlag}
|
|
|
/>
|
|
|
{homebase2_flag ? (
|
|
|
<Image
|
|
|
- source={{ uri: `${FileSystem.documentDirectory}flags/${homebase2_flag}` }}
|
|
|
+ source={{ uri: flagBaseUri + homebase2_flag }}
|
|
|
style={[styles.countryFlag, { marginLeft: -15 }]}
|
|
|
/>
|
|
|
) : null}
|