|
@@ -1,9 +1,15 @@
|
|
|
import React, { FC } from 'react';
|
|
|
import { Text, TouchableOpacity, View } from 'react-native';
|
|
|
import { Image } from 'expo-image';
|
|
|
+import { useNavigation } from '@react-navigation/native';
|
|
|
+import * as FileSystem from 'expo-file-system';
|
|
|
|
|
|
-import { API_HOST } from '../../../../constants';
|
|
|
import { styles } from './styles';
|
|
|
+
|
|
|
+import { getOnlineStatus } from 'src/storage';
|
|
|
+import { AvatarWithInitials } from 'src/components';
|
|
|
+
|
|
|
+import { API_HOST } from '../../../../constants';
|
|
|
import { getFontSize } from '../../../../utils';
|
|
|
import { Colors } from '../../../../theme';
|
|
|
|
|
@@ -11,10 +17,7 @@ import TickIcon from '../../../../../assets/icons/tick.svg';
|
|
|
import UNIcon from '../../../../../assets/icons/un_icon.svg';
|
|
|
import NMIcon from '../../../../../assets/icons/nm_icon.svg';
|
|
|
import TBTIcon from '../../../../../assets/icons/tbt.svg';
|
|
|
-import { getOnlineStatus } from 'src/storage';
|
|
|
-import * as FileSystem from 'expo-file-system';
|
|
|
-import { AvatarWithInitials } from 'src/components';
|
|
|
-import { useNavigation } from '@react-navigation/native';
|
|
|
+
|
|
|
import { NAVIGATION_PAGES } from '../../../../types';
|
|
|
|
|
|
type Props = {
|
|
@@ -26,6 +29,7 @@ type Props = {
|
|
|
homebase2_flag: string;
|
|
|
index: number;
|
|
|
score: any[];
|
|
|
+ active_score: number;
|
|
|
tbt_score?: number;
|
|
|
tbt_rank?: number;
|
|
|
badge_tbt?: number;
|
|
@@ -45,6 +49,7 @@ export const Profile: FC<Props> = ({
|
|
|
homebase2_flag,
|
|
|
index,
|
|
|
score,
|
|
|
+ active_score,
|
|
|
tbt_score,
|
|
|
tbt_rank,
|
|
|
badge_tbt,
|
|
@@ -55,7 +60,7 @@ export const Profile: FC<Props> = ({
|
|
|
}) => {
|
|
|
const navigation = useNavigation();
|
|
|
|
|
|
- const scoreNames = ['DARE', 'UN', 'UN+', 'TCC', 'YES', 'SLOW', 'WHS', 'KYE'];
|
|
|
+ const scoreNames = ['NM', 'DARE', 'UN', 'UN+', 'TCC', 'DEEP', 'YES', 'SLOW', 'WHS', 'KYE', 'TBT'];
|
|
|
const isOnline = getOnlineStatus();
|
|
|
const avatarBaseUri = isOnline
|
|
|
? `${API_HOST}/img/avatars/`
|
|
@@ -94,85 +99,130 @@ export const Profile: FC<Props> = ({
|
|
|
) : null;
|
|
|
};
|
|
|
|
|
|
+ const EmptyScore = () => {
|
|
|
+ return (
|
|
|
+ <View
|
|
|
+ style={{
|
|
|
+ display: 'flex',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ flexDirection: 'column',
|
|
|
+ marginBottom: 10
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Text style={[styles.scoreHeaderText, { flex: 0 }]}></Text>
|
|
|
+ <Text style={[styles.scoreNameText, { flex: 0 }]}></Text>
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
- <TouchableOpacity onPress={() => navigation.navigate(NAVIGATION_PAGES.PROFILE_TAB, { userId })}>
|
|
|
- <View style={{ alignItems: 'center', flexDirection: 'row', gap: 10, marginBottom: 5 }}>
|
|
|
- <View style={{ paddingLeft: 20 }}>
|
|
|
- <View>
|
|
|
- <Text style={styles.rankText}>{index + 1}</Text>
|
|
|
+ <View>
|
|
|
+ <TouchableOpacity
|
|
|
+ onPress={() =>
|
|
|
+ navigation.navigate(...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId }] as never))
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <View style={{ alignItems: 'center', flexDirection: 'row', gap: 10, marginBottom: 5 }}>
|
|
|
+ <View style={{ paddingLeft: 20 }}>
|
|
|
+ <View style={{ marginRight: 5 }}>
|
|
|
+ <Text style={styles.rankText}>{index + 1}</Text>
|
|
|
+ </View>
|
|
|
+ {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>
|
|
|
- {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 }]}>
|
|
|
- {first_name} {last_name}
|
|
|
- </Text>
|
|
|
- <View style={{ display: 'flex', justifyContent: 'space-between', flexDirection: 'row' }}>
|
|
|
+ <View style={{ gap: 5, width: '75%' }}>
|
|
|
+ <Text style={[styles.headerText, { fontSize: getFontSize(14), flex: 0 }]}>
|
|
|
+ {first_name ?? ''} {last_name ?? ''}
|
|
|
+ </Text>
|
|
|
<View
|
|
|
- style={{
|
|
|
- display: 'flex',
|
|
|
- flexDirection: 'row',
|
|
|
- gap: 10,
|
|
|
- alignItems: 'center'
|
|
|
- }}
|
|
|
+ style={{ display: 'flex', justifyContent: 'space-between', flexDirection: 'row' }}
|
|
|
>
|
|
|
- <Text
|
|
|
- style={{ color: Colors.DARK_BLUE, fontWeight: '600', fontSize: getFontSize(12) }}
|
|
|
+ <View
|
|
|
+ style={{
|
|
|
+ display: 'flex',
|
|
|
+ flexDirection: 'row',
|
|
|
+ gap: 10,
|
|
|
+ alignItems: 'center'
|
|
|
+ }}
|
|
|
>
|
|
|
- Age: {date_of_birth}
|
|
|
- </Text>
|
|
|
- <Image source={{ uri: flagBaseUri + homebase_flag }} style={styles.countryFlag} />
|
|
|
- {homebase2_flag && homebase2_flag !== homebase_flag ? (
|
|
|
- <Image
|
|
|
- source={{ uri: flagBaseUri + homebase2_flag }}
|
|
|
- style={[styles.countryFlag, { marginLeft: -15 }]}
|
|
|
- />
|
|
|
- ) : null}
|
|
|
- <View style={{ display: 'flex', flexDirection: 'row', gap: 3, marginLeft: 10 }}>
|
|
|
- {auth ? <TickIcon /> : null}
|
|
|
- {badge_un ? <UNIcon /> : null}
|
|
|
- {badge_1281 ? <NMIcon /> : null}
|
|
|
+ <Text
|
|
|
+ style={{ color: Colors.DARK_BLUE, fontWeight: '600', fontSize: getFontSize(12) }}
|
|
|
+ >
|
|
|
+ Age: {date_of_birth ?? ''}
|
|
|
+ </Text>
|
|
|
+ <Image source={{ uri: flagBaseUri + homebase_flag }} style={styles.countryFlag} />
|
|
|
+ {homebase2_flag && homebase2_flag !== homebase_flag ? (
|
|
|
+ <Image
|
|
|
+ source={{ uri: flagBaseUri + homebase2_flag }}
|
|
|
+ style={[styles.countryFlag, { marginLeft: -15 }]}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row', gap: 3, marginLeft: 10 }}>
|
|
|
+ {auth ? <TickIcon /> : null}
|
|
|
+ {badge_un ? <UNIcon /> : null}
|
|
|
+ {badge_1281 ? <NMIcon /> : null}
|
|
|
+ </View>
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
- </View>
|
|
|
-
|
|
|
+ </TouchableOpacity>
|
|
|
<View style={styles.rankingWrapper}>
|
|
|
<View style={styles.nmWrapper}>
|
|
|
<Text style={{ fontSize: 20, color: Colors.DARK_BLUE, fontWeight: '700' }}>
|
|
|
- {score[0]}
|
|
|
+ {score[active_score]}
|
|
|
+ </Text>
|
|
|
+ <Text style={{ fontSize: 14, color: Colors.DARK_BLUE, fontWeight: '500' }}>
|
|
|
+ {scoreNames[active_score]}
|
|
|
</Text>
|
|
|
- <Text style={{ fontSize: 14, color: Colors.DARK_BLUE, fontWeight: '500' }}>NM</Text>
|
|
|
</View>
|
|
|
|
|
|
- <View style={styles.seriesWrapper}>
|
|
|
+ <View style={styles.rankingScoresWrapper}>
|
|
|
{score.slice(1).map((number, index) => {
|
|
|
- if (!number) return;
|
|
|
- if (scoreNames[index] === 'YES' && number >= 10000) return;
|
|
|
- if (scoreNames[index] === 'SLOW' && number >= 4500) return;
|
|
|
+ if (!number) return <EmptyScore />;
|
|
|
+ if (scoreNames[index] === 'YES' && number >= 10000)
|
|
|
+ return (
|
|
|
+ <View
|
|
|
+ style={{
|
|
|
+ display: 'flex',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ flexDirection: 'column',
|
|
|
+ marginBottom: 10,
|
|
|
+ width: 40,
|
|
|
+ borderWidth: 1
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Text style={[styles.scoreHeaderText, { flex: 0 }]}>-</Text>
|
|
|
+ <Text style={[styles.scoreNameText, { flex: 0 }]}>YES</Text>
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ if (scoreNames[index] === 'SLOW' && number >= 4500) return <EmptyScore />;
|
|
|
+ if (index === active_score) return;
|
|
|
return (
|
|
|
<View
|
|
|
style={{
|
|
|
display: 'flex',
|
|
|
- marginTop: 10
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ flexDirection: 'column',
|
|
|
+ marginBottom: 10,
|
|
|
+ width: 40
|
|
|
}}
|
|
|
>
|
|
|
- <View style={{ display: 'flex', alignItems: 'center' }}>
|
|
|
- <Text style={[styles.headerText, { flex: 0 }]}>{number}</Text>
|
|
|
- <Text style={[styles.titleText, { flex: 0 }]}>{scoreNames[index]}</Text>
|
|
|
- </View>
|
|
|
+ <Text style={[styles.scoreHeaderText, { flex: 0 }]}>{number}</Text>
|
|
|
+ <Text style={[styles.scoreNameText, { flex: 0 }]}>{scoreNames[index]}</Text>
|
|
|
</View>
|
|
|
);
|
|
|
})}
|
|
@@ -182,6 +232,6 @@ export const Profile: FC<Props> = ({
|
|
|
<TBRanking />
|
|
|
</View>
|
|
|
</View>
|
|
|
- </TouchableOpacity>
|
|
|
+ </View>
|
|
|
);
|
|
|
};
|