Guest User

Untitled

a guest
Jan 5th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. import React, { Component } from "react";
  2. import { Image } from "react-native";
  3. import { connect } from "react-redux";
  4. import {
  5. Container,
  6. Content,
  7. Item,
  8. Input,
  9. Button,
  10. Icon,
  11. View,
  12. Text,
  13. Form
  14. } from "native-base";
  15. import { CustomText } from "../../components/CustomText";
  16. import { doLogin, informAppInitialized } from "../../redux/actions/auth";
  17. import styles from "./styles";
  18.  
  19. class Login extends Component {
  20.  
  21. static navigationOptions = {
  22. header: null
  23. };
  24.  
  25. state = {
  26. username : "",
  27. password : ""
  28. }
  29.  
  30. constructor(props) {
  31. super(props);
  32. }
  33.  
  34. componentDidMount() {
  35. this.props.informAppInitialized();
  36. }
  37.  
  38. componentWillReceiveProps(nextProps) {
  39. if (nextProps.auth.loginCompleted && !nextProps.auth.loginInProgress) {
  40. this.props.navigation.navigate("Home");
  41. }
  42. }
  43.  
  44. render() {
  45. let {username, password} = this.state;
  46. return (
  47. <Container>
  48. <View style={styles.logo}>
  49. <Image source={require("../../../images/hatay-belediyesi.png")} />
  50. </View>
  51. <View style={styles.bg}>
  52. <Form>
  53. <Item>
  54. <Input placeholder="Kullanıcı adı" value={username} onChangeText={(value) => this.setState({username : value})} autoCapitalize={"none"} />
  55. </Item>
  56. <Item last>
  57. <Input placeholder="Şifre" value={password} secureTextEntry={true} onChangeText={(value) => this.setState({password : value})} autoCapitalize={"none"} />
  58. </Item>
  59. </Form>
  60. <Button
  61. style={styles.btn}
  62. onPress={() => this.props.doLogin(this.state)}
  63. >
  64. <CustomText>Giriş Yap</CustomText>
  65. </Button>
  66. </View>
  67. </Container>
  68. );
  69. }
  70. }
  71.  
  72. function bindAction(dispatch) {
  73. return {
  74. informAppInitialized : () => dispatch(informAppInitialized()),
  75. doLogin: (loginInfo) => dispatch(doLogin(loginInfo))
  76. };
  77. }
  78.  
  79. const mapStateToProps = state => ({
  80. auth : state.auth
  81. });
  82.  
  83. export default connect(mapStateToProps, bindAction)(Login);
Add Comment
Please, Sign In to add comment