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:
parent
b6cf34450f
commit
61ea8f2963
0
ReactNativeClient/android/gradlew
vendored
Normal file → Executable file
0
ReactNativeClient/android/gradlew
vendored
Normal file → Executable 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>
|
||||
)
|
||||
|
@ -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"
|
||||
|
29
ReactNativeClient/src/components/login-button.js
Normal file
29
ReactNativeClient/src/components/login-button.js
Normal 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 };
|
7
ReactNativeClient/src/locale.js
Normal file
7
ReactNativeClient/src/locale.js
Normal 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 { _ };
|
Loading…
Reference in New Issue
Block a user