import React from 'react'; import { ScrollView, TouchableOpacity, View, Text } from 'react-native'; import { CELL_WIDTH } from './TableCell'; import styles from './styles'; import Navigation from '../../lib/Navigation'; import I18n from '../../i18n'; import { themes } from '../../constants/colors'; interface ITable { children: JSX.Element; numColumns: number; theme: string; } const MAX_HEIGHT = 300; const Table = React.memo(({ children, numColumns, theme }: ITable) => { const getTableWidth = () => numColumns * CELL_WIDTH; const renderRows = (drawExtraBorders: boolean = true) => { const tableStyle = [styles.table, { borderColor: themes[theme].borderColor }]; if (drawExtraBorders) { tableStyle.push(styles.tableExtraBorders); } const rows: any = React.Children.toArray(children); rows[rows.length - 1] = React.cloneElement(rows[rows.length - 1], { isLastRow: true }); return ( {rows} ); }; const onPress = () => Navigation.navigate('MarkdownTableView', { renderRows, tableWidth: getTableWidth() }); return ( {renderRows(false)} {I18n.t('Full_table')} ); }); export default Table;