|
@@ -1,8 +1,8 @@
|
|
|
-import React, { FC, ReactNode, useEffect, useState } from 'react';
|
|
|
-import { Linking, ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
|
|
-import { Image } from 'expo-image';
|
|
|
+import React, { FC, ReactNode, useState } from 'react';
|
|
|
+import { Linking, ScrollView, Text, TouchableOpacity, View, Image } from 'react-native';
|
|
|
import { CommonActions, NavigationProp, useNavigation } from '@react-navigation/native';
|
|
|
import Modal from 'react-native-modal';
|
|
|
+import Tooltip from 'react-native-walkthrough-tooltip';
|
|
|
|
|
|
import {
|
|
|
type Score,
|
|
@@ -38,7 +38,6 @@ import IconGlobe from '../../../../assets/icons/bottom-navigation/globe.svg';
|
|
|
import IconLink from '../../../../assets/icons/link.svg';
|
|
|
import GearIcon from '../../../../assets/icons/gear.svg';
|
|
|
import ArrowIcon from '../../../../assets/icons/next.svg';
|
|
|
-import axios from 'axios';
|
|
|
import RegionsRenderer from './RegionsRenderer';
|
|
|
|
|
|
type Props = {
|
|
@@ -52,27 +51,13 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
const token = storage.get('token', StoreType.STRING) as string;
|
|
|
const currentUserId = storage.get('uid', StoreType.STRING) as string;
|
|
|
|
|
|
- const [isUserMapAvailable, setIsUserMapAvailable] = useState<boolean>(false);
|
|
|
- const [loading, setLoading] = useState(true);
|
|
|
-
|
|
|
if (!token) return <UnauthenticatedProfileScreen />;
|
|
|
|
|
|
const { data, isFetching } = isPublicView
|
|
|
? usePostGetProfileInfoPublicQuery(route.params?.userId, true)
|
|
|
: usePostGetProfileInfoQuery(token, true);
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- const getUserMapUrl = async () => {
|
|
|
- const response = await axios.get(`${API_HOST}/img/single_maps/${route.params?.userId}.png`);
|
|
|
- return Boolean(response.data);
|
|
|
- };
|
|
|
- getUserMapUrl().then((res) => {
|
|
|
- setIsUserMapAvailable(res);
|
|
|
- setLoading(false);
|
|
|
- });
|
|
|
- }, []);
|
|
|
-
|
|
|
- if (!data || isFetching || loading) return <Loading />;
|
|
|
+ if (!data || isFetching) return <Loading />;
|
|
|
|
|
|
const handleGoToMap = () => {
|
|
|
isPublicView
|
|
@@ -93,11 +78,9 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
onPress={handleGoToMap}
|
|
|
>
|
|
|
<Image
|
|
|
- source={
|
|
|
- isUserMapAvailable
|
|
|
- ? { uri: `${API_HOST}/img/single_maps/${route.params?.userId}.png` }
|
|
|
- : require('../../../../assets/nm-map.png')
|
|
|
- }
|
|
|
+ source={{
|
|
|
+ uri: `${API_HOST}/img/single_maps/${isPublicView ? route.params?.userId : currentUserId}.png`
|
|
|
+ }}
|
|
|
style={styles.usersMap}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
@@ -192,6 +175,7 @@ const PersonalInfo: FC<PersonalInfoProps> = ({ data, userId }) => {
|
|
|
const [showMoreSeries, setShowMoreSeries] = useState(false);
|
|
|
const [type, setType] = useState<string>('nm');
|
|
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
|
+ const [toolTipVisible, setToolTipVisible] = useState<number | null>(null);
|
|
|
|
|
|
const { data: regions } = usePostGetProfileRegions(userId, type);
|
|
|
|
|
@@ -277,16 +261,27 @@ const PersonalInfo: FC<PersonalInfoProps> = ({ data, userId }) => {
|
|
|
{data.series?.length > 0 && (
|
|
|
<InfoItem showMore={showMoreSeries} inline={true} title={'SERIES'}>
|
|
|
{data.series?.slice(0, showMoreSeries ? data.series.length : 8).map((data, index) => (
|
|
|
- <View
|
|
|
+ <Tooltip
|
|
|
+ isVisible={toolTipVisible === index}
|
|
|
+ content={<Text style={{}}>{data.name}</Text>}
|
|
|
+ contentStyle={{ backgroundColor: Colors.FILL_LIGHT }}
|
|
|
+ placement="top"
|
|
|
+ onClose={() => setToolTipVisible(null)}
|
|
|
key={index}
|
|
|
- style={{ display: 'flex', flexDirection: 'column', gap: 5, alignItems: 'center' }}
|
|
|
+ backgroundColor="transparent"
|
|
|
+ allowChildInteraction={false}
|
|
|
>
|
|
|
- <Image
|
|
|
- source={{ uri: API_HOST + data.icon_png }}
|
|
|
- style={{ width: 28, height: 28 }}
|
|
|
- />
|
|
|
- <Text style={[styles.headerText, { flex: 0 }]}>{data.score}</Text>
|
|
|
- </View>
|
|
|
+ <TouchableOpacity
|
|
|
+ style={{ display: 'flex', flexDirection: 'column', gap: 5, alignItems: 'center' }}
|
|
|
+ onPress={() => setToolTipVisible(index)}
|
|
|
+ >
|
|
|
+ <Image
|
|
|
+ source={{ uri: API_HOST + data.icon_png }}
|
|
|
+ style={{ width: 28, height: 28 }}
|
|
|
+ />
|
|
|
+ <Text style={[styles.headerText, { flex: 0 }]}>{data.score}</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+ </Tooltip>
|
|
|
))}
|
|
|
</InfoItem>
|
|
|
)}
|
|
@@ -368,11 +363,7 @@ const PersonalInfo: FC<PersonalInfoProps> = ({ data, userId }) => {
|
|
|
statusBarTranslucent={true}
|
|
|
presentationStyle="overFullScreen"
|
|
|
>
|
|
|
- <RegionsRenderer
|
|
|
- type={type}
|
|
|
- regions={regions}
|
|
|
- setIsModalVisible={setIsModalVisible}
|
|
|
- />
|
|
|
+ <RegionsRenderer type={type} regions={regions} setIsModalVisible={setIsModalVisible} />
|
|
|
</Modal>
|
|
|
</>
|
|
|
);
|