import { View, Text, ScrollView, Pressable } from "react-native"; import { Style, Fonts, gutters, Palette } from "../styles"; import { Input } from "./Input"; import { mainBorderRadius } from "../styles/Style"; const Tableau = ({ headings = [], data = [], isEdit = false, onUpdate = () => {}, onPressRow = null, mainColor = Palette.primary, transparentColor = Palette.transparentPrimary, }) => { const filteredHeadings = headings.filter(({ condition = true }) => condition); return ( <> {filteredHeadings.map(({ title = "", flex }, index) => ( {title} ))} {data?.length > 0 ? ( {data.map((item, indexItemList) => { return ( <> onPressRow?.({ item })} style={{ ...Style.containerSpaceBetween, alignItems: "flex-start", paddingHorizontal: gutters / 2, }} > {filteredHeadings.map( ( { key, type = "DEFAULT", textStyle = () => {} }, indexColumn ) => { const { flex, isEditable, renderCell } = filteredHeadings[indexColumn]; const content = renderCell({ item, key, indexItemList, }); return ( {type === "CUSTOM" ? ( content ) : isEdit && isEditable ? ( onUpdate({ index: indexItemList, key, value, }) } type={!indexColumn ? "textarea" : "default"} borderType="dashed" containerStyle={{ borderRadius: mainBorderRadius / 2, width: "100%", backgroundColor: "transparent", // 'white }} textInputStyle={{ textAlign: !indexColumn ? "left" : indexColumn === filteredHeadings?.length - 1 ? "right" : "center", }} /> ) : ( {content} )} ); } )} ); })} ) : ( Il n'y a pas encore de données )} ); }; export default Tableau;