2019-08-27 12:25:38 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { ScrollView } from 'react-native';
|
2021-11-17 20:00:40 +00:00
|
|
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
|
|
|
import { RouteProp } from '@react-navigation/native';
|
2019-08-27 12:25:38 +00:00
|
|
|
|
|
|
|
import I18n from '../i18n';
|
|
|
|
import { isIOS } from '../utils/deviceInfo';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../constants/colors';
|
|
|
|
import { withTheme } from '../theme';
|
2021-12-03 19:27:57 +00:00
|
|
|
import { ChatsStackParamList } from '../stacks/types';
|
2019-08-27 12:25:38 +00:00
|
|
|
|
2021-11-17 20:00:40 +00:00
|
|
|
interface IMarkdownTableViewProps {
|
2021-12-03 19:27:57 +00:00
|
|
|
route: RouteProp<ChatsStackParamList, 'MarkdownTableView'>;
|
2021-11-17 20:00:40 +00:00
|
|
|
theme: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MarkdownTableView extends React.Component<IMarkdownTableViewProps> {
|
|
|
|
static navigationOptions = (): StackNavigationOptions => ({
|
2019-08-27 12:25:38 +00:00
|
|
|
title: I18n.t('Table')
|
2021-09-13 20:41:05 +00:00
|
|
|
});
|
2019-08-27 12:25:38 +00:00
|
|
|
|
|
|
|
render() {
|
2020-06-15 14:00:46 +00:00
|
|
|
const { route, theme } = this.props;
|
|
|
|
const renderRows = route.params?.renderRows;
|
|
|
|
const tableWidth = route.params?.tableWidth;
|
2019-08-27 12:25:38 +00:00
|
|
|
|
|
|
|
if (isIOS) {
|
|
|
|
return (
|
2019-12-04 16:39:53 +00:00
|
|
|
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }} contentContainerStyle={{ width: tableWidth }}>
|
2019-08-27 12:25:38 +00:00
|
|
|
{renderRows()}
|
|
|
|
</ScrollView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2019-12-04 16:39:53 +00:00
|
|
|
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
2021-09-13 20:41:05 +00:00
|
|
|
<ScrollView horizontal>{renderRows()}</ScrollView>
|
2019-08-27 12:25:38 +00:00
|
|
|
</ScrollView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-12-04 16:39:53 +00:00
|
|
|
|
|
|
|
export default withTheme(MarkdownTableView);
|