Skip to content

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

fix: adding notebooks.

ammarahm-edcabaf134b314
diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js
index dd4a1af97..b2d4b7a6e 100644
--- a/apps/mobile/src/components/AddNotebookDialog/index.js
+++ b/apps/mobile/src/components/AddNotebookDialog/index.js
@@ -9,7 +9,6 @@ import {
} from 'react-native';
import {SIZE, ph, pv, opacity, WEIGHT} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
-
import {getElevation, ToastEvent} from '../../utils/utils';
import {FlatList, TextInput} from 'react-native-gesture-handler';
import {db, DDS} from '../../../App';
@@ -28,9 +27,14 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
let currentSelectedInput = null;
let timestamp = null;
let description = 'my first notebook';
- const onSubmit = (text, index, willFocus = true) => {
+ let backPressCount = 0;
+
+ const onSubmit = (text, index, willFocus = false) => {
+ console.log('here');
let prevTopics = topics;
prevTopics[index] = text;
+ prevIndex = index;
+ prevItem = text;
if (
prevTopics.length === index + 1 &&
@@ -41,24 +45,22 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
}
let nextTopics = [...prevTopics];
-
setTopics(nextTopics);
-
currentSelectedInput = null;
-
- //if (!willFocus) return;
if (!refs[index + 1]) {
setTimeout(() => {
if (!refs[index + 1]) return;
-
refs[index + 1].focus();
- }, 400);
+ }, 300);
} else {
setTimeout(() => {
refs[index + 1].focus();
- }, 400);
+ }, 300);
}
};
+
+ const onBlur = (text, index) => {};
+
const onFocus = index => {
currentSelectedInput = index;
@@ -73,7 +75,6 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
prevItem = null;
let nextTopics = [...prevTopics];
-
setTopics(nextTopics);
}
};
@@ -86,12 +87,9 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
let prevTopics = topics;
if (prevTopics.length === 1) return;
-
refs = [];
prevTopics.splice(index, 1);
-
let nextTopics = [...prevTopics];
-
setTopics(nextTopics);
};
@@ -116,6 +114,24 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
close(true);
};
+ onKeyPress = (event, index, text) => {
+ if (event.nativeEvent.key === 'Backspace') {
+ if (backPressCount === 0 && (!text || text.length == 0)) {
+ backPressCount = 1;
+
+ return;
+ }
+
+ if (backPressCount === 1 && (!text || text.length == 0)) {
+ backPressCount = 0;
+ if (!refs[index] == 0) {
+ refs[index - 1].focus();
+ }
+ onDelete(index);
+ }
+ }
+ };
+
return (
<Modal
visible={visible}
@@ -123,6 +139,7 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
animated
animationType="fade"
onShow={() => {
+ refs = [];
if (toEdit !== null) {
let topicsList = [];
toEdit.topics.forEach(item => {
@@ -154,7 +171,6 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
...getElevation(5),
width: DDS.isTab ? '50%' : '80%',
maxHeight: 350,
-
borderRadius: 5,
backgroundColor: colors.bg,
paddingHorizontal: ph,
@@ -228,6 +244,8 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
onChange={onChange}
onFocus={onFocus}
onDelete={onDelete}
+ onKeyPress={onKeyPress}
+ onBlur={onBlur}
/>
)}
/>
@@ -269,12 +287,10 @@ export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
activeOpacity={opacity}
onPress={() => {
setTopics(['']);
-
refs = [];
prevIndex = null;
prevItem = null;
currentSelectedInput = null;
-
close();
}}
style={{
@@ -311,6 +327,8 @@ const TopicItem = ({
onChange,
colors,
toEdit,
+ onKeyPress,
+ onBlur,
}) => {
const [focus, setFocus] = useState(true);
const topicRef = ref => (refs[index] = ref);
@@ -332,19 +350,24 @@ const TopicItem = ({
<TextInput
ref={topicRef}
onFocus={() => {
+ text = item;
+
onFocus(index);
setFocus(true);
}}
onBlur={() => {
- onSubmit(text, index, false);
+ onBlur(text, index);
setFocus(false);
}}
onChangeText={value => {
onChange(value, index);
text = value;
}}
- onSubmit={() => onSubmit(text, index, true)}
+ onSubmitEditing={() => {
+ onSubmit(text, index, true);
+ }}
blurOnSubmit
+ onKeyPress={event => onKeyPress(event, index, text)}
style={{
padding: pv - 5,
paddingHorizontal: 0,
diff --git a/apps/mobile/src/components/EditorMenu/index.js b/apps/mobile/src/components/EditorMenu/index.js
index 72fc207fa..88f356da5 100644
--- a/apps/mobile/src/components/EditorMenu/index.js
+++ b/apps/mobile/src/components/EditorMenu/index.js
@@ -26,7 +26,7 @@ import {useAppContext} from '../../provider/useAppContext';
import {VaultDialog} from '../VaultDialog';
let tagsInputRef;
-
+let tagsList;
export const EditorMenu = ({
close = () => {},
hide,
@@ -375,6 +375,7 @@ export const EditorMenu = ({
</TouchableOpacity>
<ScrollView
+ ref={ref => (tagsList = ref)}
contentContainerStyle={{
flexDirection: 'row',
flexWrap: 'wrap',
@@ -490,7 +491,6 @@ export const EditorMenu = ({
let props = {...noteProps};
props.locked = locked;
updateProps(props);
-
setVaultDialog(false);
setUnlock(false);
}}
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index b72ee664d..2daab5c4d 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -1,5 +1,11 @@
import React, {useState} from 'react';
-import {View, Text, TouchableOpacity, Dimensions} from 'react-native';
+import {
+ View,
+ Text,
+ TouchableOpacity,
+ Dimensions,
+ ScrollView,
+} from 'react-native';
import {COLOR_SCHEME, SIZE, br, ph, pv, WEIGHT} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
import {
@@ -164,18 +170,17 @@ const NoteItem = props => {
width: '100%',
}}>
<Text
- numberOfLines={props.numColumns === 2 ? 3 : null}
style={{
fontSize: SIZE.xs + 1,
- lineHeight: SIZE.sm + 2,
color: colors.pri,
fontFamily: WEIGHT.regular,
width: '100%',
maxWidth: '100%',
paddingRight: ph,
- height: props.numColumns === 2 ? SIZE.sm * 3.5 : null,
}}>
- {item.headline}
+ {item.headline[item.headline.length - 1] === '\n'
+ ? item.headline.slice(0, item.headline.length - 1)
+ : item.headline}
</Text>
<View
@@ -183,12 +188,33 @@ const NoteItem = props => {
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
+ width: '100%',
+ marginTop: 10,
}}>
{!props.isTrash ? (
<>
+ <View
+ style={{
+ marginRight: 10,
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ {['red', 'green'].map(item => (
+ <View
+ style={{
+ width: SIZE.xs,
+ height: SIZE.xs,
+ borderRadius: 100,
+ backgroundColor: item,
+ marginRight: -5.5,
+ }}></View>
+ ))}
+ </View>
+
{item.locked ? (
<Icon
- style={{width: 30}}
+ style={{marginLeft: 10}}
name="lock"
size={SIZE.xs}
color={colors.icon}
@@ -197,7 +223,7 @@ const NoteItem = props => {
{item.favorite ? (
<Icon
- style={{width: 30}}
+ style={{marginLeft: 10}}
name="star"
size={SIZE.xs}
color={colors.icon}
@@ -209,6 +235,7 @@ const NoteItem = props => {
fontSize: SIZE.xs - 1,
textAlignVertical: 'center',
fontFamily: WEIGHT.regular,
+ marginLeft: 10,
}}>
{timeSince(item.dateCreated)}
</Text>