-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathExpensesSummary.js
More file actions
38 lines (33 loc) · 898 Bytes
/
ExpensesSummary.js
File metadata and controls
38 lines (33 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { View, Text, StyleSheet } from 'react-native';
import { GlobalStyles } from '../../constants/styles';
function ExpensesSummary({ expenses, periodName }) {
const expensesSum = expenses.reduce((sum, expense) => {
return sum + expense.amount;
}, 0);
return (
<View style={styles.container}>
<Text style={styles.period}>{periodName}</Text>
<Text style={styles.sum}>${expensesSum.toFixed(2)}</Text>
</View>
);
}
export default ExpensesSummary;
const styles = StyleSheet.create({
container: {
padding: 8,
backgroundColor: GlobalStyles.colors.primary50,
borderRadius: 6,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
period: {
fontSize: 12,
color: GlobalStyles.colors.primary400,
},
sum: {
fontSize: 16,
fontWeight: 'bold',
color: GlobalStyles.colors.primary500,
},
});