import React, {Component} from 'react';
import {Button, Card, CardSection, Input} from './common';

class LoginForm extends Component {
  constructor(props) {
    super(props);
    this.state = {email: "", password: ''};
  }
  
  render() {
    return <Card>
      <CardSection>
        <Input label="Email"
               placeholder="user@gmail.com"
               onChangeText={email => this.setState({email})}
               value={this.state.email}/>
      </CardSection>
      
      <CardSection>
        <Input secureTextEntry
               label="Password"
               placeholder = "password"
               onChangeText={password => this.setState({password})}
               value = {this.state.password}
        />
      </CardSection>
      
      <CardSection>
        <Button>
          Log in
        </Button>
      </CardSection>
    </Card>
  }
}

export default LoginForm;
@@ -91,16 +91,84 @@
 common';
+%0Aimport firebase from 'firebase';%0Aimport %7BText%7D from 'react-native';
 %0A%0Aclass 
@@ -267,10 +267,10 @@
 il: 
-%22%22
+''
 , pa
@@ -283,10 +283,451 @@
 : ''
+, error: ''%7D;%0A  %7D%0A  %0A  async onButtonPress() %7B%0A    const %7Bemail, password%7D = this.state;%0A    this.setState(%7Berror: ''%7D);%0A    try %7B%0A      await firebase.auth().signInWithEmailAndPassword(email, password);%0A    %7D%0A    catch (err) %7B%0A      try %7B%0A        await firebase.auth().createUserWithEmailAndPassword(email, password);%0A      %7D%0A      catch (err) %7B%0A        console.log(%22error%22, err);%0A        this.setState(%7Berror: %22Login Failed%22%7D);%0A      %7D%0A    
 %7D
-;
 %0A  %7D
@@ -1095,19 +1095,17 @@
 ceholder
- = 
+=
 %22passwor
@@ -1195,19 +1195,17 @@
    value
- = 
+=
 %7Bthis.st
@@ -1267,112 +1267,350 @@
     
-%3CCardSection%3E%0A        %3CButton%3E%0A          Log in%0A        %3C/Button%3E%0A      %3C/CardSection%3E%0A    %3C/Card%3E%0A  %7D%0A%7D
+%0A      %3CText style=%7Bstyles.errorTextStyle%7D%3E%0A        %7Bthis.state.error%7D%0A      %3C/Text%3E%0A      %0A      %3CCardSection%3E%0A        %3CButton onPress=%7B()=%3Ethis.onButtonPress()%7D%3E%0A          Log in%0A        %3C/Button%3E%0A      %3C/CardSection%3E%0A    %3C/Card%3E%0A  %7D%0A%7D%0A%0Aconst styles = %7B%0A  errorTextStyle: %7B%0A    fontSize: 20,%0A    alignSelf: 'center',%0A    color: 'red'%0A  %7D%0A%7D;
 %0A%0Aex

Use firebase to authenticate users