fixed the budget element and implemented onPress

This commit is contained in:
thschleicher 2024-01-05 10:52:02 +01:00
parent deda54152b
commit 7606c5d1b8
3 changed files with 50 additions and 26 deletions

View file

@ -1,4 +1,5 @@
import { ColorValue, StyleSheet, Text, View } from "react-native";
import { TouchableOpacity } from "react-native-gesture-handler";
import { useTheme } from "../../app/contexts/ThemeContext";
import CustomCard from "../common/CustomCard";
@ -8,6 +9,7 @@ export type CategoryItemProps = {
allocated_amount: number,
total_expenses: number,
category_guid: string,
onPress?: () => void,
}
const CategoryItem = (properties: CategoryItemProps) => {
@ -17,40 +19,46 @@ const CategoryItem = (properties: CategoryItemProps) => {
const subText = `${properties.total_expenses} / ${properties.allocated_amount}`;
return (
<CustomCard>
<View style={[styles.colorTipStyle, {backgroundColor: properties.color}]}></View>
<View style={[styles.textViewStyle]}>
<Text style={[styles.categoryNameStyle, {color: colors.primaryText}]}>
{properties.category}
</Text>
<Text style={[styles.subTextStyle, {color: colors.secondaryText}]}>
{subText}
</Text>
</View>
</CustomCard>
<TouchableOpacity onPress={properties.onPress}>
<CustomCard style={styles.customCardStyle}>
<View style={[styles.colorTipStyle, {backgroundColor: "blue"}]}/>
<View style={[styles.textViewStyle]}>
<Text style={[styles.categoryNameStyle, {color: colors.primaryText}]}>
{properties.category}
</Text>
<Text style={[styles.subTextStyle, {color: colors.secondaryText}]}>
{subText}
</Text>
</View>
</CustomCard>
</TouchableOpacity>
);
};
export default CategoryItem;
const styles = StyleSheet.create({
customCardStyle: {
flexDirection: "row",
justifyContent: "space-between",
},
colorTipStyle: {
width: 25,
borderTopLeftRadius: 10,
borderBottomLeftRadius: 10,
width: 25,
borderTopLeftRadius: 10,
borderBottomLeftRadius: 10,
},
textViewStyle: {
flex: 2,
flexDirection: "column",
paddingVertical: 5,
paddingHorizontal: 10,
alignSelf: "stretch",
flex: 2,
flexDirection: "column",
paddingVertical: 5,
paddingHorizontal: 10,
alignSelf: "stretch",
},
categoryNameStyle: {
fontSize: 30,
fontWeight: "bold",
fontSize: 30,
fontWeight: "bold",
},
subTextStyle: {
fontSize: 17.5,
fontSize: 17.5,
}
})
});