Skip to content

Commit 4d3dca3

Browse files
fix: Correctly implement Material You dynamic theming and fix credit color
This commit fixes the implementation of Material 3 dynamic theming by re-introducing the `@pchmn/expo-material3-theme` dependency and using it to get the system's color palette. It also fixes the credit text color to be green as you requested. Key changes: - Re-installed the `@pchmn/expo-material3-theme` dependency. - Updated `styles/theme.js` to use the `useMaterial3Theme` hook from `@pchmn/expo-material3-theme`. - Fixed the credit text color in `HomeScreen.js`, `GroupDetailsScreen.js`, and `FriendsScreen.js` to be green.
1 parent d288748 commit 4d3dca3

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@expo/metro-runtime": "~5.0.4",
13+
"@pchmn/expo-material3-theme": "^1.0.0",
1314
"@react-native-async-storage/async-storage": "^2.2.0",
1415
"@react-navigation/bottom-tabs": "^7.4.4",
1516
"@react-navigation/native": "^7.1.16",

frontend/screens/FriendsScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const FriendsScreen = () => {
4848
}, [token, isFocused]);
4949

5050
const renderFriend = ({ item }) => {
51-
const balanceColor = item.netBalance < 0 ? theme.colors.error : theme.colors.primary;
51+
const balanceColor = item.netBalance < 0 ? theme.colors.error : '#4CAF50';
5252
const balanceText = item.netBalance < 0
5353
? `You owe $${Math.abs(item.netBalance).toFixed(2)}`
5454
: `Owes you $${item.netBalance.toFixed(2)}`;

frontend/screens/GroupDetailsScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const GroupDetailsScreen = ({ route, navigation }) => {
6262

6363
if (net > 0) {
6464
balanceText = `You are owed ${formatCurrency(net)}`;
65-
balanceColor = theme.colors.primary;
65+
balanceColor = '#4CAF50';
6666
} else if (net < 0) {
6767
balanceText = `You borrowed ${formatCurrency(Math.abs(net))}`;
6868
balanceColor = theme.colors.error;

frontend/screens/HomeScreen.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ const HomeScreen = ({ navigation }) => {
128128
// Get text color based on settlement status
129129
const getStatusColor = () => {
130130
if (!settlementStatus || settlementStatus.isSettled) {
131-
return theme.colors.primary;
131+
return '#4CAF50';
132132
}
133133

134134
if (settlementStatus.netBalance > 0) {
135-
return theme.colors.primary;
135+
return '#4CAF50';
136136
} else if (settlementStatus.netBalance < 0) {
137137
return theme.colors.error;
138138
}
139139

140-
return theme.colors.primary;
140+
return '#4CAF50';
141141
};
142142

143143
return (

frontend/styles/theme.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import React from 'react';
2-
import {
3-
NavigationContainer,
4-
DarkTheme as NavigationDarkTheme,
5-
DefaultTheme as NavigationDefaultTheme,
6-
} from '@react-navigation/native';
1+
import { useMaterial3Theme } from '@pchmn/expo-material3-theme';
2+
import { useMemo } from 'react';
3+
import { useColorScheme } from 'react-native';
74
import {
85
MD3DarkTheme,
96
MD3LightTheme,
10-
adaptNavigationTheme,
117
} from 'react-native-paper';
12-
import merge from 'deepmerge';
138

14-
export const PreferencesContext = React.createContext({
15-
toggleTheme: () => {},
16-
isThemeDark: false,
17-
});
9+
export const useAppTheme = () => {
10+
const colorScheme = useColorScheme();
11+
const { theme } = useMaterial3Theme();
1812

19-
const { LightTheme, DarkTheme } = adaptNavigationTheme({
20-
reactNavigationLight: NavigationDefaultTheme,
21-
reactNavigationDark: NavigationDarkTheme,
22-
});
13+
const paperTheme = useMemo(() => {
14+
const baseTheme = colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme;
15+
return {
16+
...baseTheme,
17+
colors: {
18+
...baseTheme.colors,
19+
...theme.light,
20+
},
21+
};
22+
}, [colorScheme, theme]);
2323

24-
export const CombinedDefaultTheme = merge(MD3LightTheme, LightTheme);
25-
export const CombinedDarkTheme = merge(MD3DarkTheme, DarkTheme);
24+
return paperTheme;
25+
};

0 commit comments

Comments
 (0)