Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from "react";
- import { Button, StyleSheet, TextInput, View } from "react-native";
- export default class App extends Component {
- state = {
- email: "",
- password: ""
- };
- constructor(props) {
- super(props);
- this.handleChangeEmail = this.handleChangeEmail.bind(this)
- this.handleChangePassword = this.handleChangePassword.bind(this);
- this.handleLoginPress = this.handleLoginPress.bind(this);
- }
- handleChangeEmail(text) {
- this.setState({
- email: text
- });
- }
- handleChangePassword(text) {
- this.setState({
- password: text
- });
- }
- handleLoginPress() {
- alert(
- `Your email: ${this.state.email}. And your password: ${
- this.state.password
- }`
- );
- }
- render() {
- return (
- <View style={styles.container}>
- <TextInput
- onChangeText={this.handleChangeEmail}
- placeholder={"user@email.com"}
- style={styles.textInput}
- />
- <TextInput
- onChangeText={this.handleChangePassword}
- secureTextEntry={true}
- placeholder={"Your super secret password"}
- style={styles.textInput}
- />
- <Button title={"Login"} onPress={this.handleLoginPress} />
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: "#F5FCFF",
- justifyContent: "center",
- alignItems: "center"
- },
- welcome: {
- fontSize: 20,
- textAlign: "center",
- margin: 10
- },
- textInput: {
- borderWidth: 1,
- borderColor: "mediumaquamarine",
- height: 45,
- width: 300,
- padding: 5,
- marginBottom: 22
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement