Chore: Evaluate BackgroundContainer - TypeScript (#3917)

* update: `BackgroundContainer`

* remove: `theme` from `IBackgroundContainer`

* update: return type for `BackgroundContainer`
This commit is contained in:
Gerzon Z 2022-03-17 17:21:19 -04:00 committed by GitHub
parent a1e33c4a69
commit 334b1bad7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 10 deletions

View File

@ -1,13 +1,12 @@
import React from 'react';
import { ActivityIndicator, ImageBackground, StyleSheet, Text, View } from 'react-native';
import { withTheme } from '../../theme';
import { useTheme } from '../../theme';
import sharedStyles from '../../views/Styles';
import { themes } from '../../constants/colors';
interface IBackgroundContainer {
text?: string;
theme?: string;
loading?: boolean;
}
@ -32,12 +31,15 @@ const styles = StyleSheet.create({
}
});
const BackgroundContainer = ({ theme, text, loading }: IBackgroundContainer) => (
const BackgroundContainer = ({ text, loading }: IBackgroundContainer): React.ReactElement => {
const { theme } = useTheme();
return (
<View style={styles.container}>
<ImageBackground source={{ uri: `message_empty_${theme}` }} style={styles.image} />
{text && !loading ? <Text style={[styles.text, { color: themes[theme!].auxiliaryTintColor }]}>{text}</Text> : null}
{loading ? <ActivityIndicator style={styles.text} color={themes[theme!].auxiliaryTintColor} /> : null}
{text && !loading ? <Text style={[styles.text, { color: themes[theme].auxiliaryTintColor }]}>{text}</Text> : null}
{loading ? <ActivityIndicator style={styles.text} color={themes[theme].auxiliaryTintColor} /> : null}
</View>
);
);
};
export default withTheme(BackgroundContainer);
export default BackgroundContainer;