Chore: evaluate `MarkdownTableView` (#4104)

This commit is contained in:
Gerzon Z 2022-05-13 08:57:19 -04:00 committed by GitHub
parent 81c6ffce40
commit 4d4a5cffd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 31 deletions

View File

@ -131,7 +131,7 @@ const ChatsStackNavigator = () => {
component={AddExistingChannelView}
options={AddExistingChannelView.navigationOptions}
/>
<ChatsStack.Screen name='MarkdownTableView' component={MarkdownTableView} options={MarkdownTableView.navigationOptions} />
<ChatsStack.Screen name='MarkdownTableView' component={MarkdownTableView} />
<ChatsStack.Screen name='ReadReceiptsView' component={ReadReceiptsView} options={ReadReceiptsView.navigationOptions} />
<ChatsStack.Screen name='QueueListView' component={QueueListView} options={QueueListView.navigationOptions} />
<ChatsStack.Screen name='CannedResponsesListView' component={CannedResponsesListView} />

View File

@ -166,7 +166,7 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => {
<ModalStack.Screen name='ThreadMessagesView' component={ThreadMessagesView} />
<ModalStack.Screen name='DiscussionsView' component={DiscussionsView} />
<ModalStack.Screen name='TeamChannelsView' component={TeamChannelsView} options={TeamChannelsView.navigationOptions} />
<ModalStack.Screen name='MarkdownTableView' component={MarkdownTableView} options={MarkdownTableView.navigationOptions} />
<ModalStack.Screen name='MarkdownTableView' component={MarkdownTableView} />
<ModalStack.Screen
name='ReadReceiptsView'
component={ReadReceiptsView}

View File

@ -1,43 +1,38 @@
import React from 'react';
import React, { useEffect } from 'react';
import { ScrollView } from 'react-native';
import { StackNavigationOptions } from '@react-navigation/stack';
import { RouteProp } from '@react-navigation/native';
import I18n from '../i18n';
import { isIOS } from '../utils/deviceInfo';
import { themes } from '../lib/constants';
import { TSupportedThemes, withTheme } from '../theme';
import { useTheme } from '../theme';
import { ChatsStackParamList } from '../stacks/types';
import { IBaseScreen } from '../definitions';
interface IMarkdownTableViewProps {
route: RouteProp<ChatsStackParamList, 'MarkdownTableView'>;
theme: TSupportedThemes;
}
type IMarkdownTableViewProps = IBaseScreen<ChatsStackParamList, 'MarkdownTableView'>;
class MarkdownTableView extends React.Component<IMarkdownTableViewProps> {
static navigationOptions = (): StackNavigationOptions => ({
title: I18n.t('Table')
});
const MarkdownTableView = ({ navigation, route }: IMarkdownTableViewProps): React.ReactElement => {
const renderRows = route.params?.renderRows;
const tableWidth = route.params?.tableWidth;
const { colors } = useTheme();
render() {
const { route, theme } = this.props;
const renderRows = route.params?.renderRows;
const tableWidth = route.params?.tableWidth;
if (isIOS) {
return (
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }} contentContainerStyle={{ width: tableWidth }}>
{renderRows()}
</ScrollView>
);
}
useEffect(() => {
navigation.setOptions({
title: I18n.t('Table')
});
}, []);
if (isIOS) {
return (
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }}>
<ScrollView horizontal>{renderRows()}</ScrollView>
<ScrollView style={{ backgroundColor: colors.backgroundColor }} contentContainerStyle={{ width: tableWidth }}>
{renderRows()}
</ScrollView>
);
}
}
export default withTheme(MarkdownTableView);
return (
<ScrollView style={{ backgroundColor: colors.backgroundColor }}>
<ScrollView horizontal>{renderRows()}</ScrollView>
</ScrollView>
);
};
export default MarkdownTableView;