mirror of
https://github.com/Stef-00012/Zipline-Android-App.git
synced 2025-05-11 18:35:58 +02:00
[nobuild] move tables into its own component
This commit is contained in:
parent
37e1496a68
commit
c7d0454195
13 changed files with 1578 additions and 1364 deletions
65
components/Table.tsx
Normal file
65
components/Table.tsx
Normal file
|
@ -0,0 +1,65 @@
|
|||
import type { ReactNode } from "react";
|
||||
import { type DimensionValue, ScrollView, View } from "react-native";
|
||||
import { Table as NativeTable, Row } from "react-native-reanimated-table";
|
||||
import { styles } from "@/styles/components/table";
|
||||
|
||||
interface Props {
|
||||
headerRow: Array<ReactNode>;
|
||||
rows: Array<Array<ReactNode>>;
|
||||
rowWidth: Array<number>;
|
||||
maxHeight?: DimensionValue;
|
||||
}
|
||||
|
||||
export default function Table({ headerRow, rows, rowWidth, maxHeight }: Props) {
|
||||
return (
|
||||
<ScrollView showsHorizontalScrollIndicator={false} horizontal>
|
||||
<View>
|
||||
<NativeTable>
|
||||
<Row
|
||||
data={headerRow}
|
||||
widthArr={rowWidth}
|
||||
style={styles.tableHeader}
|
||||
textStyle={{
|
||||
...styles.rowText,
|
||||
...styles.headerRow,
|
||||
}}
|
||||
/>
|
||||
</NativeTable>
|
||||
<ScrollView
|
||||
nestedScrollEnabled
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={styles.tableVerticalScroll}
|
||||
>
|
||||
<NativeTable>
|
||||
{rows.map((row, index) => {
|
||||
let rowStyle = styles.row;
|
||||
|
||||
if (index === 0)
|
||||
rowStyle = {
|
||||
...styles.row,
|
||||
...styles.firstRow,
|
||||
};
|
||||
|
||||
if (index === rows.length - 1)
|
||||
rowStyle = {
|
||||
...styles.row,
|
||||
...styles.lastRow,
|
||||
};
|
||||
|
||||
return (
|
||||
<Row
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: .
|
||||
key={index}
|
||||
data={row}
|
||||
widthArr={rowWidth}
|
||||
style={rowStyle}
|
||||
textStyle={styles.rowText}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</NativeTable>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue