1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Started moving components to own file

This commit is contained in:
Laurent Cozic 2017-05-09 19:17:58 +00:00
parent b6cf34450f
commit 61ea8f2963
7 changed files with 42 additions and 33 deletions

0
ReactNativeClient/android/gradlew vendored Normal file → Executable file
View File

View File

@ -9,10 +9,12 @@ import { WebApi } from 'src/web-api.js'
import { Database } from 'src/database.js'
//import { Session } from 'src/model/session.js';
import { SessionService } from 'src/service/session-service.js';
import { SessionService } from 'src/services/session-service.js';
import { Log } from 'src/log.js'
import { LoginButton } from 'src/components/login-button.js';
let debugMode = true;
let clientId = 'A7D301DA7D301DA7D301DA7D301DA7D3';
@ -24,7 +26,7 @@ db.open();
let defaultState = {
'myButtonLabel': 'clicko123456',
'myButtonLabel': 'click',
'counter': 0,
}
@ -54,16 +56,6 @@ function reducer(state, action) {
return state;
}
class MyButton extends Component {
render() {
var label = this.props.label;
if (label === undefined) label = '';
return <Button onPress={this.props.onPress} title={label} />
}
}
class MyInput extends Component {
render() {
@ -72,25 +64,6 @@ class MyInput extends Component {
}
const mapStateToButtonProps = function(state) {
return { label: state.myButtonLabel };
}
const mapDispatchToButtonProps = function(dispatch) {
return {
onPress: function() {
dispatch({
type: 'INC_COUNTER'
});
}
}
}
const MyConnectedButton = connect(
mapStateToButtonProps,
mapDispatchToButtonProps
)(MyButton)
const mapStateToInputProps = function(state) {
return {}
}
@ -117,8 +90,8 @@ class App extends Component {
return (
<Provider store={store}>
<View>
<MyConnectedButton />
<MyConnectionInput />
<LoginButton />
</View>
</Provider>
)

View File

@ -18,7 +18,7 @@
"redux": "3.6.0",
"react-redux": "4.4.8",
"query-string": "4.3.4",
"react-native-sqlite-storage": "3.3.*"
"react-native-sqlite-storage": "3.3.*",
},
"jest": {
"preset": "react-native"

View File

@ -0,0 +1,29 @@
import React, { Component } from 'react';
import { connect } from 'react-redux'
import { Button } from 'react-native';
import { _ } from 'src/locale.js';
class LoginButtonComponent extends Component {
render() {
return <Button onPress={this.props.onPress} title={_(this.props.label)} />
}
}
const LoginButton = connect(
(state) => {
return { label: state.myButtonLabel };
},
(dispatch) => {
return {
onPress: function() {
dispatch({
type: 'INC_COUNTER'
});
}
}
}
)(LoginButtonComponent)
export { LoginButton };

View File

@ -0,0 +1,7 @@
// This function does nothing for now, but later will return
// a different string depending on the language.
function _(s) {
return s;
}
export { _ };