Skip to content

Commit 9011da7

Browse files
This commit introduces a new "Friends" page to the application.
- A "Friends" tab has been added to the main navigation. - The new screen displays a list of friends (users from shared groups). - For each friend, it shows the net balance aggregated across all shared groups. - Each friend item can be expanded to show a breakdown of balances per group. - The client-side logic fetches all group data and calculates these balances.
1 parent b46be03 commit 9011da7

File tree

6 files changed

+800
-27
lines changed

6 files changed

+800
-27
lines changed

frontend/api/groups.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,10 @@ export const createExpense = (token, groupId, expenseData) => {
3737
};
3838

3939
export const getGroupDetails = (token, groupId) => {
40-
// Note: The backend doesn't seem to have a dedicated group details endpoint.
41-
// The POC reuses the group object from the list. We will do the same for now,
42-
// but in a real app, a dedicated endpoint would be better.
43-
// This is a placeholder for if we had one.
44-
// For now, we will fetch members and expenses separately.
45-
// This function can be used to get the group's basic info if needed.
46-
// However, the /groups endpoint already provides this.
47-
// We will simulate fetching details by combining other calls.
48-
// A single /groups/:id endpoint would be more efficient.
49-
// For now, let's assume we don't need this function and will get group name from navigation params.
50-
return Promise.resolve(null); // Placeholder
40+
return Promise.all([
41+
getGroupMembers(token, groupId),
42+
getGroupExpenses(token, groupId),
43+
]);
5144
};
5245

5346
export const getGroupMembers = (token, groupId) => {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
3+
import HomeScreen from '../screens/HomeScreen';
4+
import GroupDetailsScreen from '../screens/GroupDetailsScreen';
5+
import AddExpenseScreen from '../screens/AddExpenseScreen';
6+
import JoinGroupScreen from '../screens/JoinGroupScreen';
7+
8+
const Stack = createNativeStackNavigator();
9+
10+
const GroupsStackNavigator = () => {
11+
return (
12+
<Stack.Navigator>
13+
<Stack.Screen name="GroupsList" component={HomeScreen} options={{ headerShown: false }}/>
14+
<Stack.Screen name="GroupDetails" component={GroupDetailsScreen} />
15+
<Stack.Screen name="AddExpense" component={AddExpenseScreen} options={{ title: 'Add Expense' }} />
16+
<Stack.Screen name="JoinGroup" component={JoinGroupScreen} options={{ headerShown: false }} />
17+
</Stack.Navigator>
18+
);
19+
};
20+
21+
export default GroupsStackNavigator;

frontend/navigation/MainNavigator.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
import React from 'react';
2-
import { createNativeStackNavigator } from '@react-navigation/native-stack';
3-
import HomeScreen from '../screens/HomeScreen';
4-
import GroupDetailsScreen from '../screens/GroupDetailsScreen';
5-
import AddExpenseScreen from '../screens/AddExpenseScreen';
6-
import JoinGroupScreen from '../screens/JoinGroupScreen';
2+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
3+
import { MaterialCommunityIcons } from '@expo/vector-icons';
4+
import GroupsStackNavigator from './GroupsStackNavigator';
5+
import FriendsScreen from '../screens/FriendsScreen';
76

8-
const Stack = createNativeStackNavigator();
7+
const Tab = createBottomTabNavigator();
98

109
const MainNavigator = () => {
1110
return (
12-
<Stack.Navigator>
13-
<Stack.Screen name="Home" component={HomeScreen} options={{ headerShown: false }}/>
14-
<Stack.Screen name="GroupDetails" component={GroupDetailsScreen} />
15-
<Stack.Screen name="AddExpense" component={AddExpenseScreen} options={{ title: 'Add Expense' }} />
16-
<Stack.Screen name="JoinGroup" component={JoinGroupScreen} options={{ headerShown: false }} />
17-
</Stack.Navigator>
11+
<Tab.Navigator screenOptions={{ headerShown: false }}>
12+
<Tab.Screen
13+
name="Groups"
14+
component={GroupsStackNavigator}
15+
options={{
16+
tabBarIcon: ({ color, size }) => (
17+
<MaterialCommunityIcons name="account-group" color={color} size={size} />
18+
),
19+
}}
20+
/>
21+
<Tab.Screen
22+
name="Friends"
23+
component={FriendsScreen}
24+
options={{
25+
tabBarIcon: ({ color, size }) => (
26+
<MaterialCommunityIcons name="account-multiple" color={color} size={size} />
27+
),
28+
}}
29+
/>
30+
</Tab.Navigator>
1831
);
1932
};
2033

0 commit comments

Comments
 (0)