Advertisement
Guest User

Login.js

a guest
Dec 13th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { View, Image, ImageBackground, AsyncStorage } from 'react-native';
  3. import { Button } from '../components';
  4. import {Input} from '../components'
  5. import {LinearGradient} from 'expo-linear-gradient'
  6. import { login } from '../services/api';
  7.  
  8. export default class Login extends Component {
  9.  
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. username: '',
  14. password: '',
  15. }
  16. }
  17. _login = async () => {
  18. const { username, password } = this.state;
  19. const data = {
  20. username,
  21. password
  22. }
  23. console.log("DATA: ", data);
  24. const val = await login(data);
  25. if (val) {
  26. this.props.navigation.navigate('Home')
  27. }
  28. }
  29.  
  30. render() {
  31. return (
  32.  
  33. <LinearGradient colors={['#061071', '#015CA3', '#2DA6DD', '#061071']} style={styles.linearGradient}>
  34. <View style={styles.container}>
  35.  
  36.  
  37.  
  38. <Image style={styles.icon}
  39. source={{uri: "https://i.ibb.co/dfzQ3KC/user.png"}}
  40. />
  41.  
  42.  
  43. <Input style={styles.username} placeholder="Name" autoCompleteType='username' onChangeText={(text) => this.setState({username:text})}></Input>
  44. <Input style={styles.password} secureTextEntry={true} placeholder="Password" autoCompleteType='password' onChangeText={(text) => this.setState({password:text})}></Input>
  45. <Button onPress={this._login} outline>Login</Button>
  46. </View>
  47. </LinearGradient>
  48. )
  49. }
  50. }
  51.  
  52. const styles = {
  53. background: {
  54. justifyContent: 'flex-start',
  55. alignItems: 'center',
  56. width: '100%',
  57. height: '100%'
  58.  
  59. },
  60. container: {
  61. flex: 1,
  62. justifyContent: 'flex-start',
  63. alignItems: 'center',
  64. padding: 10,
  65. position: 'fixed',
  66. marginTop: '40%',
  67. marginBottom: '30%'
  68. },
  69. icon:{
  70. marginTop:10,
  71. marginBottom: 20,
  72. height: 50,
  73. width: 50,
  74. padding: 60,
  75. justifyContent: 'flex-start',
  76. alignItems: 'center'
  77. },
  78. title:{
  79. marginTop:10,
  80. marginBottom:30,
  81. fontSize:20,
  82. color: "white"
  83. },
  84. linearGradient: {
  85. flex: 1,
  86. paddingLeft: 15,
  87. paddingRight: 15,
  88. borderRadius: 5
  89. }
  90.  
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement