Add autobind decorator and fix Android login screen
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
import { StyleSheet, Text, Image, Button } from 'react-native';
|
||||
import { reactAutoBind } from 'auto-bind2'
|
||||
|
||||
export class Error extends React.Component {
|
||||
static navigatorStyle = {
|
||||
@@ -17,11 +16,6 @@ export class Error extends React.Component {
|
||||
},
|
||||
})
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
reactAutoBind(this)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={Login.styles.page}>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import React from 'react';
|
||||
import { StyleSheet, Text, Image, Switch, TextInput, KeyboardAvoidingView, ScrollView, View, Button, Alert, InteractionManager } from 'react-native';
|
||||
import { Platform, StyleSheet, Text, Image, Switch, TextInput,
|
||||
KeyboardAvoidingView, ScrollView, View, Button, Alert, InteractionManager } from 'react-native';
|
||||
import logoImage from './images/deighton.png'
|
||||
import { FormBinder } from 'react-form-binder'
|
||||
import { api } from '../API'
|
||||
import { BoundSwitch, BoundInput, BoundButton } from '../ui'
|
||||
import { reactAutoBind } from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
export class Login extends React.Component {
|
||||
static navigatorStyle = {
|
||||
@@ -67,12 +68,12 @@ export class Login extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
reactAutoBind(this)
|
||||
this.state = {
|
||||
binder: new FormBinder({}, Login.bindings)
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleLogin() {
|
||||
let obj = this.state.binder.getModifiedFieldValues()
|
||||
let { navigator } = this.props
|
||||
@@ -88,7 +89,8 @@ export class Login extends React.Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<KeyboardAvoidingView style={Login.styles.page} behavior='padding'>
|
||||
<KeyboardAvoidingView style={Login.styles.page} behavior='padding'
|
||||
keyboardVerticalOffset={Platform.select({ios: () => 0, android: () => 200})}>
|
||||
<Image style={Login.styles.logo} source={logoImage} resizeMode='contain' />
|
||||
<View style={Login.styles.inputRow}>
|
||||
<BoundInput name='email' label='Email:' placeholder='name@xyz.com' message='Must enter a valid email' binder={this.state.binder} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { View, Text, TouchableHighlight } from 'react-native'
|
||||
import { reactAutoBind } from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
export class BoundButton extends React.Component {
|
||||
static propTypes = {
|
||||
@@ -15,7 +15,6 @@ export class BoundButton extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
reactAutoBind(this)
|
||||
|
||||
let { name, binder } = this.props
|
||||
|
||||
@@ -23,6 +22,7 @@ export class BoundButton extends React.Component {
|
||||
this.state = binder.getFieldState(name)
|
||||
}
|
||||
|
||||
@autobind
|
||||
updateValue(e) {
|
||||
this.setState(e.state)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { TextInput, Text, View } from 'react-native'
|
||||
import { reactAutoBind } from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
export class BoundInput extends React.Component {
|
||||
static propTypes = {
|
||||
@@ -15,10 +15,10 @@ export class BoundInput extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
reactAutoBind(this)
|
||||
this.state = props.binder.getFieldState(props.name)
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleChangeText(newText) {
|
||||
const { binder, name } = this.props
|
||||
const state = binder.getFieldState(name)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { View, Switch, Text } from 'react-native'
|
||||
import { reactAutoBind } from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
export class BoundSwitch extends React.Component {
|
||||
static propTypes = {
|
||||
@@ -12,10 +12,10 @@ export class BoundSwitch extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
reactAutoBind(this)
|
||||
this.state = props.binder.getFieldState(props.name)
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleValueChange() {
|
||||
const { binder, name } = this.props
|
||||
const state = binder.getFieldState(name)
|
||||
|
||||
Reference in New Issue
Block a user