2019-09-03 19:27:57 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import { Text, View } from 'react-native';
|
|
|
|
|
2019-12-11 23:01:12 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
|
2019-09-03 19:27:57 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
export const CELL_WIDTH = 100;
|
|
|
|
|
|
|
|
const TableCell = React.memo(({
|
2019-12-11 23:01:12 +00:00
|
|
|
isLastCell, align, children, theme
|
2019-09-03 19:27:57 +00:00
|
|
|
}) => {
|
2019-12-11 23:01:12 +00:00
|
|
|
const cellStyle = [styles.cell, { borderColor: themes[theme].borderColor }];
|
2019-09-03 19:27:57 +00:00
|
|
|
if (!isLastCell) {
|
|
|
|
cellStyle.push(styles.cellRightBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
let textStyle = null;
|
|
|
|
if (align === 'center') {
|
|
|
|
textStyle = styles.alignCenter;
|
|
|
|
} else if (align === 'right') {
|
|
|
|
textStyle = styles.alignRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={[...cellStyle, { width: CELL_WIDTH }]}>
|
2019-12-11 23:01:12 +00:00
|
|
|
<Text style={[textStyle, { color: themes[theme].titleText }]}>
|
2019-09-03 19:27:57 +00:00
|
|
|
{children}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
TableCell.propTypes = {
|
|
|
|
align: PropTypes.oneOf(['', 'left', 'center', 'right']),
|
|
|
|
children: PropTypes.node,
|
2019-12-11 23:01:12 +00:00
|
|
|
isLastCell: PropTypes.bool,
|
|
|
|
theme: PropTypes.string
|
2019-09-03 19:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default TableCell;
|