Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  import React, { Component,Buffer } from 'react';
  2.  import { AppRegistry, Text, Image, View, TextInput, Button, Alert,Linking,StyleSheet,RCTView} from 'react-native';
  3.  
  4. //const hash = new Buffer(`${username}:${password}`).toString('base64')
  5.  export default class AwesomeProject extends Component {
  6.    constructor(props) {
  7.     super(props);
  8.    this.state = {
  9.        username: 't.chrobak',
  10.        password: '1234qwer'
  11.     }
  12. }
  13.    _onPressButton() {
  14.      let username = this.state.username, password = this.state.password;
  15. var data = new FormData();
  16. data.append( 'apiKey', '2esde2#derdsr#RD' );
  17. data.append( 'login', this.username );
  18. data.append( 'password', this.password );
  19. fetch("http://www.beinsured.t.test.ideo.pl/api/v1/1/pl/RestAuth/signIn/",
  20. {
  21. method: 'POST',
  22. body: data
  23. })
  24. .then(function(res){ return res; })
  25. .then(function(data){ alert( JSON.stringify( data ) ) })
  26.  
  27.   }
  28.  
  29.  
  30.    render() {
  31.      return (
  32.    <View style={{marginTop:100}}>
  33.      <View style={{alignItems:'center',justifyContent:'center'}}>
  34.      <Image
  35.         style={{width: 200,justifyContent:'center', height:200,marginBottom:-10,  resizeMode: 'contain'}}
  36.       source={require('./app/images/logo.png')}
  37.      />
  38.    </View>
  39.    <View style={{marginLeft:40, marginRight:40}}>
  40.      <TextInput
  41.        style={styles.inputText}
  42.        placeholder='Login'
  43.        underlineColorAndroid= 'transparent'
  44.        placeholderTextColor= '#959595'
  45.        onChangeText={(username) => this.setState({username})}
  46.        value={this.state.username}
  47.      />
  48.      <TextInput
  49.        style={styles.inputText}
  50.        placeholder='Hasło'
  51.        underlineColorAndroid= 'transparent'
  52.        placeholderTextColor= '#959595'
  53.        onChangeText={(password) => this.setState({password})}
  54.        value={this.state.password}
  55.        secureTextEntry={true}
  56.      />
  57.      <View style={{marginTop: 10, marginBottom:10,}}>
  58.      <Button
  59.      onPress={this._onPressButton}
  60.     title="Zaloguj"
  61.     color="#ff7200"
  62.     style={styles.button}
  63.   />
  64. </View>
  65. <Text style={{textAlign: 'center'}}>
  66.   Jeśli nie masz jeszcze konta zarejestruj się na beinsured.pl
  67. </Text>
  68. <Text style={{color: '#922051',textAlign:'center'}}
  69.       onPress={() => Linking.openURL('http://www.beinsured.pl/pakiety/')}>
  70.   Link
  71. </Text>
  72.  </View>
  73.  </View>
  74.      );
  75.    }
  76.  }
  77.  var styles = StyleSheet.create({
  78.    container: {
  79.      marginTop: 0,
  80.    },
  81.    inputText: {
  82.      height: 40,
  83.      borderWidth: 1,
  84.      borderRadius: 5,
  85.      backgroundColor: '#f1f1f1',
  86.      color: '#5a5b5b',
  87.      borderColor: '#e6e6e6',
  88.      marginTop: 5,
  89.      marginBottom: 5,
  90.      fontFamily: 'OpenSans',
  91.    },
  92.    button: {
  93.      borderWidth: 1,
  94.      borderRadius: 5,
  95.      borderColor: '#e36703',
  96.      fontFamily: 'Helvetica',
  97.    },
  98.  });
  99.  
  100. AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement