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