diff --git a/ReactNativeClient/src/components/create-note-button.js b/ReactNativeClient/src/components/create-note-button.js
new file mode 100644
index 000000000..99b2b2d78
--- /dev/null
+++ b/ReactNativeClient/src/components/create-note-button.js
@@ -0,0 +1,31 @@
+// import React, { Component } from 'react';
+// import { connect } from 'react-redux'
+// import { Button } from 'react-native';
+// import { _ } from 'src/locale.js';
+
+// class CreateNoteButtonComponent extends Component {
+
+// render() {
+// return
+// }
+
+// }
+
+// const CreateNoteButton = connect(
+// (state) => {
+// return {
+// selectedNoteId: selectedNoteId,
+// };
+// },
+// (dispatch) => {
+// return {
+// onPress: function() {
+// dispatch({
+// type: 'VIEW_NOTE'
+// });
+// }
+// }
+// }
+// )(CreateNoteButtonComponent)
+
+// export { CreateNoteButton };
\ No newline at end of file
diff --git a/ReactNativeClient/src/components/item-list.js b/ReactNativeClient/src/components/item-list.js
index 60296f869..0b581824d 100644
--- a/ReactNativeClient/src/components/item-list.js
+++ b/ReactNativeClient/src/components/item-list.js
@@ -49,8 +49,9 @@ const ItemList = connect(
return {
onItemClick: (noteId) => {
dispatch({
- type: 'VIEW_NOTE',
- id: noteId,
+ type: 'Navigation/NAVIGATE',
+ routeName: 'Note',
+ noteId: noteId,
});
}
}
diff --git a/ReactNativeClient/src/models/note.js b/ReactNativeClient/src/models/note.js
new file mode 100644
index 000000000..333c8b9e2
--- /dev/null
+++ b/ReactNativeClient/src/models/note.js
@@ -0,0 +1,14 @@
+import { BaseModel } from 'src/base-model.js';
+
+class Note extends BaseModel {
+
+ static noteById(notes, id) {
+ for (let i = 0; i < notes.length; i++) {
+ if (notes[i].id == id) return notes[i];
+ }
+ return null;
+ }
+
+}
+
+export { Note };
\ No newline at end of file
diff --git a/ReactNativeClient/src/root.js b/ReactNativeClient/src/root.js
index f7be4bf4e..85ce3e80f 100644
--- a/ReactNativeClient/src/root.js
+++ b/ReactNativeClient/src/root.js
@@ -7,6 +7,7 @@ import { combineReducers } from 'redux';
import { StackNavigator } from 'react-navigation';
import { addNavigationHelpers } from 'react-navigation';
import { Log } from 'src/log.js'
+import { Note } from 'src/models/note.js'
import { ItemList } from 'src/components/item-list.js'
let defaultState = {
@@ -23,30 +24,39 @@ let defaultState = {
const reducer = (state = defaultState, action) => {
Log.info('Reducer action', action);
+ let newState = state;
+
switch (action.type) {
case 'Navigation/NAVIGATE':
case 'Navigation/BACK':
- const nextStateNav = AppNavigator.router.getStateForAction(action, state.nav);
- if (!nextStateNav) return state;
- let newState = Object.assign({}, state);
- newState.nav = nextStateNav;
- return newState;
+ const nextStateNav = AppNavigator.router.getStateForAction(action, state.nav);
+ newState = Object.assign({}, state);
+ if (nextStateNav) {
+ newState.nav = nextStateNav;
+ }
+
+ if (action.noteId) {
+ newState.selectedNoteId = action.noteId;
+ }
+
+ break;
case 'VIEW_NOTE':
- // TODO
- return state;
+ newState = Object.assign({}, state);
+
+ break;
}
- return state;
+ return newState;
}
let store = createStore(reducer);
-class NotesScreen extends React.Component {
+class NotesScreenComponent extends React.Component {
static navigationOptions = {
title: 'Notes',
};
@@ -66,26 +76,40 @@ class NotesScreen extends React.Component {
}
}
-class NoteScreen extends React.Component {
+const NotesScreen = connect(
+ (state) => {
+ return {};
+ },
+ (dispatch) => {
+ return {};
+ }
+)(NotesScreenComponent)
+
+class NoteScreenComponent extends React.Component {
static navigationOptions = {
title: 'Note',
};
render() {
- const { navigate } = this.props.navigation;
+ let note = this.props.note;
+ //
return (
-
-
);
}
}
+const NoteScreen = connect(
+ (state) => {
+ let selectedNote = state.selectedNoteId ? Note.noteById(state.notes, state.selectedNoteId) : null;
+ return { note: selectedNote };
+ },
+ (dispatch) => {
+ return {};
+ }
+)(NoteScreenComponent)
+
const AppNavigator = StackNavigator({
Notes: {screen: NotesScreen},
Note: {screen: NoteScreen},