This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
interaktive-systeme/components/common/CategoryListItem.tsx
2024-01-05 00:46:40 +01:00

66 lines
No EOL
1.6 KiB
TypeScript

import { StyleSheet, Text, View, Pressable } from 'react-native'
import React from 'react'
import { Category } from '../../types/dbItems'
import CustomCard from './CustomCard';
import { SIZES } from '../../constants/theme';
import { useTheme } from '../../app/contexts/ThemeContext';
interface CategoryListItemProps{
category: Category;
onPress?: (category: Category) =>void | undefined
}
const CategoryListItem: React.FC<CategoryListItemProps> = (props: CategoryListItemProps) => {
const {category, onPress} = props;
const {colors} = useTheme();
const handlePress = ()=>{
if(onPress){
onPress(category);
}
}
return (
<Pressable onPress={handlePress}>
<View style={[styles.tile, {backgroundColor: colors.backgroundColor}]}>
<View style={[styles.colorTip, {backgroundColor: category.color}]}/>
<View style={[styles.textWrapper]}>
<Text style={[styles.text, {color: colors.primaryText}]}>{category.name ?? "#noData#"}</Text>
</View>
<View style={styles.tileTail}/>
</View>
</Pressable>
)
}
export default CategoryListItem
const styles = StyleSheet.create({
tile: {
height: 60,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
borderRadius: 20
},
colorTip:{
height: "100%",
width: 30,
borderTopLeftRadius:20,
borderBottomLeftRadius: 20
},
textWrapper: {
},
tileTail:{
height: "100%",
width: 30,
borderTopRightRadius:20,
borderBottomRightRadius: 20
},
text: {
fontSize: SIZES.large,
}
})