Merge branch 'repair' into 'main'
fixed the budget element and implemented onPress See merge request thschleicher/interaktive-systeme!44
This commit is contained in:
commit
b927b0e8a0
3 changed files with 50 additions and 26 deletions
|
|
@ -37,6 +37,10 @@ export default function Page() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCategoryPress = (item: {[column: string]: any;}) => {
|
||||||
|
console.log(item.category_name);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={[styles.safeAreaViewStyle, {backgroundColor: containerColor}]}>
|
<SafeAreaView style={[styles.safeAreaViewStyle, {backgroundColor: containerColor}]}>
|
||||||
<BudgetHeader selectedPage={selectedPage} handlePageSelection={handlePageSelection}/>
|
<BudgetHeader selectedPage={selectedPage} handlePageSelection={handlePageSelection}/>
|
||||||
|
|
@ -48,7 +52,15 @@ export default function Page() {
|
||||||
{isLoading ? (<LoadingSymbol/>) : (
|
{isLoading ? (<LoadingSymbol/>) : (
|
||||||
<FlatList
|
<FlatList
|
||||||
data={data}
|
data={data}
|
||||||
renderItem = {({item}) => <CategoryItem category={item.category_name} allocated_amount={item.allocated_amount ?? 0} color={item.category_color} category_guid={item.category_guid} total_expenses={item.total_expenses ?? 0}/>}
|
renderItem = {({item}) => <CategoryItem
|
||||||
|
category={item.category_name}
|
||||||
|
allocated_amount={item.allocated_amount ?? 0}
|
||||||
|
color={item.category_color}
|
||||||
|
category_guid={item.category_guid}
|
||||||
|
total_expenses={item.total_expenses ?? 0}
|
||||||
|
onPress={() => {
|
||||||
|
handleCategoryPress(item);
|
||||||
|
}}/>}
|
||||||
keyExtractor={item => item.category_guid}
|
keyExtractor={item => item.category_guid}
|
||||||
ItemSeparatorComponent={() => {
|
ItemSeparatorComponent={() => {
|
||||||
return (<View style={styles.itemSeperatorStyle}/>);
|
return (<View style={styles.itemSeperatorStyle}/>);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { StyleSheet, Text, TouchableHighlight, View } from "react-native";
|
import { StyleSheet, Text, TouchableHighlight, View } from "react-native";
|
||||||
import TextInputBar from "../common/TextInputBar";
|
|
||||||
import { useTheme } from "../../app/contexts/ThemeContext";
|
import { useTheme } from "../../app/contexts/ThemeContext";
|
||||||
|
import TextInputBar from "../common/TextInputBar";
|
||||||
|
|
||||||
type BudgetHeaderProperties = {
|
type BudgetHeaderProperties = {
|
||||||
selectedPage: string,
|
selectedPage: string,
|
||||||
|
|
@ -34,7 +34,7 @@ const BudgetHeader = (properties: BudgetHeaderProperties) => {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<TextInputBar placeholder='Search...'></TextInputBar>
|
<TextInputBar style={styles.searchBarStyle} placeholder='Search...'></TextInputBar>
|
||||||
</>);
|
</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,4 +81,8 @@ const styles = StyleSheet.create({
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
},
|
},
|
||||||
|
searchBarStyle: {
|
||||||
|
marginBottom: 20,
|
||||||
|
marginHorizontal: 10,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ColorValue, StyleSheet, Text, View } from "react-native";
|
import { ColorValue, StyleSheet, Text, View } from "react-native";
|
||||||
|
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||||
import { useTheme } from "../../app/contexts/ThemeContext";
|
import { useTheme } from "../../app/contexts/ThemeContext";
|
||||||
import CustomCard from "../common/CustomCard";
|
import CustomCard from "../common/CustomCard";
|
||||||
|
|
||||||
|
|
@ -8,6 +9,7 @@ export type CategoryItemProps = {
|
||||||
allocated_amount: number,
|
allocated_amount: number,
|
||||||
total_expenses: number,
|
total_expenses: number,
|
||||||
category_guid: string,
|
category_guid: string,
|
||||||
|
onPress?: () => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CategoryItem = (properties: CategoryItemProps) => {
|
const CategoryItem = (properties: CategoryItemProps) => {
|
||||||
|
|
@ -17,8 +19,9 @@ const CategoryItem = (properties: CategoryItemProps) => {
|
||||||
const subText = `${properties.total_expenses} / ${properties.allocated_amount} €`;
|
const subText = `${properties.total_expenses} / ${properties.allocated_amount} €`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomCard>
|
<TouchableOpacity onPress={properties.onPress}>
|
||||||
<View style={[styles.colorTipStyle, {backgroundColor: properties.color}]}></View>
|
<CustomCard style={styles.customCardStyle}>
|
||||||
|
<View style={[styles.colorTipStyle, {backgroundColor: "blue"}]}/>
|
||||||
<View style={[styles.textViewStyle]}>
|
<View style={[styles.textViewStyle]}>
|
||||||
<Text style={[styles.categoryNameStyle, {color: colors.primaryText}]}>
|
<Text style={[styles.categoryNameStyle, {color: colors.primaryText}]}>
|
||||||
{properties.category}
|
{properties.category}
|
||||||
|
|
@ -28,12 +31,17 @@ const CategoryItem = (properties: CategoryItemProps) => {
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</CustomCard>
|
</CustomCard>
|
||||||
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CategoryItem;
|
export default CategoryItem;
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
customCardStyle: {
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
},
|
||||||
colorTipStyle: {
|
colorTipStyle: {
|
||||||
width: 25,
|
width: 25,
|
||||||
borderTopLeftRadius: 10,
|
borderTopLeftRadius: 10,
|
||||||
|
|
@ -53,4 +61,4 @@ const styles = StyleSheet.create({
|
||||||
subTextStyle: {
|
subTextStyle: {
|
||||||
fontSize: 17.5,
|
fontSize: 17.5,
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
|
||||||
Reference in a new issue