Rocket.Chat.ReactNative/app/views/MarkdownTableView.tsx

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-05-30 22:02:08 +00:00
import React, { useEffect } from 'react';
2019-12-11 23:01:12 +00:00
import { ScrollView } from 'react-native';
import I18n from '../i18n';
import { isIOS } from '../utils/deviceInfo';
2022-05-30 22:02:08 +00:00
import { useTheme } from '../theme';
2021-12-24 13:12:38 +00:00
import { ChatsStackParamList } from '../stacks/types';
2022-05-30 22:02:08 +00:00
import { IBaseScreen } from '../definitions';
2019-12-11 23:01:12 +00:00
2022-05-30 22:02:08 +00:00
type IMarkdownTableViewProps = IBaseScreen<ChatsStackParamList, 'MarkdownTableView'>;
2021-11-25 14:25:45 +00:00
2022-05-30 22:02:08 +00:00
const MarkdownTableView = ({ navigation, route }: IMarkdownTableViewProps): React.ReactElement => {
const renderRows = route.params?.renderRows;
const tableWidth = route.params?.tableWidth;
const { colors } = useTheme();
2019-12-11 23:01:12 +00:00
2022-05-30 22:02:08 +00:00
useEffect(() => {
navigation.setOptions({
title: I18n.t('Table')
});
}, []);
2019-12-11 23:01:12 +00:00
2022-05-30 22:02:08 +00:00
if (isIOS) {
2019-12-11 23:01:12 +00:00
return (
2022-05-30 22:02:08 +00:00
<ScrollView style={{ backgroundColor: colors.backgroundColor }} contentContainerStyle={{ width: tableWidth }}>
{renderRows()}
2019-12-11 23:01:12 +00:00
</ScrollView>
);
}
2022-05-30 22:02:08 +00:00
return (
<ScrollView style={{ backgroundColor: colors.backgroundColor }}>
<ScrollView horizontal>{renderRows()}</ScrollView>
</ScrollView>
);
};
export default MarkdownTableView;