Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component,Buffer } from 'react';
- import { AppRegistry, Text, Image, View, TextInput, Button, Alert,Linking,StyleSheet,RCTView} from 'react-native';
- //const hash = new Buffer(`${username}:${password}`).toString('base64')
- export default class AwesomeProject extends Component {
- constructor(props) {
- super(props);
- this.state = {
- username: 't.chrobak',
- password: '1234qwer'
- }
- }
- _onPressButton() {
- let username = this.state.username, password = this.state.password;
- var data = new FormData();
- data.append( 'apiKey', '2esde2#derdsr#RD' );
- data.append( 'login', this.username );
- data.append( 'password', this.password );
- fetch("http://www.beinsured.t.test.ideo.pl/api/v1/1/pl/RestAuth/signIn/",
- {
- method: 'POST',
- body: data
- })
- .then(function(res){ return res; })
- .then(function(data){ alert( JSON.stringify( data ) ) })
- }
- render() {
- return (
- <View style={{marginTop:100}}>
- <View style={{alignItems:'center',justifyContent:'center'}}>
- <Image
- style={{width: 200,justifyContent:'center', height:200,marginBottom:-10, resizeMode: 'contain'}}
- source={require('./app/images/logo.png')}
- />
- </View>
- <View style={{marginLeft:40, marginRight:40}}>
- <TextInput
- style={styles.inputText}
- placeholder='Login'
- underlineColorAndroid= 'transparent'
- placeholderTextColor= '#959595'
- onChangeText={(username) => this.setState({username})}
- value={this.state.username}
- />
- <TextInput
- style={styles.inputText}
- placeholder='Hasło'
- underlineColorAndroid= 'transparent'
- placeholderTextColor= '#959595'
- onChangeText={(password) => this.setState({password})}
- value={this.state.password}
- secureTextEntry={true}
- />
- <View style={{marginTop: 10, marginBottom:10,}}>
- <Button
- onPress={this._onPressButton}
- title="Zaloguj"
- color="#ff7200"
- style={styles.button}
- />
- </View>
- <Text style={{textAlign: 'center'}}>
- Jeśli nie masz jeszcze konta zarejestruj się na beinsured.pl
- </Text>
- <Text style={{color: '#922051',textAlign:'center'}}
- onPress={() => Linking.openURL('http://www.beinsured.pl/pakiety/')}>
- Link
- </Text>
- </View>
- </View>
- );
- }
- }
- var styles = StyleSheet.create({
- container: {
- marginTop: 0,
- },
- inputText: {
- height: 40,
- borderWidth: 1,
- borderRadius: 5,
- backgroundColor: '#f1f1f1',
- color: '#5a5b5b',
- borderColor: '#e6e6e6',
- marginTop: 5,
- marginBottom: 5,
- fontFamily: 'OpenSans',
- },
- button: {
- borderWidth: 1,
- borderRadius: 5,
- borderColor: '#e36703',
- fontFamily: 'Helvetica',
- },
- });
- AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement