Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Autor: Amin Fas
  3. Datum: 08.02.2019
  4. Beschreibung: DnF-Splashscreen
  5. */
  6. import React from 'react'
  7. import { View, TextInput, StyleSheet, TouchableOpacity, Text, Image } from 'react-native'
  8. import Icon from 'react-native-vector-icons/FontAwesome';
  9. import { Input , Button, ThemeProvider } from 'react-native-elements';
  10. import { bindActionCreators } from 'redux'
  11. import { connect } from 'react-redux'
  12. import { updateEmail, updatePassword, login, getUser } from '../actions/user'
  13. import Firebase from '../config/Firebase'
  14. import * as Font from 'expo-font';
  15.  
  16.  
  17. class Splashscreen extends React.Component {
  18.     componentDidMount = () => {
  19.         Firebase.auth().onAuthStateChanged(user => {
  20.             if (user) {
  21.                 this.props.getUser(user.uid)
  22.                 if (this.props.user != null) {
  23.                     this.props.navigation.navigate('Profile')
  24.                 }
  25.             }
  26.         })
  27.         Font.loadAsync({
  28.             'Caveat-Regular' : require('../assets/fonts/Caveat-Regular.ttf'),
  29.             'Catamaran-Regular': require('../assets/fonts/Catamaran-Regular.ttf'),
  30.             'Catamaran-Bold': require('../assets/fonts/Catamaran-Bold.ttf'),
  31.         });
  32.     }
  33.  
  34.     render() {
  35.         return (
  36.             <View style={styles.container}>
  37.                 <Image style={styles.logo} source={require('../assets/logo.png')}/>
  38.  
  39.                 <Image style={styles.img} source={require('../assets/Smile-Dog.png')}/>
  40.                
  41.                 <Text style={styles.title}>
  42.                     Hey du!
  43.                 </Text>
  44.                 <Text style={styles.loginText}>
  45.                 Endlich hast du Zeit für mich.{"\n"}
  46.                 </Text>
  47.  
  48.  
  49.                 <TouchableOpacity style={styles.btnlogin} onPress={() => this.props.navigation.navigate('Login')}>
  50.                     <Text style={styles.buttonText}>Login</Text>
  51.                     <Image style={styles.pawLogin} source={require('../assets/paw-login.png')}/>
  52.                 </TouchableOpacity>
  53.                
  54.                 <TouchableOpacity style={styles.btnregister} onPress={() => this.props.navigation.navigate('Signup')}>
  55.                     <Text style={styles.buttonText}>Registrieren</Text>
  56.                     <Image style={styles.pawRegister} source={require('../assets/paw-register.png')}/>
  57.                 </TouchableOpacity>
  58.  
  59.             </View>
  60.         )
  61.     }
  62. }
  63.  
  64. const styles = StyleSheet.create({
  65.     container: {
  66.         flex: 1,
  67.         backgroundColor: '#FFF5BF',
  68.         alignItems: 'center',
  69.         justifyContent: 'center',
  70.     },
  71.     logo:{
  72.         top: -150,
  73.     },
  74.     img:{
  75.         top: -150,
  76.     },
  77.     title:{
  78.         top: -140,
  79.         fontSize: 30,
  80.         fontFamily: 'Catamaran-Bold',
  81.         color: '#646464',
  82.     },
  83.     loginText:{
  84.         marginTop: -145,
  85.         fontSize: 20,
  86.         fontFamily:'Catamaran-Regular',
  87.         color: '#646464'
  88.     },
  89.     btnlogin: {
  90.         position:'absolute',
  91.         height: 150,
  92.         bottom: 50,
  93.         left: 20,
  94.         alignItems: 'center',
  95.         justifyContent: 'center',
  96.         width: 150
  97.     },
  98.     btnregister:{
  99.         position: 'absolute',
  100.         height: 150,
  101.         bottom: 50,
  102.         right: 20,
  103.         alignItems: 'center',
  104.         justifyContent: 'center',
  105.         width: 150,
  106.     },
  107.     buttonText: {
  108.         zIndex: 10,
  109.         fontSize: 30,
  110.         fontFamily: 'Caveat-Regular',
  111.         color: '#fff',
  112.         top: 15,
  113.         bottom: 0,
  114.         left: 10,
  115.         color: '#646464'
  116.     },
  117.     buttonSignup: {
  118.         fontSize: 12
  119.     },
  120.     pawLogin:{
  121.         position: 'absolute',
  122.         bottom: 0,
  123.         left: 0
  124.     },
  125.     pawRegister:{
  126.         position: 'absolute',
  127.         bottom: 0,
  128.         right: 0,
  129.     },
  130. })
  131.  
  132.  
  133. const mapDispatchToProps = dispatch => {
  134.     return bindActionCreators({ updateEmail, updatePassword, login, getUser }, dispatch)
  135. }
  136.  
  137. const mapStateToProps = state => {
  138.     return {
  139.         user: state.user
  140.     }
  141. }
  142.  
  143. export default connect(
  144.     mapStateToProps,
  145.     mapDispatchToProps
  146. )(Splashscreen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement