You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Started moving components to own file
This commit is contained in:
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 { Database } from 'src/database.js'
|
||||||
//import { Session } from 'src/model/session.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 { Log } from 'src/log.js'
|
||||||
|
|
||||||
|
import { LoginButton } from 'src/components/login-button.js';
|
||||||
|
|
||||||
|
|
||||||
let debugMode = true;
|
let debugMode = true;
|
||||||
let clientId = 'A7D301DA7D301DA7D301DA7D301DA7D3';
|
let clientId = 'A7D301DA7D301DA7D301DA7D301DA7D3';
|
||||||
@ -24,7 +26,7 @@ db.open();
|
|||||||
|
|
||||||
|
|
||||||
let defaultState = {
|
let defaultState = {
|
||||||
'myButtonLabel': 'clicko123456',
|
'myButtonLabel': 'click',
|
||||||
'counter': 0,
|
'counter': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,16 +56,6 @@ function reducer(state, action) {
|
|||||||
return state;
|
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 {
|
class MyInput extends Component {
|
||||||
|
|
||||||
render() {
|
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) {
|
const mapStateToInputProps = function(state) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
@ -117,8 +90,8 @@ class App extends Component {
|
|||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<View>
|
<View>
|
||||||
<MyConnectedButton />
|
|
||||||
<MyConnectionInput />
|
<MyConnectionInput />
|
||||||
|
<LoginButton />
|
||||||
</View>
|
</View>
|
||||||
</Provider>
|
</Provider>
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"redux": "3.6.0",
|
"redux": "3.6.0",
|
||||||
"react-redux": "4.4.8",
|
"react-redux": "4.4.8",
|
||||||
"query-string": "4.3.4",
|
"query-string": "4.3.4",
|
||||||
"react-native-sqlite-storage": "3.3.*"
|
"react-native-sqlite-storage": "3.3.*",
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "react-native"
|
"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 { _ };
|
Reference in New Issue
Block a user