2019-08-27 12:25:38 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View } from 'react-native';
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
|
2019-08-27 12:25:38 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
2021-07-21 15:15:13 +00:00
|
|
|
interface ITableRow {
|
|
|
|
children: JSX.Element;
|
|
|
|
isLastRow: boolean;
|
|
|
|
theme: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TableRow = React.memo(({ isLastRow, children: _children, theme }: ITableRow) => {
|
2019-12-04 16:39:53 +00:00
|
|
|
const rowStyle = [styles.row, { borderColor: themes[theme].borderColor }];
|
2019-08-27 12:25:38 +00:00
|
|
|
if (!isLastRow) {
|
|
|
|
rowStyle.push(styles.rowBottomBorder);
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:15:13 +00:00
|
|
|
const children: any = React.Children.toArray(_children);
|
2019-08-27 12:25:38 +00:00
|
|
|
children[children.length - 1] = React.cloneElement(children[children.length - 1], {
|
|
|
|
isLastCell: true
|
|
|
|
});
|
|
|
|
|
|
|
|
return <View style={rowStyle}>{children}</View>;
|
|
|
|
});
|
|
|
|
|
|
|
|
export default TableRow;
|