2019-08-27 12:25:38 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Text, 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-09-13 20:41:05 +00:00
|
|
|
interface ITableCell {
|
|
|
|
align: '' | 'left' | 'center' | 'right';
|
|
|
|
children: JSX.Element;
|
|
|
|
isLastCell: boolean;
|
|
|
|
theme: string;
|
|
|
|
}
|
|
|
|
|
2019-08-27 12:25:38 +00:00
|
|
|
export const CELL_WIDTH = 100;
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
const TableCell = React.memo(({ isLastCell, align, children, theme }: ITableCell) => {
|
2019-12-04 16:39:53 +00:00
|
|
|
const cellStyle = [styles.cell, { borderColor: themes[theme].borderColor }];
|
2019-08-27 12:25:38 +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 }]}>
|
2021-09-13 20:41:05 +00:00
|
|
|
<Text style={[textStyle, { color: themes[theme].bodyText }]}>{children}</Text>
|
2019-08-27 12:25:38 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
export default TableCell;
|