Skip to content

Commit

Permalink
Merge pull request #508 from bounswe/imp/followers-screen
Browse files Browse the repository at this point in the history
imp: Followers screen
  • Loading branch information
gulsensabak authored Dec 13, 2024
2 parents 2a8eb83 + 02773c8 commit 5a3c207
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 3 deletions.
6 changes: 6 additions & 0 deletions mobile/tradeverse/app/(tabs)/account/followers.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react'
import FollowersScreen from '../../../screens/followers'

export default function Followers() {
return <FollowersScreen />
}
3 changes: 2 additions & 1 deletion mobile/tradeverse/config/screen-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const paths = {
PORTFOLIO: `${roots.ACCOUNT}/portfolio`,
FOLLOWED_TOPICS: `${roots.ACCOUNT}/followed-topics`,
FOLLOWED_USERS: `${roots.ACCOUNT}/followed-users`,
MY_POSTS: `${roots.ACCOUNT}/my-posts`
MY_POSTS: `${roots.ACCOUNT}/my-posts`,
FOLLOWERS: `${roots.ACCOUNT}/followers`
},
}
export default paths
3 changes: 1 addition & 2 deletions mobile/tradeverse/screens/account-root/profile-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ const ProfileConfig = {
value: 'my_followers',
title: 'Followers',
icon: <IconUserDown {...defaultIconProps} />,
href: '#',
disabled: true,
href: paths.ACCOUNT.FOLLOWERS,
},
{
value: 'my_following',
Expand Down
109 changes: 109 additions & 0 deletions mobile/tradeverse/screens/followers/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React, { useEffect, useState } from 'react';
import { View, Text, Image, StyleSheet } from 'react-native';
import GlobalScreen from '../../components/ui/global-screen';
import FullScrollView from '../../components/ui/full-scroll-view';
import { Stack } from 'expo-router';
import api from '../../services/_axios';
import AsyncStorage from '@react-native-async-storage/async-storage';

const FollowersScreen = () => {
const [followers, setFollowers] = useState([]);
const [loading, setLoading] = useState(true);

useEffect(() => {
const fetchFollowers = async () => {
try {
const token = await AsyncStorage.getItem('authToken');
const response = await api.get('/api/follow/get-followers', {
headers: { Authorization: `Bearer ${token}` },
});
setFollowers(response.data.followers || []);
} catch (error) {
console.error('Error fetching followers:', error);
} finally {
setLoading(false);
}
};

fetchFollowers();
}, []);

return (
<GlobalScreen>
<FullScrollView>
<Stack.Screen
options={{
headerBackTitleVisible: false,
headerTitle: 'Followers',
}}
/>
{loading ? (
<Text style={styles.loadingText}>Loading followers...</Text>
) : (
<View style={styles.container}>
<Text style={styles.countText}>
Followers Count: {followers.length}
</Text>
{followers.map((follower, index) => (
<View key={index} style={styles.followerItem}>
<Image
source={{ uri: follower.userPhoto }}
style={styles.userPhoto}
/>
<View style={styles.textContainer}>
<Text style={styles.username}>
{follower.username}
</Text>
<Text style={styles.name}>
{follower.name}
</Text>
</View>
</View>
))}
</View>
)}
</FullScrollView>
</GlobalScreen>
);
};

const styles = StyleSheet.create({
container: {
padding: 16,
},
countText: {
fontSize: 18,
fontWeight: 'bold',
marginBottom: 16,
textAlign: 'center'
},
loadingText: {
fontSize: 16,
textAlign: 'center',
marginTop: 20,
},
followerItem: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 12,
},
userPhoto: {
width: 50,
height: 50,
borderRadius: 25,
marginRight: 12,
},
textContainer: {
flex: 1,
},
username: {
fontSize: 16,
fontWeight: '600',
},
name: {
fontSize: 14,
color: '#555',
},
});

export default FollowersScreen;

0 comments on commit 5a3c207

Please sign in to comment.