index.tsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import React from 'react';
  2. import { View, Text, FlatList, TouchableOpacity, StyleSheet, Dimensions } from 'react-native';
  3. import { useNavigation } from '@react-navigation/native';
  4. import { Colors } from '../../../theme';
  5. import { PageWrapper } from '../../../components';
  6. import { NAVIGATION_PAGES } from 'src/types';
  7. import { StoreType, storage } from 'src/storage';
  8. import UserGroupIcon from '../../../../assets/icons/user-group.svg';
  9. import CrownIcon from '../../../../assets/icons/crown.svg';
  10. import IDCardIcon from '../../../../assets/icons/id-card.svg';
  11. import StreetPeopleIcon from '../../../../assets/icons/street-view.svg';
  12. import ChartPieIcon from '../../../../assets/icons/chart-pie.svg';
  13. import MemoriamIcon from '../../../../assets/icons/monument.svg';
  14. import ClockIcon from '../../../../assets/icons/clock.svg';
  15. import TrophyIcon from '../../../../assets/icons/trophy.svg';
  16. import InfoIcon from 'assets/icons/info-solid.svg';
  17. import FriendsIcon from 'assets/icons/friends.svg';
  18. import BlinkingDot from 'src/components/BlinkingDot';
  19. import { useNotification } from 'src/contexts/NotificationContext';
  20. const TravellersScreen = () => {
  21. const navigation = useNavigation();
  22. const token = storage.get('token', StoreType.STRING);
  23. const { isNotificationActive } = useNotification();
  24. const buttons = [
  25. { label: 'Master Ranking', icon: UserGroupIcon, page: NAVIGATION_PAGES.MASTER_RANKING },
  26. { label: 'UN Masters', icon: CrownIcon, page: NAVIGATION_PAGES.UN_MASTERS },
  27. { label: 'LPI Ranking', icon: IDCardIcon, page: NAVIGATION_PAGES.LPI_RANKING },
  28. { label: 'Series Ranking', icon: StreetPeopleIcon, page: NAVIGATION_PAGES.SERIES_RANKING },
  29. { label: 'Statistics', icon: ChartPieIcon, page: NAVIGATION_PAGES.STATISTICS },
  30. { label: 'In Memoriam', icon: MemoriamIcon, page: NAVIGATION_PAGES.IN_MEMORIAM },
  31. { label: 'In History', icon: ClockIcon, page: NAVIGATION_PAGES.IN_HISTORY },
  32. { label: 'Triumphs', icon: TrophyIcon, page: NAVIGATION_PAGES.TRIUMPHS }
  33. ];
  34. if (token) {
  35. buttons.push({ label: 'Friends', icon: FriendsIcon, page: NAVIGATION_PAGES.MY_FRIENDS });
  36. }
  37. const renderItem = ({ item }: { item: { label: string; icon: any; page: string } }) => (
  38. <TouchableOpacity
  39. style={{ alignItems: 'center' }}
  40. onPress={() => navigation.navigate(item.page as never)}
  41. >
  42. <View style={styles.button}>
  43. <item.icon
  44. fill={Colors.ORANGE}
  45. width={Dimensions.get('window').width < 380 ? 105 : 110}
  46. height={32}
  47. />
  48. <Text style={styles.label}>{item.label}</Text>
  49. </View>
  50. {item.label === 'Friends' && isNotificationActive && (
  51. <BlinkingDot diameter={10} right={'15%'} top={'15%'} />
  52. )}
  53. </TouchableOpacity>
  54. );
  55. return (
  56. <PageWrapper>
  57. <View style={styles.header}>
  58. <View style={{ width: 30 }} />
  59. <Text style={styles.title}>Travellers</Text>
  60. <TouchableOpacity
  61. onPress={() => navigation.navigate(NAVIGATION_PAGES.JOIN_INFO as never)}
  62. style={{ width: 30 }}
  63. >
  64. <InfoIcon />
  65. </TouchableOpacity>
  66. </View>
  67. <FlatList
  68. data={buttons}
  69. renderItem={renderItem}
  70. keyExtractor={(item, index) => 'key' + index}
  71. numColumns={2}
  72. contentContainerStyle={styles.container}
  73. style={{ flex: 1 }}
  74. columnWrapperStyle={{ justifyContent: 'space-between' }}
  75. />
  76. </PageWrapper>
  77. );
  78. };
  79. const styles = StyleSheet.create({
  80. container: {
  81. justifyContent: 'space-between',
  82. paddingHorizontal: Dimensions.get('window').width < 380 ? '5%' : 24,
  83. paddingVertical: 8,
  84. gap: 32,
  85. width: '100%'
  86. },
  87. button: {
  88. alignItems: 'center',
  89. justifyContent: 'center',
  90. paddingVertical: 16,
  91. paddingHorizontal: 8,
  92. backgroundColor: Colors.FILL_LIGHT,
  93. borderRadius: 16,
  94. gap: 12
  95. },
  96. label: {
  97. color: Colors.DARK_BLUE,
  98. fontSize: 13,
  99. fontWeight: 'bold'
  100. },
  101. title: { color: Colors.DARK_BLUE, fontSize: 14, fontWeight: '600' },
  102. header: {
  103. alignItems: 'center',
  104. paddingVertical: 16,
  105. flexDirection: 'row',
  106. justifyContent: 'space-between'
  107. }
  108. });
  109. export interface Ranking {
  110. user_id: number;
  111. score_dare: number;
  112. score_nm: number;
  113. score_un: number;
  114. score_unp: number;
  115. score_tcc: number;
  116. score_deep: number;
  117. score_whs: number | null;
  118. score_kye: number;
  119. score_tbt: number;
  120. score_yes: number;
  121. score_slow: number;
  122. rank_tbt: number;
  123. avatar: string | null;
  124. first_name: string;
  125. last_name: string;
  126. age: number;
  127. flag1: string;
  128. flag2: string | null;
  129. badge_1281: number;
  130. badge_un: number;
  131. badge_supreme: number;
  132. badge_tbt: number;
  133. badge_offline: number;
  134. patreon: number;
  135. country: string;
  136. auth: number;
  137. rank: number;
  138. country_rank: number;
  139. dod: number;
  140. ukr: number;
  141. badges: number;
  142. arrow_nm: number;
  143. arrow_un: number;
  144. arrow_unp: number;
  145. arrow_dare: number;
  146. arrow_yes: number;
  147. arrow_whs: number;
  148. arrow_tcc: number;
  149. arrow_tbt: number;
  150. arrow_slow: number;
  151. arrow_kye: number;
  152. }
  153. export default TravellersScreen;