No Description

LoginScreen.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React, { Component } from "react";
  2. import { TextInput, TouchableWithoutFeedback, Keyboard, ImageBackground, Image } from "react-native";
  3. import firebase from "firebase";
  4. import { styles } from "../../config/styles";
  5. import CustomButton from "../../components/CustomButton";
  6. export default class LoginScreen extends Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. email: '',
  11. password: '',
  12. };
  13. this.onLogin = this.onLogin.bind(this)
  14. };
  15. onLogin() {
  16. const { email, password } = this.state;
  17. firebase.auth().signInWithEmailAndPassword(email, password).then((result) => {console.log(result)}).catch((error) => {console.log(error)})
  18. }
  19. render() {
  20. return (
  21. <TouchableWithoutFeedback style={styles.stdcontainer} onPress={Keyboard.dismiss} accessible={false}>
  22. <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
  23. <Image style={styles.logo} resizeMode="contain" source={require("../../assets/open-hand.png")}/>
  24. <TextInput style={styles.regtxtfield} placeholder="Email" onChangeText={(email) => this.setState({ email })}/>
  25. <TextInput style={styles.regtxtfield} placeholder="Password" onChangeText={(password) => this.setState({ password })} secureTextEntry={ true }/>
  26. <CustomButton marginTop={70} title="Login" onPress={() => this.onLogin()}/>
  27. <CustomButton marginTop={25} title="Register" onPress={() => this.props.navigation.navigate('Register')}/>
  28. </ImageBackground>
  29. </TouchableWithoutFeedback>
  30. );
  31. }
  32. }