Skip to content

Commit a696aa3

Browse files
committed
auth helper fixes for android
1 parent 77e73f7 commit a696aa3

File tree

4 files changed

+51
-35
lines changed

4 files changed

+51
-35
lines changed

App/Components/Button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const Button = React.createClass({
4848
<Text
4949
key={index}
5050
allowFontScaling={false}
51-
style={[{flex: 0, paddingHorizontal: 5, textAlign: 'center'}, styles.text, disabledStateStyle, this._stylesFromType('text'), this.props.textStyle]}
51+
style={[{flex: 0, marginHorizontal: 5, textAlign: 'center'}, styles.text, disabledStateStyle, this._stylesFromType('text'), this.props.textStyle]}
5252
>
5353
{children}
5454
</Text>

App/Components/TextInput.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,49 @@ import React from 'react';
22

33
import {
44
PixelRatio,
5-
TextInput,
65
StyleSheet,
6+
TextInput,
77
} from 'react-native';
88

99
import cssVar from '../Lib/cssVar';
1010

11-
var _TextInput = React.createClass({
12-
propTypes: TextInput.propTypes,
11+
class _TextInput extends React.Component {
12+
constructor(props) {
13+
super(props);
14+
}
15+
16+
setNativeProps(...args) {
17+
this.refs.input.setNativeProps(...args);
18+
}
19+
20+
blur() {
21+
this.refs.input.blur();
22+
}
1323

1424
focus() {
1525
this.refs.input.focus();
16-
},
17-
18-
setNativeProps() {
19-
var input = this.refs.input;
20-
input.setNativeProps.apply(input, arguments);
21-
},
26+
}
2227

2328
render() {
2429
return (
2530
<TextInput
31+
ref='input'
2632
{...this.props}
27-
ref="input"
28-
style={[styles.input, this.props.style || {}]}
33+
style={[styles.input, this.props.style]}
2934
/>
3035
);
3136
}
32-
})
37+
}
3338

34-
var styles = StyleSheet.create({
39+
const styles = StyleSheet.create({
3540
input: {
3641
borderWidth: 1 / PixelRatio.get(),
3742
borderColor: cssVar('gray50'),
3843
padding: 10,
3944
fontFamily: cssVar('fontRegular'),
4045
color: cssVar('gray90'),
41-
fontSize: 8 // make it small to know it's not set
42-
}
46+
fontSize: 8, // make it small to know it's not set
47+
},
4348
});
4449

4550
export default _TextInput;

App/Mixins/AuthHelper.js

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,32 @@ var AuthHelper = {
7979
return (
8080
<View style={styles.container}>
8181
<View style={styles.flex} />
82-
<TextInput ref="username"
83-
placeholder={i18n.t('username')}
84-
keyboardType="default"
85-
style={[styles.input, styles.username]}
86-
enablesReturnKeyAutomatically={true}
87-
returnKeyType='next'
88-
onChange={(event) => this.state.username = event.nativeEvent.text }
89-
onSubmitEditing={() => this.refs.password.focus() }
82+
<View style={styles.inputContainer}>
83+
<TextInput ref="username"
84+
placeholder={i18n.t('username')}
85+
keyboardType="default"
86+
style={[styles.input, styles.username]}
87+
enablesReturnKeyAutomatically={true}
88+
autoCapitalize='none'
89+
autoCorrect={false}
90+
returnKeyType='next'
91+
onChange={(event) => this.state.username = event.nativeEvent.text }
92+
onSubmitEditing={() => this.refs.password.focus() }
93+
/>
94+
</View>
95+
<View style={styles.inputContainer}>
96+
<TextInput ref="password"
97+
placeholder={i18n.t('password')}
98+
secureTextEntry={true}
99+
autoCorrect={false}
100+
keyboardType="default"
101+
style={[styles.input, styles.password]}
102+
enablesReturnKeyAutomatically={true}
103+
returnKeyType='done'
104+
onChange={(event) => this.state.password = event.nativeEvent.text }
105+
onSubmitEditing={this.onAuthButton}
90106
/>
91-
<TextInput ref="password"
92-
placeholder={i18n.t('password')}
93-
password={true}
94-
autoCorrect={false}
95-
keyboardType="default"
96-
style={[styles.input, styles.password]}
97-
enablesReturnKeyAutomatically={true}
98-
returnKeyType='done'
99-
onChange={(event) => this.state.password = event.nativeEvent.text }
100-
onSubmitEditing={this.onAuthButton}
101-
/>
107+
</View>
102108
<Button type='blue' onPress={this.onAuthButton}>
103109
{this.getButtonText()}
104110
</Button>
@@ -153,8 +159,12 @@ var styles = StyleSheet.create({
153159
fontSize: 13,
154160
height: 50,
155161
padding: 10,
162+
flex: 1,
156163
marginHorizontal: 30
157164
},
165+
inputContainer: {
166+
flexDirection: 'row'
167+
},
158168
bottom: {
159169
flexDirection: 'row'
160170
},

android/app/app.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
8585
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8686
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
87+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
8788
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
8889
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
8990
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />

0 commit comments

Comments
 (0)