Skip to content

Commit 4493370

Browse files
authored
Merge pull request #5 from KushK04/socialfeeed
Socialfeeed
2 parents 38c0494 + 8faf736 commit 4493370

File tree

28 files changed

+3619
-47
lines changed

28 files changed

+3619
-47
lines changed

.env

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ DOMAIN=localhost
55
# To test the local Traefik config
66
# DOMAIN=localhost.tiangolo.com
77

8+
89
# Used by the backend to generate links in emails to the frontend
910
FRONTEND_HOST=http://localhost:5173
1011
# In staging and production, set this env var to the frontend host, e.g.
1112
# FRONTEND_HOST=https://dashboard.example.com
1213

14+
1315
# Environment: local, staging, production
1416
ENVIRONMENT=local
1517

18+
1619
PROJECT_NAME="Full Stack FastAPI Project"
1720
STACK_NAME=full-stack-fastapi-project
1821

22+
1923
# Backend
20-
BACKEND_CORS_ORIGINS="http://localhost,http://localhost:5173,https://localhost,https://localhost:5173,http://localhost.tiangolo.com"
21-
SECRET_KEY=changethis
24+
BACKEND_CORS_ORIGINS="http://localhost,http://localhost:5173,http://localhost:8081,https://localhost,https://localhost:5173,https://localhost:8081,http://localhost.tiangolo.com"
25+
SECRET_KEY=VfIGsNDeZkTOiSHIgoG9DjhpTyaLGBb-lZvYa8-wbTM
2226
FIRST_SUPERUSER=[email protected]
23-
FIRST_SUPERUSER_PASSWORD=changethis
27+
FIRST_SUPERUSER_PASSWORD=ierjXObp0qpZq82J
28+
2429

2530
# Emails
2631
SMTP_HOST=
@@ -31,15 +36,21 @@ SMTP_TLS=True
3136
SMTP_SSL=False
3237
SMTP_PORT=587
3338

39+
3440
# Postgres
3541
POSTGRES_SERVER=localhost
3642
POSTGRES_PORT=5432
3743
POSTGRES_DB=app
3844
POSTGRES_USER=postgres
39-
POSTGRES_PASSWORD=changethis
45+
POSTGRES_PASSWORD=SP52qKZTPKFTpi0w7adJJS80G4BpGDC4X2uxH5H7FYY
46+
4047

4148
SENTRY_DSN=
4249

50+
4351
# Configure these with your own Docker registry images
4452
DOCKER_IMAGE_BACKEND=backend
4553
DOCKER_IMAGE_FRONTEND=frontend
54+
55+
56+

KonditionExpo/app/(tabs)/_layout.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ export default function TabLayout() {
4747
tabBarIcon: ({ color }) => <IconSymbol size={28} name="clock.fill" color={color} />,
4848
}}
4949
/>
50+
<Tabs.Screen
51+
name="feed"
52+
options={{
53+
title: 'Feed',
54+
tabBarIcon: ({ color }) => <IconSymbol size={28} name="list.bullet" color={color} />,
55+
}}
56+
/>
57+
<Tabs.Screen
58+
name="social"
59+
options={{
60+
title: 'Social',
61+
tabBarIcon: ({ color }) => <IconSymbol size={28} name="person.2.fill" color={color} />,
62+
}}
63+
/>
5064
<Tabs.Screen
5165
name="profile"
5266
options={{

KonditionExpo/app/(tabs)/feed.tsx

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import React, { useEffect, useState } from 'react';
2+
import { View, StyleSheet, Alert } from 'react-native';
3+
import { router } from 'expo-router';
4+
import { useFeed, FeedType } from '../../contexts/FeedContext';
5+
import { FeedToggle, PostList, CreatePostButton } from '../../components/feed';
6+
import { WorkoutPostResponse } from '../../services/api';
7+
8+
export default function FeedScreen() {
9+
const {
10+
getCurrentFeed,
11+
currentFeedType,
12+
setCurrentFeedType,
13+
loadFeed,
14+
loadMorePosts,
15+
refreshFeed,
16+
isLoading,
17+
error,
18+
hasMore,
19+
personalFeed,
20+
publicFeed,
21+
combinedFeed,
22+
clearError,
23+
} = useFeed();
24+
25+
const [isRefreshing, setIsRefreshing] = useState(false);
26+
27+
useEffect(() => {
28+
// Load initial feed when component mounts
29+
loadFeed(currentFeedType, true);
30+
}, []);
31+
32+
useEffect(() => {
33+
// Show error alert if there's an error
34+
if (error) {
35+
Alert.alert('Error', error, [
36+
{ text: 'OK', onPress: clearError }
37+
]);
38+
}
39+
}, [error, clearError]);
40+
41+
const handleFeedTypeChange = async (feedType: FeedType) => {
42+
setCurrentFeedType(feedType);
43+
44+
// Load feed if it's empty or switch to a different type
45+
const targetFeed = getFeedForType(feedType);
46+
if (targetFeed.length === 0) {
47+
await loadFeed(feedType, true);
48+
}
49+
};
50+
51+
const getFeedForType = (feedType: FeedType): WorkoutPostResponse[] => {
52+
switch (feedType) {
53+
case 'personal':
54+
return personalFeed;
55+
case 'public':
56+
return publicFeed;
57+
case 'combined':
58+
return combinedFeed;
59+
default:
60+
return personalFeed;
61+
}
62+
};
63+
64+
const handleRefresh = async () => {
65+
setIsRefreshing(true);
66+
try {
67+
await refreshFeed();
68+
} finally {
69+
setIsRefreshing(false);
70+
}
71+
};
72+
73+
const handleLoadMore = async () => {
74+
await loadMorePosts();
75+
};
76+
77+
const handleCreatePost = () => {
78+
router.push('/create-post' as any);
79+
};
80+
81+
const handlePostPress = (post: WorkoutPostResponse) => {
82+
// Navigate to post detail or user profile
83+
console.log('Post pressed:', post.id);
84+
// TODO: Implement post detail navigation
85+
};
86+
87+
const postCounts = {
88+
personal: personalFeed.length,
89+
public: publicFeed.length,
90+
combined: combinedFeed.length,
91+
};
92+
93+
const currentFeed = getCurrentFeed();
94+
95+
return (
96+
<View style={styles.container}>
97+
<FeedToggle
98+
currentFeedType={currentFeedType}
99+
onFeedTypeChange={handleFeedTypeChange}
100+
postCounts={postCounts}
101+
/>
102+
103+
<PostList
104+
posts={currentFeed}
105+
isLoading={isLoading}
106+
isRefreshing={isRefreshing}
107+
hasMore={hasMore}
108+
onRefresh={handleRefresh}
109+
onLoadMore={handleLoadMore}
110+
onPostPress={handlePostPress}
111+
/>
112+
113+
<CreatePostButton onPress={handleCreatePost} />
114+
</View>
115+
);
116+
}
117+
118+
const styles = StyleSheet.create({
119+
container: {
120+
flex: 1,
121+
backgroundColor: '#f5f5f5',
122+
},
123+
});

0 commit comments

Comments
 (0)