import React from 'react'; import {View, Text, StyleSheet, ViewProps} from 'react-native'; import {TouchableOpacity} from 'react-native-gesture-handler'; import {useNavigation} from '@react-navigation/native'; import {AuthContext, ProfileContext} from '../../routes'; interface FollowCountProps extends ViewProps { mode: 'followers' | 'following'; count: number; isProfileView: boolean; } const FollowCount: React.FC = ({ style, mode, count, isProfileView, }) => { const {followers, following} = isProfileView ? React.useContext(ProfileContext) : React.useContext(AuthContext); const navigation = useNavigation(); const displayed: string = count < 5e3 ? `${count}` : count < 1e5 ? `${(count / 1e3).toFixed(1)}k` : count < 1e6 ? `${(count / 1e3).toFixed(0)}k` : `${count / 1e6}m`; return ( navigation.push('FollowersListScreen', { isFollowers: mode === 'followers', list: mode === 'followers' ? followers : following, }) }> {displayed} {mode === 'followers' ? 'Followers' : 'Following'} ); }; const styles = StyleSheet.create({ container: { alignItems: 'center', }, count: { fontWeight: '700', fontSize: 18, }, label: { fontWeight: '400', fontSize: 16, }, }); export default FollowCount;