Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add highlighting for selected note

ammarahm-edb58cc664306c
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index 70116177b..2a4696e17 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -29,6 +29,9 @@ export default class NoteItem extends React.Component {
}
shouldComponentUpdate(nextProps, nextState) {
+ if (nextProps.currentEditingNote === this.props.item.dateCreated) {
+ return true;
+ }
if (nextProps.item.locked !== this.cipher.value) {
return true;
} else {
@@ -59,6 +62,7 @@ export default class NoteItem extends React.Component {
isTrash,
pinned,
index,
+ currentEditingNote,
} = this.props;
console.log('rendering', index);
return (
@@ -70,10 +74,13 @@ export default class NoteItem extends React.Component {
alignItems: 'center',
flexDirection: 'row',
maxWidth: '100%',
- paddingRight: 6,
+ paddingRight: 12,
alignSelf: 'center',
borderBottomWidth: 1,
- borderBottomColor: colors.nav,
+ borderBottomColor:
+ currentEditingNote === item.dateCreated
+ ? colors.accent
+ : colors.nav,
},
customStyle ? customStyle : {},
]}>
@@ -127,7 +134,10 @@ export default class NoteItem extends React.Component {
<Text
numberOfLines={1}
style={{
- color: colors.pri,
+ color:
+ currentEditingNote === item.dateCreated
+ ? colors.accent
+ : colors.pri,
fontSize: SIZE.md,
fontFamily: WEIGHT.bold,
maxWidth: '95%',
diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.js
index c23c95f6b..82a921b82 100644
--- a/apps/mobile/src/components/NotesList/index.js
+++ b/apps/mobile/src/components/NotesList/index.js
@@ -18,7 +18,7 @@ export const NotesList = ({
searchResults,
}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode} = state;
+ const {colors, selectionMode, currentEditingNote} = state;
const notes = [...state.notes];
const _renderItem = ({item, index}) => (
@@ -29,6 +29,9 @@ export const NotesList = ({
width: selectionMode ? '90%' : '100%',
marginHorizontal: 0,
}}
+ currentEditingNote={
+ currentEditingNote === item.dateCreated ? currentEditingNote : null
+ }
onLongPress={() => {
dispatch({type: ACTIONS.SELECTION_MODE, enabled: !selectionMode});
dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
diff --git a/apps/mobile/src/provider/index.js b/apps/mobile/src/provider/index.js
index b74e8cc0c..2d44369fd 100644
--- a/apps/mobile/src/provider/index.js
+++ b/apps/mobile/src/provider/index.js
@@ -35,6 +35,7 @@ const defaultState = {
},
preventDefaultMargins: false,
isLoginNavigator: false,
+ currenEditingNote: null,
};
export const ACTIONS = {
@@ -50,6 +51,7 @@ export const ACTIONS = {
MODAL_NAVIGATOR: 'modalNavigator',
CLEAR_SELECTION: 'clearSelection',
LOGIN_NAVIGATOR: 'loginNavigator',
+ CURRENT_EDITING_NOTE: 'currentEditingNote',
};
const reducer = (state, action) => {
@@ -137,6 +139,12 @@ const reducer = (state, action) => {
isLoginNavigator: action.enabled,
};
}
+ case ACTIONS.CURRENT_EDITING_NOTE: {
+ return {
+ ...state,
+ currentEditingNote: action.dateCreated,
+ };
+ }
default:
throw new Error('unknown action type');
}
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 4e343477b..fcd06a9cc 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -62,6 +62,10 @@ const Editor = ({navigation, noMenu}) => {
clearEditor();
} else {
note = item;
+ dispatch({
+ type: ACTIONS.CURRENT_EDITING_NOTE,
+ dateCreated: item.dateCreated,
+ });
updateEditor();
}
});
@@ -71,6 +75,10 @@ const Editor = ({navigation, noMenu}) => {
clearEditor();
} else {
note = item;
+ dispatch({
+ type: ACTIONS.CURRENT_EDITING_NOTE,
+ dateCreated: item.dateCreated,
+ });
updateEditor();
}
}
@@ -148,8 +156,10 @@ const Editor = ({navigation, noMenu}) => {
},
dateCreated: timestamp,
});
+
if (timestamp !== dateCreated) {
timestamp = dateCreated;
+ dispatch({type: ACTIONS.CURRENT_EDITING_NOTE, dateCreated: timestamp});
}
if (content.text.length < 200 || saveCounter < 2) {
@@ -419,8 +429,8 @@ const Editor = ({navigation, noMenu}) => {
Platform.OS === 'ios'
? sourceUri
: {
- uri: 'http://192.168.10.7:8080/texteditor.html',
- baseUrl: 'http://192.168.10.7:8080/',
+ uri: 'file:///android_asset/texteditor.html',
+ baseUrl: 'file:///android_asset/',
}
}
style={{