2019-08-27 12:25:38 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
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';
|
|
|
|
|
|
|
|
const TableRow = React.memo(({
|
2019-12-04 16:39:53 +00:00
|
|
|
isLastRow, children: _children, theme
|
2019-08-27 12:25:38 +00:00
|
|
|
}) => {
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
const children = React.Children.toArray(_children);
|
|
|
|
children[children.length - 1] = React.cloneElement(children[children.length - 1], {
|
|
|
|
isLastCell: true
|
|
|
|
});
|
|
|
|
|
|
|
|
return <View style={rowStyle}>{children}</View>;
|
|
|
|
});
|
|
|
|
|
|
|
|
TableRow.propTypes = {
|
|
|
|
children: PropTypes.node,
|
2019-12-04 16:39:53 +00:00
|
|
|
isLastRow: PropTypes.bool,
|
|
|
|
theme: PropTypes.string
|
2019-08-27 12:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default TableRow;
|