Chore: Migrate WithoutServerView to hooks (#4415)

* migrate WithoutServerView to hooks

* remove navigation options

* minor tweak

Co-authored-by: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com>
Co-authored-by: Reinaldo Neto <reinaldonetof@hotmail.com>
This commit is contained in:
Gleidson Daniel Silva 2022-08-11 11:41:18 -03:00 committed by GitHub
parent 6b8086aa55
commit a101d319e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 26 deletions

View File

@ -72,7 +72,7 @@ const OutsideStack = () => {
return (
<Outside.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme) }}>
<Outside.Screen name='WithoutServersView' component={WithoutServersView} options={WithoutServersView.navigationOptions} />
<Outside.Screen name='WithoutServersView' component={WithoutServersView} />
</Outside.Navigator>
);
};

View File

@ -1,12 +1,12 @@
import React from 'react';
import React, { useLayoutEffect } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import ShareExtension from 'rn-extensions-share';
import { useNavigation } from '@react-navigation/native';
import * as HeaderButton from '../containers/HeaderButton';
import sharedStyles from './Styles';
import I18n from '../i18n';
import { themes } from '../lib/constants';
import { TSupportedThemes, withTheme } from '../theme';
import { useTheme } from '../theme';
import sharedStyles from './Styles';
const styles = StyleSheet.create({
container: {
@ -26,27 +26,25 @@ const styles = StyleSheet.create({
}
});
interface IWithoutServerViewProps {
theme: TSupportedThemes;
}
const WithoutServerView = (): React.ReactElement => {
const navigation = useNavigation();
const { colors } = useTheme();
class WithoutServerView extends React.Component<IWithoutServerViewProps> {
static navigationOptions = () => ({
useLayoutEffect(() => {
navigation.setOptions({
title: 'Rocket.Chat',
headerLeft: () => <HeaderButton.CancelModal onPress={ShareExtension.close} testID='share-extension-close' />
});
}, [navigation]);
render() {
const { theme } = this.props;
return (
<View style={[styles.container, { backgroundColor: themes[theme].backgroundColor }]}>
<Text style={[styles.title, { color: themes[theme].titleText }]}>{I18n.t('Without_Servers')}</Text>
<Text style={[styles.content, { color: themes[theme].titleText }]}>
<View style={[styles.container, { backgroundColor: colors.backgroundColor }]}>
<Text style={[styles.title, { color: colors.titleText }]}>{I18n.t('Without_Servers')}</Text>
<Text style={[styles.content, { color: colors.titleText }]}>
{I18n.t('You_need_to_access_at_least_one_RocketChat_server_to_share_something')}
</Text>
</View>
);
}
}
};
export default withTheme(WithoutServerView);
export default WithoutServerView;