Skip to content

Commit 6fe980e

Browse files
committed
feat: implement theming with react-native-paper and navigation, enhance UI components
1 parent 2aacca8 commit 6fe980e

File tree

8 files changed

+262
-57
lines changed

8 files changed

+262
-57
lines changed

frontend/App.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import React from 'react';
2-
import AppNavigator from './navigation/AppNavigator';
1+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
32
import { PaperProvider } from 'react-native-paper';
43
import { AuthProvider } from './context/AuthContext';
4+
import AppNavigator from './navigation/AppNavigator';
5+
import { paperTheme } from './utils/theme';
56

67
export default function App() {
78
return (
89
<AuthProvider>
9-
<PaperProvider>
10-
<AppNavigator />
10+
<PaperProvider theme={paperTheme}>
11+
<GestureHandlerRootView style={{ flex: 1 }}>
12+
<AppNavigator />
13+
</GestureHandlerRootView>
1114
</PaperProvider>
1215
</AuthProvider>
1316
);

frontend/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { registerRootComponent } from 'expo';
2+
import 'react-native-gesture-handler';
23

34
import App from './App';
45

frontend/navigation/AppNavigator.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, { useContext } from 'react';
21
import { NavigationContainer } from '@react-navigation/native';
3-
import { View, ActivityIndicator, StyleSheet } from 'react-native';
2+
import { useContext } from 'react';
3+
import { ActivityIndicator, StyleSheet, View } from 'react-native';
44
import { AuthContext } from '../context/AuthContext';
5+
import { navTheme } from '../utils/theme';
56
import AuthNavigator from './AuthNavigator';
67
import MainNavigator from './MainNavigator';
78

@@ -17,7 +18,7 @@ const AppNavigator = () => {
1718
}
1819

1920
return (
20-
<NavigationContainer>
21+
<NavigationContainer theme={navTheme}>
2122
{token ? <MainNavigator /> : <AuthNavigator />}
2223
</NavigationContainer>
2324
);

frontend/navigation/GroupsStackNavigator.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ const Stack = createNativeStackNavigator();
99

1010
const GroupsStackNavigator = () => {
1111
return (
12-
<Stack.Navigator>
12+
<Stack.Navigator
13+
screenOptions={{
14+
animation: 'slide_from_right',
15+
headerShadowVisible: false,
16+
}}
17+
>
1318
<Stack.Screen name="GroupsList" component={HomeScreen} options={{ headerShown: false }}/>
14-
<Stack.Screen name="GroupDetails" component={GroupDetailsScreen} />
19+
<Stack.Screen name="GroupDetails" component={GroupDetailsScreen} options={{ animation: 'slide_from_right' }} />
1520
<Stack.Screen name="AddExpense" component={AddExpenseScreen} options={{ title: 'Add Expense' }} />
1621
<Stack.Screen name="JoinGroup" component={JoinGroupScreen} options={{ headerShown: false }} />
1722
<Stack.Screen name="GroupSettings" component={GroupSettingsScreen} options={{ title: 'Group Settings' }} />

frontend/navigation/MainNavigator.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
import React from 'react';
2-
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
31
import { MaterialCommunityIcons } from '@expo/vector-icons';
4-
import GroupsStackNavigator from './GroupsStackNavigator';
2+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
3+
import { useTheme } from '@react-navigation/native';
54
import FriendsScreen from '../screens/FriendsScreen';
65
import AccountStackNavigator from './AccountStackNavigator';
6+
import GroupsStackNavigator from './GroupsStackNavigator';
77

88
const Tab = createBottomTabNavigator();
99

1010
const MainNavigator = () => {
11+
const { colors } = useTheme();
1112
return (
12-
<Tab.Navigator screenOptions={{ headerShown: false }}>
13+
<Tab.Navigator
14+
screenOptions={{
15+
headerShown: false,
16+
tabBarActiveTintColor: colors.primary,
17+
tabBarInactiveTintColor: '#64748B',
18+
tabBarStyle: {
19+
backgroundColor: colors.card,
20+
borderTopColor: colors.border,
21+
height: 64,
22+
paddingBottom: 10,
23+
paddingTop: 8,
24+
},
25+
}}
26+
>
1327
<Tab.Screen
1428
name="Groups"
1529
component={GroupsStackNavigator}
16-
options={{
30+
options={{
1731
tabBarIcon: ({ color, size }) => (
1832
<MaterialCommunityIcons name="account-group" color={color} size={size} />
1933
),
@@ -22,7 +36,7 @@ const MainNavigator = () => {
2236
<Tab.Screen
2337
name="Friends"
2438
component={FriendsScreen}
25-
options={{
39+
options={{
2640
tabBarIcon: ({ color, size }) => (
2741
<MaterialCommunityIcons name="account-multiple" color={color} size={size} />
2842
),
@@ -31,7 +45,7 @@ const MainNavigator = () => {
3145
<Tab.Screen
3246
name="Account"
3347
component={AccountStackNavigator}
34-
options={{
48+
options={{
3549
tabBarIcon: ({ color, size }) => (
3650
<MaterialCommunityIcons name="account-cog" color={color} size={size} />
3751
),

frontend/screens/GroupDetailsScreen.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTheme } from "@react-navigation/native";
12
import { useContext, useEffect, useState } from "react";
23
import { Alert, FlatList, StyleSheet, Text, View } from "react-native";
34
import {
@@ -50,6 +51,8 @@ const GroupDetailsScreen = ({ route, navigation }) => {
5051
}
5152
};
5253

54+
const { colors } = useTheme();
55+
5356
useEffect(() => {
5457
navigation.setOptions({
5558
title: groupName,
@@ -76,23 +79,23 @@ const GroupDetailsScreen = ({ route, navigation }) => {
7679
const paidByMe = (item.paidBy || item.createdBy) === user._id;
7780
const net = paidByMe ? item.amount - userShare : -userShare;
7881

79-
let balanceText;
80-
let balanceColor = "black";
82+
let balanceText;
83+
let balanceColor = colors.text;
8184

8285
if (net > 0) {
8386
balanceText = `You are owed ${formatCurrency(net)}`;
84-
balanceColor = "green";
87+
balanceColor = "#16A34A";
8588
} else if (net < 0) {
8689
balanceText = `You borrowed ${formatCurrency(Math.abs(net))}`;
87-
balanceColor = "red";
90+
balanceColor = "#DC2626";
8891
} else {
8992
balanceText = "You are settled for this expense.";
9093
}
9194

9295
return (
93-
<Card style={styles.card}>
96+
<Card style={styles.card}>
9497
<Card.Content>
95-
<Title>{item.description}</Title>
98+
<Title>{item.description}</Title>
9699
<Paragraph>Amount: {formatCurrency(item.amount)}</Paragraph>
97100
<Paragraph>
98101
Paid by: {getMemberName(item.paidBy || item.createdBy)}
@@ -227,7 +230,8 @@ const styles = StyleSheet.create({
227230
alignItems: "center",
228231
},
229232
card: {
230-
marginBottom: 16,
233+
marginBottom: 16,
234+
borderRadius: 16,
231235
},
232236
expensesTitle: {
233237
marginTop: 16,

0 commit comments

Comments
 (0)