Skip to content

Commit 4b7a0c3

Browse files
This commit enhances the UI by displaying group icons.
- The groups list now shows an icon for each group, with a fallback to the group's first initial. - The group details screen also displays the icon in its header for a consistent user experience.
1 parent e201e83 commit 4b7a0c3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

frontend/screens/GroupDetailsScreen.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useState, useEffect, useContext } from 'react';
22
import { View, StyleSheet, FlatList, Alert, ScrollView } from 'react-native';
3-
import { Button, Text, Card, ActivityIndicator, Appbar, FAB, Title, Paragraph } from 'react-native-paper';
3+
import { Button, Text, Card, ActivityIndicator, Appbar, FAB, Title, Paragraph, Avatar } from 'react-native-paper';
44
import { AuthContext } from '../context/AuthContext';
55
import { getGroupMembers, getGroupExpenses, getOptimizedSettlements } from '../api/groups';
66

77
const GroupDetailsScreen = ({ route, navigation }) => {
8-
const { groupId, groupName } = route.params;
8+
const { groupId, groupName, groupIcon } = route.params;
99
const { token, user } = useContext(AuthContext);
1010
const [members, setMembers] = useState([]);
1111
const [expenses, setExpenses] = useState([]);
@@ -120,7 +120,8 @@ const GroupDetailsScreen = ({ route, navigation }) => {
120120
<View style={styles.container}>
121121
<Appbar.Header>
122122
<Appbar.BackAction onPress={() => navigation.goBack()} />
123-
<Appbar.Content title={groupName} />
123+
<Avatar.Text size={36} label={groupIcon || groupName.charAt(0)} style={{marginLeft: 8}} />
124+
<Appbar.Content title={groupName} titleStyle={{marginLeft: 8}}/>
124125
</Appbar.Header>
125126

126127
<ScrollView style={styles.contentContainer}>

frontend/screens/HomeScreen.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useEffect, useContext } from 'react';
22
import { View, StyleSheet, FlatList, Alert } from 'react-native';
3-
import { Button, Text, Card, ActivityIndicator, Appbar, Modal, Portal, TextInput } from 'react-native-paper';
3+
import { Button, Text, Card, ActivityIndicator, Appbar, Modal, Portal, TextInput, Avatar } from 'react-native-paper';
44
import { AuthContext } from '../context/AuthContext';
55
import { getGroups, createGroup } from '../api/groups';
66

@@ -56,8 +56,11 @@ const HomeScreen = ({ navigation }) => {
5656
};
5757

5858
const renderGroup = ({ item }) => (
59-
<Card style={styles.card} onPress={() => navigation.navigate('GroupDetails', { groupId: item._id, groupName: item.name })}>
60-
<Card.Title title={item.name} />
59+
<Card style={styles.card} onPress={() => navigation.navigate('GroupDetails', { groupId: item._id, groupName: item.name, groupIcon: item.icon })}>
60+
<Card.Title
61+
title={item.name}
62+
left={(props) => <Avatar.Text {...props} label={item.icon || item.name.charAt(0)} />}
63+
/>
6164
<Card.Content>
6265
<Text>Join Code: {item.joinCode}</Text>
6366
<Text>You are settled up.</Text>

0 commit comments

Comments
 (0)