|
@@ -1,4 +1,4 @@
|
|
-import React, { FC } from 'react';
|
|
|
|
|
|
+import React, { FC, useEffect } from 'react';
|
|
import { Image } from 'expo-image';
|
|
import { Image } from 'expo-image';
|
|
import { Text, View } from 'react-native';
|
|
import { Text, View } from 'react-native';
|
|
|
|
|
|
@@ -23,75 +23,103 @@ import { API_HOST } from '../../../../constants';
|
|
import { ItemStyles } from './styles';
|
|
import { ItemStyles } from './styles';
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
- index: number;
|
|
|
|
|
|
+ blockIndex: number;
|
|
item: ListType;
|
|
item: ListType;
|
|
ranking: any;
|
|
ranking: any;
|
|
|
|
+ idx: number;
|
|
};
|
|
};
|
|
|
|
|
|
-export const RenderItem: FC<Props> = ({ item, index, ranking }) => {
|
|
|
|
|
|
+export const RenderItem: FC<Props> = ({ item, blockIndex, ranking, idx }) => {
|
|
if (isType1(item) || isType4(item) || isType5(item)) {
|
|
if (isType1(item) || isType4(item) || isType5(item)) {
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
{'megaregion' in item && (
|
|
{'megaregion' in item && (
|
|
<View>
|
|
<View>
|
|
- {item.megaregion !== ranking[index - 1]?.megaregion ? (
|
|
|
|
|
|
+ {item.megaregion !== ranking[idx - 1]?.megaregion ? (
|
|
<Text style={[ItemStyles.nameAndCnt, ItemStyles.headerWrapper]}>
|
|
<Text style={[ItemStyles.nameAndCnt, ItemStyles.headerWrapper]}>
|
|
{item.megaregion as string}
|
|
{item.megaregion as string}
|
|
</Text>
|
|
</Text>
|
|
) : null}
|
|
) : null}
|
|
</View>
|
|
</View>
|
|
)}
|
|
)}
|
|
- <StatisticItem cnt={item.cnt} flag={item.flag} index={index} name={item.region_name} />
|
|
|
|
|
|
+ <StatisticItem cnt={item.cnt} flag={item.flag} index={blockIndex} name={item.region_name} />
|
|
</>
|
|
</>
|
|
);
|
|
);
|
|
} else if (isType6(item)) {
|
|
} else if (isType6(item)) {
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
<View>
|
|
<View>
|
|
- {item.country !== ranking[index - 1]?.country ? (
|
|
|
|
- <Text style={[ItemStyles.nameAndCnt, ItemStyles.headerWrapper]}>{item.country}</Text>
|
|
|
|
|
|
+ {item.country !== ranking[idx - 1]?.country ? (
|
|
|
|
+ <View style={ItemStyles.headerContainer}>
|
|
|
|
+ <Image
|
|
|
|
+ style={ItemStyles.flagSquare}
|
|
|
|
+ source={{ uri: API_HOST + '/img/flags_new/' + item.country_flag }}
|
|
|
|
+ />
|
|
|
|
+ <Text
|
|
|
|
+ style={[
|
|
|
|
+ ItemStyles.nameAndCnt,
|
|
|
|
+ { fontSize: getFontSize(14), textAlign: 'center', textTransform: 'uppercase' }
|
|
|
|
+ ]}
|
|
|
|
+ >
|
|
|
|
+ {item.country}
|
|
|
|
+ </Text>
|
|
|
|
+ </View>
|
|
) : null}
|
|
) : null}
|
|
</View>
|
|
</View>
|
|
- <StatisticItem cnt={item.cnt} flag={item.region_flag} index={index} name={item.region} />
|
|
|
|
|
|
+ <StatisticItem
|
|
|
|
+ cnt={item.cnt}
|
|
|
|
+ flag={item.region_flag}
|
|
|
|
+ index={blockIndex}
|
|
|
|
+ name={item.region}
|
|
|
|
+ />
|
|
</>
|
|
</>
|
|
);
|
|
);
|
|
} else if (isType2(item)) {
|
|
} else if (isType2(item)) {
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
<View>
|
|
<View>
|
|
- {item.mega_name !== ranking[index - 1]?.mega_name ? (
|
|
|
|
|
|
+ {item.mega_name !== ranking[idx - 1]?.mega_name ? (
|
|
<Text style={[ItemStyles.nameAndCnt, ItemStyles.headerWrapper]}>
|
|
<Text style={[ItemStyles.nameAndCnt, ItemStyles.headerWrapper]}>
|
|
{item.mega_name as string}
|
|
{item.mega_name as string}
|
|
</Text>
|
|
</Text>
|
|
) : null}
|
|
) : null}
|
|
</View>
|
|
</View>
|
|
- <StatisticItem name={item.dare_name} flag={item.dare_flag} cnt={item.cnt} index={index} />
|
|
|
|
|
|
+ <StatisticItem
|
|
|
|
+ name={item.dare_name}
|
|
|
|
+ flag={item.dare_flag}
|
|
|
|
+ cnt={item.cnt}
|
|
|
|
+ index={blockIndex}
|
|
|
|
+ />
|
|
</>
|
|
</>
|
|
);
|
|
);
|
|
} else if (isType7(item)) {
|
|
} else if (isType7(item)) {
|
|
- return <StatisticItem name={item.country_name} flag={item.flag} cnt={item.cnt} index={index} />;
|
|
|
|
|
|
+ return (
|
|
|
|
+ <StatisticItem name={item.country_name} flag={item.flag} cnt={item.cnt} index={blockIndex} />
|
|
|
|
+ );
|
|
} else if (isType8(item)) {
|
|
} else if (isType8(item)) {
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
<View>
|
|
<View>
|
|
- {item.mega_name !== ranking[index - 1]?.mega_name ? (
|
|
|
|
|
|
+ {item.mega_name !== ranking[idx - 1]?.mega_name ? (
|
|
<Text style={[ItemStyles.nameAndCnt, ItemStyles.headerWrapper]}>
|
|
<Text style={[ItemStyles.nameAndCnt, ItemStyles.headerWrapper]}>
|
|
{item.mega_name as string}
|
|
{item.mega_name as string}
|
|
</Text>
|
|
</Text>
|
|
) : null}
|
|
) : null}
|
|
- <StatisticItem name={item.country} flag={item.flag} cnt={item.cnt} index={index} />
|
|
|
|
|
|
+ <StatisticItem name={item.country} flag={item.flag} cnt={item.cnt} index={blockIndex} />
|
|
</View>
|
|
</View>
|
|
</>
|
|
</>
|
|
);
|
|
);
|
|
} else if (isType9(item)) {
|
|
} else if (isType9(item)) {
|
|
- return <StatisticItem name={item.nation} flag={item.flag} cnt={item.score} index={index} />;
|
|
|
|
|
|
+ return (
|
|
|
|
+ <StatisticItem name={item.nation} flag={item.flag} cnt={item.score} index={blockIndex} />
|
|
|
|
+ );
|
|
} else if (isType10(item)) {
|
|
} else if (isType10(item)) {
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
- {item.series_name !== ranking[index - 1]?.series_name ? (
|
|
|
|
|
|
+ {item.series_name !== ranking[idx - 1]?.series_name ? (
|
|
<View style={ItemStyles.headerSeriesWrapper}>
|
|
<View style={ItemStyles.headerSeriesWrapper}>
|
|
<Image
|
|
<Image
|
|
- key={index}
|
|
|
|
|
|
+ key={idx}
|
|
style={{ width: 20, height: 20, borderRadius: 10 }}
|
|
style={{ width: 20, height: 20, borderRadius: 10 }}
|
|
source={{ uri: API_HOST + '/static/img/series/' + item.series_icon }}
|
|
source={{ uri: API_HOST + '/static/img/series/' + item.series_icon }}
|
|
/>
|
|
/>
|
|
@@ -104,19 +132,20 @@ export const RenderItem: FC<Props> = ({ item, index, ranking }) => {
|
|
name={item.item_name}
|
|
name={item.item_name}
|
|
flags={item.flags as unknown as string}
|
|
flags={item.flags as unknown as string}
|
|
cnt={item.cnt}
|
|
cnt={item.cnt}
|
|
- index={index}
|
|
|
|
|
|
+ index={blockIndex}
|
|
/>
|
|
/>
|
|
</>
|
|
</>
|
|
);
|
|
);
|
|
- } else
|
|
|
|
|
|
+ } else {
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
<StatisticItem
|
|
<StatisticItem
|
|
name={item.nation ? item.nation : `${item.first_name} ${item.last_name}`}
|
|
name={item.nation ? item.nation : `${item.first_name} ${item.last_name}`}
|
|
flag={item.flag}
|
|
flag={item.flag}
|
|
cnt={item.score ? item.score : item.cnt}
|
|
cnt={item.score ? item.score : item.cnt}
|
|
- index={index}
|
|
|
|
|
|
+ index={blockIndex}
|
|
/>
|
|
/>
|
|
</>
|
|
</>
|
|
);
|
|
);
|
|
|
|
+ }
|
|
};
|
|
};
|