1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Done login screen

This commit is contained in:
Laurent Cozic 2017-05-12 20:31:03 +00:00
parent af5d23af68
commit bc8fdf582a
3 changed files with 61 additions and 2 deletions

View File

@ -0,0 +1,55 @@
import React, { Component } from 'react';
import { View, Button, TextInput } from 'react-native';
import { connect } from 'react-redux'
import { Log } from 'src/log.js'
class LoginScreenComponent extends React.Component {
static navigationOptions = {
title: 'Login',
};
constructor() {
super();
this.state = { username: '', password: '' };
}
username_changeText = (text) => {
this.setState({ username: text });
}
password_changeText = (text) => {
this.setState({ password: text });
}
loginButton_press = () => {
Log.info('LOGIN');
// Note.save(this.state.note).then((note) => {
// this.props.dispatch({
// type: 'NOTES_UPDATE_ONE',
// note: note,
// });
// }).catch((error) => {
// Log.warn('Cannot save note', error);
// });
}
render() {
return (
<View style={{flex: 1}}>
<TextInput value={this.state.username} onChangeText={this.username_changeText} />
<TextInput value={this.state.password} onChangeText={this.password_changeText} />
<Button title="Login" onPress={this.loginButton_press} />
</View>
);
}
}
const LoginScreen = connect(
(state) => {
return {};
}
)(LoginScreenComponent)
export { LoginScreen };

View File

@ -18,7 +18,10 @@ class NotesScreenComponent extends React.Component {
}
loginButton_press = () => {
this.props.dispatch({
type: 'Navigation/NAVIGATE',
routeName: 'Login',
});
}
syncButton_press = () => {

View File

@ -13,6 +13,7 @@ import { Registry } from 'src/registry.js'
import { ItemList } from 'src/components/item-list.js'
import { NotesScreen } from 'src/components/screens/notes.js'
import { NoteScreen } from 'src/components/screens/note.js'
import { LoginScreen } from 'src/components/screens/login.js'
import { Setting } from 'src/models/setting.js'
let defaultState = {
@ -38,7 +39,6 @@ const reducer = (state = defaultState, action) => {
}
const nextStateNav = AppNavigator.router.getStateForAction(action, state.nav);
Log.info('NEXT', nextStateNav);
newState = Object.assign({}, state);
if (nextStateNav) {
newState.nav = nextStateNav;
@ -88,6 +88,7 @@ let store = createStore(reducer);
const AppNavigator = StackNavigator({
Notes: {screen: NotesScreen},
Note: {screen: NoteScreen},
Login: {screen: LoginScreen},
});
class AppComponent extends React.Component {