{"size": 2143, "ext": "js", "max_stars_repo_path": "src/modules/login/TeacherLoginView.js", "max_stars_repo_name": "futurice/xprt-app-old", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/modules/login/TeacherLoginView.js", "max_issues_repo_name": "futurice/xprt-app-old", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/modules/login/TeacherLoginView.js", "max_forks_repo_name": "futurice/xprt-app-old", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.6057692308, "max_line_length": 65, "alphanum_fraction": 0.5921605226}
import * as NavigationState from '../navigation/NavigationState';
import * as AuthState from '../auth/AuthState';
import React, {PropTypes} from 'react';
import {
  StyleSheet,
  Text,
  View
} from 'react-native';

import {
  ButtonGroup
} from 'react-native-elements';

import LoginForm from '../../components/LoginForm';

const TeacherLoginView = React.createClass({
  getInitialState() {
    return {
      selectedIndex: 0,
    };
  },

  updateIndex(selectedIndex) {
    this.setState({selectedIndex: selectedIndex});
  },

  doLogin(credentials) {
    // Always succeed with login for now
    this.props.dispatch(AuthState.onUserLoginSuccess());
    console.log(credentials);
  },

  render() {
    const buttons = ['Teacher', 'Expert'];
    const selectedIndex = this.state.selectedIndex;

    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          {'Welcome to SCOOL!'}
        </Text>
        <Text style={styles.loginText}>
          {'Log in as:'}
        </Text>
        <ButtonGroup
          onPress={this.updateIndex}
          selectedIndex={selectedIndex}
          containerStyle={styles.buttonGroup}
          textStyle={styles.buttonGroupText}
          selectedBackgroundColor='yellow'
          underlayColor='white'
          buttons={buttons} />

        <LoginForm
          submit={this.doLogin}
          />

        <Text
          style={styles.forgot}
          onPress={() => this.props.forgot()}
        >
          Forgot your password?
        </Text>
      </View>
    );
  }
});

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white'
  },
  forgot: {
    marginTop: 20,
    fontSize: 16,
    textAlign: 'center'
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    color: 'black',
    marginTop: 50,
    marginBottom: 5
  },
  loginText: {
    fontSize: 18,
    textAlign: 'center',
    color: '#AAAAAA',
    marginBottom: 10,
    padding: 5
  },
  buttonGroup: {
    height: 40,
    backgroundColor: 'white'
  },
  buttonGroupText: {
    color: '#CCCCCC',
    fontSize: 18
  }
});

export default TeacherLoginView;
