Skip to content

Instantly share code, notes, and snippets.

@popeating
Created August 4, 2020 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popeating/dfc20c620e831d72245e6d0c1ec24803 to your computer and use it in GitHub Desktop.
Save popeating/dfc20c620e831d72245e6d0c1ec24803 to your computer and use it in GitHub Desktop.
import React, { useContext } from 'react';
import { View, StyleSheet } from 'react-native';
import { Text, Button, Title, Paragraph } from 'react-native-paper';
import mainContext from '../context/mainContext'; //Don't forget the context
import Firebase from '../Firebase';
import loc from '../utils/localization';
const HomeScreen = () => {
const { currentUser } = Firebase.auth(); //we are getting the user from Firebase
const { signOutUser } = useContext(mainContext); //we are getting these functions from the context so that can be used here
const { inHome } = useContext(mainContext);
return (
<View style={styles.container}>
<View style={styles.box}>
<Title>Home Screen</Title>
</View>
<View style={styles.box}>
<Paragraph>{currentUser.email}</Paragraph>
</View>
<View style={styles.box}>
<Button onPress={() => signOutUser()} mode="contained" icon="logout">
{loc.t('signout')}
</Button>
</View>
<View style={styles.box}>
<Button onPress={() => inHome()} icon="camera" mode="contained">
{loc.t('theme')}
</Button>
</View>
</View>
);
};
const styles = StyleSheet.create({
inputContainer: {
width: '80%',
marginBottom: 20,
},
container: {
flex: 1,
//backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
box: {
marginBottom: 20,
},
});
export default HomeScreen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment