[FIX] Navigate to MarkdownTableView using tablets (#4222)

* [FIX] Navigate to MarkdownTableView using tablets

* [FIX] Navigate to MarkdownTableView using tablets

* fix lint

* update yarn.lock

Co-authored-by: Alex Junior <alexalexandrejr@gmail.com>
This commit is contained in:
Reinaldo Neto 2022-05-27 14:18:51 -03:00 committed by GitHub
parent 53aaae5d82
commit a82e3e6c1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View File

@ -2,11 +2,12 @@ import React from 'react';
import { ScrollView, Text, TouchableOpacity, View, ViewStyle } from 'react-native'; import { ScrollView, Text, TouchableOpacity, View, ViewStyle } from 'react-native';
import { CELL_WIDTH } from './TableCell'; import { CELL_WIDTH } from './TableCell';
import styles from './styles';
import Navigation from '../../lib/navigation/appNavigation'; import Navigation from '../../lib/navigation/appNavigation';
import styles from './styles';
import I18n from '../../i18n'; import I18n from '../../i18n';
import { TSupportedThemes } from '../../theme'; import { TSupportedThemes } from '../../theme';
import { themes } from '../../lib/constants'; import { themes } from '../../lib/constants';
import { useAppSelector } from '../../lib/hooks';
interface ITable { interface ITable {
children: React.ReactElement | null; children: React.ReactElement | null;
@ -18,6 +19,7 @@ const MAX_HEIGHT = 300;
const Table = React.memo(({ children, numColumns, theme }: ITable) => { const Table = React.memo(({ children, numColumns, theme }: ITable) => {
const getTableWidth = () => numColumns * CELL_WIDTH; const getTableWidth = () => numColumns * CELL_WIDTH;
const isMasterDetail = useAppSelector(state => state.app.isMasterDetail);
const renderRows = (drawExtraBorders = true) => { const renderRows = (drawExtraBorders = true) => {
const tableStyle: ViewStyle[] = [styles.table, { borderColor: themes[theme].borderColor }]; const tableStyle: ViewStyle[] = [styles.table, { borderColor: themes[theme].borderColor }];
@ -33,7 +35,16 @@ const Table = React.memo(({ children, numColumns, theme }: ITable) => {
return <View style={tableStyle}>{rows}</View>; return <View style={tableStyle}>{rows}</View>;
}; };
const onPress = () => Navigation.navigate('MarkdownTableView', { renderRows, tableWidth: getTableWidth() }); const onPress = () => {
if (isMasterDetail) {
Navigation.navigate('ModalStackNavigator', {
screen: 'MarkdownTableView',
params: { renderRows, tableWidth: getTableWidth() }
});
} else {
Navigation.navigate('MarkdownTableView', { renderRows, tableWidth: getTableWidth() });
}
};
return ( return (
<TouchableOpacity onPress={onPress}> <TouchableOpacity onPress={onPress}>

View File

@ -1,10 +1,12 @@
import React from 'react'; import React from 'react';
import { ScrollView, StyleSheet, View } from 'react-native'; import { ScrollView, StyleSheet, View } from 'react-native';
import { storiesOf } from '@storybook/react-native'; import { storiesOf } from '@storybook/react-native';
import { Provider } from 'react-redux';
import Markdown, { MarkdownPreview } from '../../app/containers/markdown'; import Markdown, { MarkdownPreview } from '../../app/containers/markdown';
import { themes } from '../../app/lib/constants'; import { themes } from '../../app/lib/constants';
import { TGetCustomEmoji, IEmoji } from '../../app/definitions/IEmoji'; import { TGetCustomEmoji, IEmoji } from '../../app/definitions/IEmoji';
import { store } from '.';
const theme = 'light'; const theme = 'light';
@ -42,7 +44,7 @@ const getCustomEmoji: TGetCustomEmoji = content => {
return customEmoji; return customEmoji;
}; };
const stories = storiesOf('Markdown', module); const stories = storiesOf('Markdown', module).addDecorator(story => <Provider store={store}>{story()}</Provider>);
stories.add('Text', () => ( stories.add('Text', () => (
<View style={styles.container}> <View style={styles.container}>

View File

@ -42,6 +42,7 @@ const reducers = combineReducers({
settings: {} settings: {}
}), }),
meteor: () => ({ connected: true }), meteor: () => ({ connected: true }),
activeUsers: () => ({ abc: { status: 'online', statusText: 'dog' } }) activeUsers: () => ({ abc: { status: 'online', statusText: 'dog' } }),
app: () => ({ isMasterDetail: false })
}); });
export const store = createStore(reducers); export const store = createStore(reducers);