Chore: evaluate `AuthLoadingView` (#4102)

* chore: evaluate `AuthLoadingView`

* remove: `mapStateToProps`, `connect` and interface
This commit is contained in:
Gerzon Z 2022-05-03 12:25:18 -04:00 committed by GitHub
parent 0dc34f1eca
commit d277788dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 23 deletions

View File

@ -1,11 +1,11 @@
import React from 'react'; import React from 'react';
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native'; import { ActivityIndicator, StyleSheet, Text, View } from 'react-native';
import { connect } from 'react-redux'; import { useSelector } from 'react-redux';
import { IApplicationState } from '../definitions';
import I18n from '../i18n'; import I18n from '../i18n';
import StatusBar from '../containers/StatusBar'; import StatusBar from '../containers/StatusBar';
import { TSupportedThemes, withTheme } from '../theme'; import { useTheme } from '../theme';
import { themes } from '../lib/constants';
import sharedStyles from './Styles'; import sharedStyles from './Styles';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
@ -22,25 +22,20 @@ const styles = StyleSheet.create({
} }
}); });
interface IAuthLoadingView { const AuthLoadingView = React.memo((): React.ReactElement => {
theme: TSupportedThemes; const text = useSelector((state: IApplicationState) => state.app.text);
text: string; const { colors } = useTheme();
} return (
<View style={[styles.container, { backgroundColor: colors.backgroundColor }]}>
const AuthLoadingView = React.memo(({ theme, text }: IAuthLoadingView) => (
<View style={[styles.container, { backgroundColor: themes[theme].backgroundColor }]}>
<StatusBar /> <StatusBar />
{text ? ( {text ? (
<> <>
<ActivityIndicator color={themes[theme].auxiliaryText} size='large' /> <ActivityIndicator color={colors.auxiliaryText} size='large' />
<Text style={[styles.text, { color: themes[theme].bodyText }]}>{`${text}\n${I18n.t('Please_wait')}`}</Text> <Text style={[styles.text, { color: colors.bodyText }]}>{`${text}\n${I18n.t('Please_wait')}`}</Text>
</> </>
) : null} ) : null}
</View> </View>
)); );
const mapStateToProps = (state: any) => ({
text: state.app.text
}); });
export default connect(mapStateToProps)(withTheme(AuthLoadingView)); export default AuthLoadingView;