|
|
@@ -4,12 +4,28 @@ import ActionSheet, { SheetManager } from 'react-native-actions-sheet';
|
|
|
import { Colors } from 'src/theme';
|
|
|
import { getFontSize } from 'src/utils';
|
|
|
import { FlashList } from '@shopify/flash-list';
|
|
|
+import { API_HOST } from 'src/constants';
|
|
|
+import { useNavigation } from '@react-navigation/native';
|
|
|
+import { NAVIGATION_PAGES } from 'src/types';
|
|
|
+import { useSubscription } from 'src/screens/OfflineMapsScreen/useSubscription';
|
|
|
|
|
|
const MultipleSeriesModal = () => {
|
|
|
+ const navigation = useNavigation();
|
|
|
+ const { isPremium, loading } = useSubscription();
|
|
|
const [seriesData, setSeriesData] = useState<any>(null);
|
|
|
const [markers, setMarkers] = useState<any[]>([]);
|
|
|
|
|
|
const shouldOpenWarningModalRef = useRef(false);
|
|
|
+ const shouldOpenPremiumWarningModalRef = useRef(false);
|
|
|
+
|
|
|
+ function formatNumber(number: number) {
|
|
|
+ if (number >= 1000 && number < 10000) {
|
|
|
+ return (number / 1000).toFixed(1) + 'k';
|
|
|
+ } else if (number >= 10000) {
|
|
|
+ return (number / 1000).toFixed(0) + 'k';
|
|
|
+ }
|
|
|
+ return number.toString();
|
|
|
+ }
|
|
|
|
|
|
const handleSheetOpen = (payload: any) => {
|
|
|
setSeriesData(payload);
|
|
|
@@ -56,6 +72,11 @@ const MultipleSeriesModal = () => {
|
|
|
|
|
|
shouldOpenWarningModalRef.current = false;
|
|
|
seriesData.setIsWarningModalVisible(true);
|
|
|
+ } else if (shouldOpenPremiumWarningModalRef.current) {
|
|
|
+ if (!seriesData) return;
|
|
|
+
|
|
|
+ shouldOpenPremiumWarningModalRef.current = false;
|
|
|
+ seriesData.setPremiumModalVisible(true);
|
|
|
}
|
|
|
}}
|
|
|
containerStyle={styles.sheetContainer}
|
|
|
@@ -68,37 +89,90 @@ const MultipleSeriesModal = () => {
|
|
|
keyExtractor={(item, index) => item.id.toString() + index.toString()}
|
|
|
showsVerticalScrollIndicator={true}
|
|
|
persistentScrollbar={true}
|
|
|
- renderItem={({ item }) => (
|
|
|
- <TouchableOpacity style={styles.option} onPress={() => handleItemPress(item)}>
|
|
|
- <View style={styles.imageContainer}>
|
|
|
- <Image
|
|
|
- source={{ uri: item.icon?.uri || '' }}
|
|
|
- style={styles.icon}
|
|
|
- resizeMode="contain"
|
|
|
- />
|
|
|
- <View style={{ justifyContent: 'space-between', flex: 1 }}>
|
|
|
- <Text style={styles.name}>{item.series_name}</Text>
|
|
|
- <Text style={styles.description}>{item.name}</Text>
|
|
|
+ renderItem={({ item }) => {
|
|
|
+ const formattedCount = formatNumber(item.no_visited);
|
|
|
+ const parsedAvatars =
|
|
|
+ typeof item.avatars === 'string' ? JSON.parse(item.avatars) : item.avatars;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <TouchableOpacity style={styles.option} onPress={() => handleItemPress(item)}>
|
|
|
+ <View style={styles.imageContainer}>
|
|
|
+ <Image
|
|
|
+ source={{ uri: item.icon?.uri || '' }}
|
|
|
+ style={styles.icon}
|
|
|
+ resizeMode="contain"
|
|
|
+ />
|
|
|
</View>
|
|
|
- </View>
|
|
|
-
|
|
|
- <TouchableOpacity
|
|
|
- onPress={() => handleToggleSeries(item)}
|
|
|
- style={[styles.markButton, item.visited === 1 && styles.visitedButton]}
|
|
|
- >
|
|
|
- {item.visited === 1 ? (
|
|
|
- <View style={styles.completedContainer}>
|
|
|
- <Text style={[styles.calloutButtonText, { color: Colors.DARK_BLUE }]}>
|
|
|
- Completed
|
|
|
- </Text>
|
|
|
+
|
|
|
+ <View style={{ flex: 1, gap: 8 }}>
|
|
|
+ <View style={{ justifyContent: 'space-between', flex: 1 }}>
|
|
|
+ <Text style={styles.name}>{item.series_name}</Text>
|
|
|
+ <Text style={styles.description}>{item.name}</Text>
|
|
|
+ </View>
|
|
|
+
|
|
|
+ <View
|
|
|
+ style={{
|
|
|
+ flexDirection: 'row',
|
|
|
+ justifyContent: 'space-between',
|
|
|
+ alignItems: 'center',
|
|
|
+ flex: 1
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {parsedAvatars && (
|
|
|
+ <TouchableOpacity
|
|
|
+ onPress={() => {
|
|
|
+ if (!isPremium) {
|
|
|
+ shouldOpenPremiumWarningModalRef.current = true;
|
|
|
+ SheetManager.hide('multiple-series-modal');
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SheetManager.hide('multiple-series-modal');
|
|
|
+ navigation.navigate(
|
|
|
+ ...([
|
|
|
+ NAVIGATION_PAGES.USERS_LIST,
|
|
|
+ {
|
|
|
+ id: item.id,
|
|
|
+ isFromHere: false,
|
|
|
+ type: 'series'
|
|
|
+ }
|
|
|
+ ] as never)
|
|
|
+ );
|
|
|
+ }}
|
|
|
+ style={styles.userImageContainer}
|
|
|
+ >
|
|
|
+ {parsedAvatars?.map((avatar: number, index: number) => (
|
|
|
+ <Image
|
|
|
+ key={index}
|
|
|
+ source={{ uri: API_HOST + '/img/avatars/' + avatar + '.webp' }}
|
|
|
+ style={styles.userImageSmall}
|
|
|
+ />
|
|
|
+ ))}
|
|
|
+ <View style={styles.userCountContainer}>
|
|
|
+ <Text style={styles.userCount}>{formattedCount}</Text>
|
|
|
+ </View>
|
|
|
+ </TouchableOpacity>
|
|
|
+ )}
|
|
|
+
|
|
|
+ <TouchableOpacity
|
|
|
+ onPress={() => handleToggleSeries(item)}
|
|
|
+ style={[styles.markButton, item.visited === 1 && styles.visitedButton]}
|
|
|
+ >
|
|
|
+ {item.visited === 1 ? (
|
|
|
+ <View style={styles.completedContainer}>
|
|
|
+ <Text style={[styles.calloutButtonText, { color: Colors.DARK_BLUE }]}>
|
|
|
+ Completed
|
|
|
+ </Text>
|
|
|
+ </View>
|
|
|
+ ) : (
|
|
|
+ <Text style={styles.calloutButtonText}>To Complete</Text>
|
|
|
+ )}
|
|
|
+ </TouchableOpacity>
|
|
|
</View>
|
|
|
- ) : (
|
|
|
- <Text style={styles.calloutButtonText}>To Complete</Text>
|
|
|
- )}
|
|
|
+ </View>
|
|
|
</TouchableOpacity>
|
|
|
- </TouchableOpacity>
|
|
|
- )}
|
|
|
- estimatedItemSize={50}
|
|
|
+ );
|
|
|
+ }}
|
|
|
/>
|
|
|
</View>
|
|
|
)}
|
|
|
@@ -147,7 +221,6 @@ const styles = StyleSheet.create({
|
|
|
option: {
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
- justifyContent: 'space-between',
|
|
|
backgroundColor: Colors.FILL_LIGHT,
|
|
|
paddingVertical: 8,
|
|
|
paddingHorizontal: 12,
|
|
|
@@ -158,7 +231,6 @@ const styles = StyleSheet.create({
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
gap: 8,
|
|
|
- flex: 1,
|
|
|
marginRight: 8
|
|
|
},
|
|
|
name: {
|
|
|
@@ -172,6 +244,34 @@ const styles = StyleSheet.create({
|
|
|
fontWeight: '600',
|
|
|
color: Colors.DARK_BLUE,
|
|
|
flex: 1
|
|
|
+ },
|
|
|
+ userCountContainer: {
|
|
|
+ width: 28,
|
|
|
+ height: 28,
|
|
|
+ borderRadius: 14,
|
|
|
+ backgroundColor: Colors.DARK_LIGHT,
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ marginLeft: -6
|
|
|
+ },
|
|
|
+ userCount: {
|
|
|
+ fontSize: 12,
|
|
|
+ color: Colors.DARK_BLUE,
|
|
|
+ lineHeight: 24
|
|
|
+ },
|
|
|
+ userImageContainer: {
|
|
|
+ flexDirection: 'row',
|
|
|
+ alignItems: 'center',
|
|
|
+ marginLeft: 6
|
|
|
+ },
|
|
|
+ userImageSmall: {
|
|
|
+ width: 28,
|
|
|
+ height: 28,
|
|
|
+ borderRadius: 14,
|
|
|
+ marginLeft: -6,
|
|
|
+ borderWidth: 1,
|
|
|
+ borderColor: Colors.DARK_LIGHT,
|
|
|
+ resizeMode: 'cover'
|
|
|
}
|
|
|
});
|
|
|
|