-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathExpenseItem.js
More file actions
76 lines (70 loc) · 1.83 KB
/
ExpenseItem.js
File metadata and controls
76 lines (70 loc) · 1.83 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { Pressable, StyleSheet, Text, View } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { GlobalStyles } from '../../constants/styles';
import { getFormattedDate } from '../../util/date';
function ExpenseItem({ id, description, amount, date }) {
const navigation = useNavigation();
function expensePressHandler() {
navigation.navigate('ManageExpense', {
expenseId: id
});
}
return (
<Pressable
onPress={expensePressHandler}
style={({ pressed }) => pressed && styles.pressed}
>
<View style={styles.expenseItem}>
<View>
<Text style={[styles.textBase, styles.description]}>
{description}
</Text>
<Text style={styles.textBase}>{getFormattedDate(date)}</Text>
</View>
<View style={styles.amountContainer}>
<Text style={styles.amount}>{amount.toFixed(2)}</Text>
</View>
</View>
</Pressable>
);
}
export default ExpenseItem;
const styles = StyleSheet.create({
pressed: {
opacity: 0.75,
},
expenseItem: {
padding: 12,
marginVertical: 8,
backgroundColor: GlobalStyles.colors.primary500,
flexDirection: 'row',
justifyContent: 'space-between',
borderRadius: 6,
elevation: 3,
shadowColor: GlobalStyles.colors.gray500,
shadowRadius: 4,
shadowOffset: { width: 1, height: 1 },
shadowOpacity: 0.4,
},
textBase: {
color: GlobalStyles.colors.primary50,
},
description: {
fontSize: 16,
marginBottom: 4,
fontWeight: 'bold',
},
amountContainer: {
paddingHorizontal: 12,
paddingVertical: 4,
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 4,
minWidth: 80,
},
amount: {
color: GlobalStyles.colors.primary500,
fontWeight: 'bold',
},
});