Newer
Older
import { TextInput, StyleSheet, KeyboardAvoidingView, Platform } from 'react-native';
import realm from '../lib/realm';
import { loginWithPassword, loadSubscriptions, Accounts } from '../lib/meteor';
const styles = StyleSheet.create({
view: {
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'stretch'
},
input: {
height: 40,
borderColor: '#aaa',
marginLeft: 20,
marginRight: 20,
marginTop: 10,
padding: 5,
borderWidth: 0,
backgroundColor: '#f6f6f6'
}
});
Accounts.onLogin(() => {
loadSubscriptions(() => {
navigate('Rooms');
});
});
export default class LoginView extends React.Component {
static propTypes = {
navigation: PropTypes.object.isRequired
}
static navigationOptions = () => ({
title: realm.objectForPrimaryKey('settings', 'Site_Name').value
});
constructor(props) {
super(props);
this.state = {
this.submit = () => {
loginWithPassword({ username: this.state.username }, this.state.password);
<KeyboardAvoidingView style={styles.view} behavior={Platform.OS === 'ios' && 'padding'}>
onChangeText={username => this.setState({ username })}
keyboardType='email-address'
autoCorrect={false}
returnKeyType='done'
autoCapitalize='none'
onChangeText={password => this.setState({ password })}
secureTextEntry
autoCorrect={false}
returnKeyType='done'
autoCapitalize='none'
onSubmitEditing={this.submit}