Skip to content

Commit 200c0dc

Browse files
committedJan 11, 2025
Implement toggle for feed selection and update styles
1 parent af4a74d commit 200c0dc

File tree

6 files changed

+81
-19
lines changed

6 files changed

+81
-19
lines changed
 

‎.expo/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
> Why do I have a folder named ".expo" in my project?
2+
3+
The ".expo" folder is created when an Expo project is started using "expo start" command.
4+
5+
> What do the files contain?
6+
7+
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
8+
- "packager-info.json": contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator.
9+
- "settings.json": contains the server configuration that is used to serve the application manifest.
10+
11+
> Should I commit the ".expo" folder?
12+
13+
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
14+
15+
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.

‎.expo/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"hostType": "lan",
3+
"lanType": "ip",
4+
"dev": true,
5+
"minify": false,
6+
"urlRandomness": null,
7+
"https": false
8+
}

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ There are plenty of features to add, so here is what I would work on next. Feel
9292

9393
- Ability to share posts through messaging
9494
- For You feed page vs Following feed page
95+
- camera Could not generate thumbnail error

‎frontend/src/navigation/home/index.tsx

-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export type HomeStackParamList = {
1515
Add: undefined;
1616
Inbox: undefined;
1717
Me: { initialUserId: string };
18-
Following: undefined; // Add new route
1918
};
2019

2120
const Tab = createMaterialBottomTabNavigator<HomeStackParamList>();
@@ -37,15 +36,6 @@ export default function HomeScreen() {
3736
),
3837
}}
3938
/>
40-
<Tab.Screen
41-
name="Following"
42-
component={FollowingFeedScreen} // Add new screen
43-
options={{
44-
tabBarIcon: ({ color }) => (
45-
<Feather name="users" size={24} color={color} />
46-
),
47-
}}
48-
/>
4939
<Tab.Screen
5040
name="Discover"
5141
component={SearchScreen}

‎frontend/src/screens/feed/index.tsx

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { FlatList, View, Dimensions, ViewToken, RefreshControl } from "react-native";
1+
import { FlatList, View, Dimensions, ViewToken, RefreshControl, TouchableOpacity, Text } from "react-native";
22
import styles from "./styles";
33
import PostSingle, { PostSingleHandles } from "../../components/general/post";
44
import { useContext, useEffect, useRef, useState, useCallback } from "react";
5-
import { getFeed, getPostsByUserId } from "../../services/posts";
5+
import { getFeed, getFollowingFeed, getPostsByUserId } from "../../services/posts";
66
import { Post } from "../../../types";
77
import { RouteProp } from "@react-navigation/native";
88
import { RootStackParamList } from "../../navigation/main";
@@ -41,17 +41,21 @@ export default function FeedScreen({ route }: { route: FeedScreenRouteProp }) {
4141

4242
const [posts, setPosts] = useState<Post[]>([]);
4343
const [refreshing, setRefreshing] = useState(false);
44+
const [selectedFeed, setSelectedFeed] = useState<"ForYou" | "Following">("ForYou");
4445
const mediaRefs = useRef<Record<string, PostSingleHandles | null>>({});
4546

4647
const fetchPosts = useCallback(async () => {
4748
if (profile && creator) {
4849
const posts = await getPostsByUserId(creator);
4950
setPosts(posts);
50-
} else {
51+
} else if (selectedFeed === "ForYou") {
5152
const posts = await getFeed();
5253
setPosts(posts);
54+
} else {
55+
const posts = await getFollowingFeed();
56+
setPosts(posts);
5357
}
54-
}, [profile, creator]);
58+
}, [profile, creator, selectedFeed]);
5559

5660
useEffect(() => {
5761
fetchPosts();
@@ -114,6 +118,26 @@ export default function FeedScreen({ route }: { route: FeedScreenRouteProp }) {
114118

115119
return (
116120
<View style={styles.container}>
121+
<View style={styles.toggleContainer}>
122+
<TouchableOpacity
123+
style={[
124+
styles.toggleButton,
125+
selectedFeed === "ForYou" && styles.selectedButton,
126+
]}
127+
onPress={() => setSelectedFeed("ForYou")}
128+
>
129+
<Text style={styles.toggleButtonText}>For You</Text>
130+
</TouchableOpacity>
131+
<TouchableOpacity
132+
style={[
133+
styles.toggleButton,
134+
selectedFeed === "Following" && styles.selectedButton,
135+
]}
136+
onPress={() => setSelectedFeed("Following")}
137+
>
138+
<Text style={styles.toggleButtonText}>Following</Text>
139+
</TouchableOpacity>
140+
</View>
117141
<FlatList
118142
data={posts}
119143
windowSize={4}

‎frontend/src/screens/feed/styles.ts

+29-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
import { StyleSheet } from "react-native";
22

3-
const styles = StyleSheet.create({
4-
container: { flex: 1 },
5-
});
6-
7-
export default styles;
3+
export default StyleSheet.create({
4+
container: {
5+
flex: 1,
6+
backgroundColor: "black",
7+
},
8+
toggleContainer: {
9+
position: "absolute",
10+
top: 20,
11+
left: 0,
12+
right: 0,
13+
flexDirection: "row",
14+
justifyContent: "center",
15+
zIndex: 1,
16+
},
17+
toggleButton: {
18+
paddingHorizontal: 20,
19+
paddingVertical: 10,
20+
marginHorizontal: 5,
21+
borderRadius: 20,
22+
backgroundColor: "rgba(82, 82, 82, 0.5)",
23+
},
24+
selectedButton: {
25+
backgroundColor: "rgba(0, 0, 0, 0.7)",
26+
},
27+
toggleButtonText: {
28+
color: "white",
29+
fontWeight: "bold",
30+
},
31+
});

0 commit comments

Comments
 (0)
Please sign in to comment.