Skip to content

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

add delete functionality.

ammarahm-ed10b2486ff212
diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js
index 811bccb84..b4f4d977c 100644
--- a/apps/mobile/src/components/AddNotebookDialog/index.js
+++ b/apps/mobile/src/components/AddNotebookDialog/index.js
@@ -167,6 +167,7 @@ export const AddNotebookDialog = ({visible, close}) => {
borderRadius: 5,
fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
+ color: colors.pri,
marginTop: 20,
marginBottom: 10,
}}
@@ -181,8 +182,9 @@ export const AddNotebookDialog = ({visible, close}) => {
style={{
fontSize: SIZE.sm,
fontFamily: WEIGHT.semibold,
+ color: colors.pri,
}}>
- Topics
+ Topics:
</Text>
<FlatList
@@ -325,6 +327,7 @@ const TopicItem = ({
paddingHorizontal: 0,
fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
+ color: colors.pri,
width: '90%',
maxWidth: '90%',
}}
diff --git a/apps/mobile/src/components/AddTopicDialog/index.js b/apps/mobile/src/components/AddTopicDialog/index.js
new file mode 100644
index 000000000..3c18dd50c
--- /dev/null
+++ b/apps/mobile/src/components/AddTopicDialog/index.js
@@ -0,0 +1,171 @@
+import React, {useEffect, useState, createRef} from 'react';
+import {
+ ScrollView,
+ View,
+ Text,
+ TouchableOpacity,
+ Dimensions,
+ Image,
+ SafeAreaView,
+ Platform,
+ Modal,
+} from 'react-native';
+import NavigationService from '../../services/NavigationService';
+import {
+ COLOR_SCHEME,
+ SIZE,
+ br,
+ ph,
+ pv,
+ opacity,
+ FONT,
+ WEIGHT,
+} from '../../common/common';
+import Icon from 'react-native-vector-icons/Feather';
+
+import {getElevation, h, w, timeSince, ToastEvent} from '../../utils/utils';
+import {FlatList, TextInput} from 'react-native-gesture-handler';
+import {useForceUpdate} from '../../views/ListsEditor';
+import {storage} from '../../../App';
+
+export const AddTopicDialog = ({
+ visible,
+ close = () => {},
+ notebookID,
+ toEdit = null,
+}) => {
+ const [colors, setColors] = useState(COLOR_SCHEME);
+ const [topics, setTopics] = useState(['']);
+ const forceUpdate = useForceUpdate();
+ const setTitleRef = createRef();
+ let description = 'my first notebook';
+ let title = null;
+ const addNewTopic = async () => {
+ if (!title)
+ return ToastEvent.show('Title is required', 'error', 3000, () => {}, '');
+ console.log(notebookID, title);
+ storage.addTopicToNotebook(notebookID, title);
+ ToastEvent.show('New topic added', 'success', 3000, () => {}, '');
+ close(true);
+ };
+
+ return (
+ <Modal
+ visible={visible}
+ transparent={true}
+ onRequestClose={() => (refs = [])}>
+ <View
+ style={{
+ width: '100%',
+ height: '100%',
+ backgroundColor: 'rgba(255,255,255,0.3)',
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ <View
+ style={{
+ width: '80%',
+ maxHeight: 350,
+ elevation: 5,
+ borderRadius: 5,
+ backgroundColor: colors.bg,
+ paddingHorizontal: ph,
+ paddingVertical: pv,
+ }}>
+ <View
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ <Icon name="book-open" color={colors.accent} size={SIZE.lg} />
+ <Text
+ style={{
+ color: colors.accent,
+ fontFamily: WEIGHT.semibold,
+ marginLeft: 10,
+ fontSize: SIZE.lg,
+ marginTop: -5,
+ }}>
+ {toEdit ? 'Edit Topic' : 'Add New Topic'}
+ </Text>
+ </View>
+
+ <TextInput
+ style={{
+ padding: pv,
+ borderWidth: 1.5,
+ borderColor: colors.nav,
+ paddingHorizontal: ph,
+ borderRadius: 5,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ marginTop: 20,
+ }}
+ defaultValue={toEdit ? toEdit.title : null}
+ onChangeText={value => {
+ title = value;
+ }}
+ placeholder="Enter title of topic"
+ placeholderTextColor={colors.icon}
+ />
+
+ <View
+ style={{
+ justifyContent: 'space-around',
+ alignItems: 'center',
+ flexDirection: 'row',
+ marginTop: 20,
+ }}>
+ <TouchableOpacity
+ activeOpacity={opacity}
+ onPress={async () => await addNewTopic()}
+ style={{
+ paddingVertical: pv,
+ paddingHorizontal: ph,
+ borderRadius: 5,
+ width: '45%',
+ justifyContent: 'center',
+ alignItems: 'center',
+ borderColor: colors.accent,
+ backgroundColor: colors.accent,
+ borderWidth: 1,
+ }}>
+ <Text
+ style={{
+ fontFamily: WEIGHT.medium,
+ color: 'white',
+ fontSize: SIZE.sm,
+ }}>
+ Add
+ </Text>
+ </TouchableOpacity>
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ onPress={() => close()}
+ style={{
+ paddingVertical: pv,
+ paddingHorizontal: ph,
+ borderRadius: 5,
+ width: '45%',
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: colors.nav,
+ }}>
+ <Text
+ style={{
+ fontFamily: WEIGHT.medium,
+ color: colors.icon,
+ fontSize: SIZE.sm,
+ }}>
+ Cancel
+ </Text>
+ </TouchableOpacity>
+ </View>
+ </View>
+ </View>
+ </Modal>
+ );
+};
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 386df7a8b..cc5fc8f75 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -1,16 +1,7 @@
import React, {useEffect, useState, createRef} from 'react';
-import {
- ScrollView,
- View,
- Text,
- TouchableOpacity,
- Dimensions,
- Image,
- SafeAreaView,
- Platform,
- Modal,
-} from 'react-native';
+import {View, Text, TouchableOpacity, Modal} from 'react-native';
import NavigationService from '../../services/NavigationService';
+
import {
COLOR_SCHEME,
SIZE,
@@ -22,9 +13,6 @@ import {
WEIGHT,
} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
-import {getElevation, h, w, timeSince} from '../../utils/utils';
-import {FlatList, TextInput} from 'react-native-gesture-handler';
-import {useForceUpdate} from '../../views/ListsEditor';
export const Dialog = ({
title,
@@ -37,12 +25,13 @@ export const Dialog = ({
positivePress = () => {},
}) => {
const [colors, setColors] = useState(COLOR_SCHEME);
- const forceUpdate = useForceUpdate();
return (
<Modal
visible={visible}
transparent={true}
+ animated
+ animationType="fade"
onRequestClose={() => (refs = [])}>
<View
style={{
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index b0a2b12a2..845deba1f 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -28,6 +28,8 @@ import NavigationService from '../../services/NavigationService';
import Menu, {MenuItem, MenuDivider} from 'react-native-material-menu';
import {Dialog} from '../Dialog';
import {VaultDialog} from '../VaultDialog';
+import {storage} from '../../../App';
+
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -36,7 +38,37 @@ const NoteItem = props => {
const [visible, setVisible] = useState(false);
const [vaultDialog, setVaultDialog] = useState(false);
const item = props.item;
+
+ let show = null;
+
let setMenuRef = {};
+
+ const onMenuHide = () => {
+ if (show) {
+ if (show === 'delete') {
+ setVisible(true);
+ show = null;
+ } else if (show == 'vault') {
+ setVaultDialog(true);
+ show = null;
+ }
+ }
+ };
+
+ const hideMenu = () => {
+ setMenuRef[props.index].hide();
+ };
+
+ const showMenu = () => {
+ setMenuRef[props.index].show();
+ };
+
+ const deleteItem = async () => {
+ await storage.deleteNotes([item]);
+ ToastEvent.show('Note moved to trash', 'success', 3000);
+ setVisible(false);
+ props.refresh();
+ };
return (
<View
style={{
@@ -59,6 +91,7 @@ const NoteItem = props => {
icon="trash"
paragraph="Do you want to delete this note?"
positiveText="Delete"
+ positivePress={deleteItem}
close={() => {
setVisible(false);
}}
@@ -153,6 +186,7 @@ const NoteItem = props => {
borderRadius: 5,
backgroundColor: colors.nav,
}}
+ onHidden={onMenuHide}
ref={ref => (setMenuRef[props.index] = ref)}
button={
<TouchableOpacity
@@ -162,7 +196,7 @@ const NoteItem = props => {
minHeight: 70,
alignItems: 'center',
}}
- onPress={() => setMenuRef[props.index].show()}>
+ onPress={showMenu}>
<Icon name="more-vertical" size={SIZE.lg} color={colors.icon} />
</TouchableOpacity>
}>
@@ -178,7 +212,7 @@ const NoteItem = props => {
</MenuItem>
<MenuItem
onPress={() => {
- setMenuRef[props.index].hide();
+ hideMenu();
ToastEvent.show(
'Note added to favorites.',
'success',
@@ -209,7 +243,7 @@ const NoteItem = props => {
<MenuItem
onPress={() => {
- setMenuRef[props.index].hide();
+ hideMenu();
NavigationService.navigate('Folders', {
note: item,
title: 'Choose Notebook',
@@ -228,8 +262,8 @@ const NoteItem = props => {
</MenuItem>
<MenuItem
onPress={() => {
- setMenuRef[props.index].hide();
- setVaultDialog(true);
+ show = 'vault';
+ hideMenu(true);
}}
textStyle={{
color: colors.pri,
@@ -242,8 +276,8 @@ const NoteItem = props => {
<MenuItem
onPress={() => {
- setVisible(true);
- setMenuRef[props.index].hide();
+ show = 'delete';
+ hideMenu();
}}
textStyle={{
color: colors.pri,
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 61c85eb17..2f9ae4db8 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -13,27 +13,72 @@ import {
WEIGHT,
} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
-import {w} from '../../utils/utils';
+import {w, ToastEvent} from '../../utils/utils';
+import {storage} from '../../../App';
+import {Dialog} from '../Dialog';
+import {AddTopicDialog} from '../AddTopicDialog';
export const NotebookItem = ({
item,
index,
- colors,
- hideMore,
+ hideMore = false,
topic,
isTopic = false,
+ isMove = false,
+ noteToMove = null,
+ notebookID,
+ refresh = () => {},
}) => {
+ const [colors, setColors] = useState(COLOR_SCHEME);
+ const [isVisible, setVisible] = useState(false);
+ const [addTopic, setAddTopic] = useState(false);
let setMenuRef = {};
- return (
- <TouchableOpacity
- activeOpacity={opacity}
- onPress={() => {
- NavigationService.navigate('Notebook', {
+ let show = null;
+
+ const deleteItem = async () => {
+ if (isTopic) {
+ await storage.deleteTopicFromNotebook(notebookID, item.title);
+ ToastEvent.show('Topic moved to trash', 'success', 3000);
+ } else {
+ await storage.deleteNotebooks([item]);
+ ToastEvent.show('Notebook moved to trash', 'success', 3000);
+ }
+ refresh();
+ setVisible(false);
+ };
+
+ const navigate = () => {
+ isTopic
+ ? NavigationService.navigate('Notes', item)
+ : NavigationService.navigate('Notebook', {
notebook: item,
+ note: noteToMove,
title: hideMore ? 'Choose topic' : item.title,
- isMove: hideMore ? true : false,
+ isMove: isMove ? true : false,
hideMore: hideMore ? true : false,
});
- }}
+ };
+
+ const onMenuHide = () => {
+ if (show) {
+ if (show === 'delete') {
+ setVisible(true);
+ show = null;
+ } else if (show === 'topic') {
+ setAddTopic(true);
+ show = null;
+ }
+ }
+ };
+
+ const hideMenu = () => {
+ setMenuRef[index].hide();
+ };
+
+ const showMenu = () => {
+ setMenuRef[index].show();
+ };
+ return (
+ <View
style={{
paddingHorizontal: ph,
marginHorizontal: '5%',
@@ -41,13 +86,30 @@ export const NotebookItem = ({
borderBottomColor: colors.nav,
paddingVertical: pv,
}}>
+ <Dialog
+ visible={isVisible}
+ title={`Delete ${isTopic ? 'topic' : 'notebook'}`}
+ icon="trash"
+ paragraph={`Do you want to delete this ${
+ isTopic ? 'topic' : 'notebook'
+ }?`}
+ positiveText="Delete"
+ positivePress={deleteItem}
+ close={() => setVisible(false)}
+ />
+ <AddTopicDialog
+ visible={addTopic}
+ toEdit={item}
+ close={() => setAddTopic(false)}
+ />
+
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
}}>
- <View>
+ <TouchableOpacity onPress={navigate}>
<Text
style={{
fontFamily: WEIGHT.bold,
@@ -76,23 +138,21 @@ export const NotebookItem = ({
alignItems: 'center',
marginTop: 5,
}}>
- {Object.keys(item.topics)
- .slice(0, 3)
- .map(topic => (
- <Text
- style={{
- borderRadius: 5,
- backgroundColor: colors.accent,
- color: 'white',
- marginRight: 5,
- fontFamily: WEIGHT.regular,
- fontSize: SIZE.xxs,
- paddingHorizontal: ph / 2,
- paddingVertical: pv / 4,
- }}>
- {topic}
- </Text>
- ))}
+ {item.topics.slice(0, 4).map(topic => (
+ <Text
+ style={{
+ borderRadius: 5,
+ backgroundColor: colors.accent,
+ color: 'white',
+ marginRight: 5,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.xxs,
+ paddingHorizontal: ph / 2,
+ paddingVertical: pv / 4,
+ }}>
+ {topic.title}
+ </Text>
+ ))}
</View>
)}
@@ -128,14 +188,15 @@ export const NotebookItem = ({
</Text>
</View>
)}
- </View>
+ </TouchableOpacity>
{hideMore ? null : (
<Menu
style={{
borderRadius: 5,
- backgroundColor: colors.bg,
+ backgroundColor: colors.nav,
}}
+ onHidden={onMenuHide}
ref={ref => (setMenuRef[index] = ref)}
button={
<TouchableOpacity
@@ -145,10 +206,25 @@ export const NotebookItem = ({
minHeight: 70,
alignItems: 'center',
}}
- onPress={() => setMenuRef[index].show()}>
+ onPress={showMenu}>
<Icon name="more-vertical" size={SIZE.lg} color={colors.icon} />
</TouchableOpacity>
}>
+ <MenuItem
+ onPress={() => {
+ show = 'topic';
+ hideMenu();
+ }}
+ textStyle={{
+ color: colors.pri,
+
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="edit-2" size={SIZE.sm} color={colors.icon} />
+ {' '}Edit
+ </MenuItem>
+
<MenuItem
textStyle={{
color: colors.pri,
@@ -161,7 +237,7 @@ export const NotebookItem = ({
</MenuItem>
<MenuItem
onPress={() => {
- setMenuRef[props.index].hide();
+ hideMenu();
ToastEvent.show(
'Note added to favorites.',
'success',
@@ -179,10 +255,11 @@ export const NotebookItem = ({
<Icon name="star" size={SIZE.sm} color={colors.icon} />
{' '}Favorite
</MenuItem>
+
<MenuItem
onPress={() => {
- setVisible(true);
- setMenuRef[index].hide();
+ show = 'delete';
+ hideMenu();
}}
textStyle={{
color: colors.pri,
@@ -200,7 +277,13 @@ export const NotebookItem = ({
<TouchableOpacity
activeOpacity={opacity}
onPress={() => {
+ storage.addNoteToTopic(
+ notebookID,
+ item.title,
+ noteToMove.dateCreated,
+ );
NavigationService.navigate('Home');
+ ToastEvent.show(`Note moved to ${item.title}`, 'success', 3000);
}}
style={{
borderWidth: 1,
@@ -225,6 +308,6 @@ export const NotebookItem = ({
</TouchableOpacity>
) : null}
</View>
- </TouchableOpacity>
+ </View>
);
};
diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.js
index 51e4a0315..94151d6eb 100644
--- a/apps/mobile/src/components/NotesList/index.js
+++ b/apps/mobile/src/components/NotesList/index.js
@@ -27,13 +27,19 @@ import NoteItem from '../NoteItem';
import NavigationService from '../../services/NavigationService';
import {storage} from '../../../App';
-export const NotesList = ({keyword, searchResults, margin, onScroll}) => {
+export const NotesList = ({
+ keyword = null,
+ notes,
+ margin,
+ onScroll,
+ isSearch = false,
+}) => {
const [colors, setColors] = useState(COLOR_SCHEME);
return (
<>
<FlatList
- data={searchResults}
+ data={notes}
ListFooterComponent={
<View
style={{
@@ -57,25 +63,46 @@ export const NotesList = ({keyword, searchResults, margin, onScroll}) => {
}}
ListHeaderComponent={
<>
- <Text
- style={{
- fontSize: SIZE.lg,
- marginTop: margin,
- fontFamily: WEIGHT.medium,
- color: colors.pri,
- paddingHorizontal: Platform.isPad ? '2.5%' : '5%',
- maxWidth: '100%',
- }}>
- Search Results for{' '}
+ {isSearch ? (
<Text
style={{
- color: colors.accent,
+ fontSize: SIZE.lg,
+ marginTop: margin,
+ fontFamily: WEIGHT.medium,
+ color: colors.pri,
+ paddingHorizontal: Platform.isPad ? '2.5%' : '5%',
+ maxWidth: '100%',
}}>
- {keyword}{' '}
+ Search Results for{' '}
+ <Text
+ style={{
+ color: colors.accent,
+ }}>
+ {keyword}{' '}
+ </Text>
</Text>
- </Text>
+ ) : (
+ <View style={{marginTop: margin}} />
+ )}
</>
}
+ ListFooterComponent={
+ <View
+ style={{
+ height: 150,
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}>
+ <Text
+ style={{
+ color: colors.navbg,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ }}>
+ - End -
+ </Text>
+ </View>
+ }
renderItem={({item, index}) => <NoteItem item={item} index={index} />}
/>
</>
diff --git a/apps/mobile/src/components/Recents/index.js b/apps/mobile/src/components/Recents/index.js
index 912d4f81d..c9f4cdf80 100644
--- a/apps/mobile/src/components/Recents/index.js
+++ b/apps/mobile/src/components/Recents/index.js
@@ -1,3 +1,5 @@
+// Component to be removed soon.
+
import React, {useState, useEffect} from 'react';
import {
View,
@@ -91,7 +93,9 @@ export const RecentList = ({update, onScroll, margin}) => {
</View>
}
keyExtractor={(item, index) => item.dateCreated.toString()}
- renderItem={({item, index}) => <NoteItem item={item} index={index} />}
+ renderItem={({item, index}) => (
+ <NoteItem refresh={fetchNotes} item={item} index={index} />
+ )}
/>
</>
);
diff --git a/apps/mobile/src/components/header/index.js b/apps/mobile/src/components/header/index.js
index 34dc52b8c..8c14ea41f 100644
--- a/apps/mobile/src/components/header/index.js
+++ b/apps/mobile/src/components/header/index.js
@@ -20,10 +20,10 @@ export const Header = ({
sendHeight(e.nativeEvent.layout.height);
}
}}
- transition={['height', 'marginBottom']}
+ transition={['minHeight', 'marginBottom']}
duration={250}
style={{
- height: hide ? 50 : 50,
+ minHeight: hide ? 50 : 50,
flexDirection: 'row',
zIndex: 10,
justifyContent: 'space-between',
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 98cfd84ae..e84753ff9 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -31,6 +31,8 @@ import {SideMenuEvent} from '../../utils/utils';
import {Dialog} from '../../components/Dialog';
import {TouchableOpacity} from 'react-native-gesture-handler';
import * as Animatable from 'react-native-animatable';
+import Menu, {MenuItem, MenuDivider} from 'react-native-material-menu';
+
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -53,7 +55,7 @@ const Editor = ({navigation}) => {
let updateInterval = null;
let keyboardDidShowListener = null;
let keyboardDidHideListener = null;
-
+ let setMenuRef;
// REFS
let EditorWebView = createRef();
@@ -152,23 +154,129 @@ const Editor = ({navigation}) => {
onSubmitEditing={async () => await saveNote()}
/>
- <AnimatedTouchableOpacity
- transition={['width', 'height']}
- duration={250}
+ <Menu
style={{
- width: resize ? 35 : 40,
- height: resize ? 35 : 40,
- }}>
- <Icon
- style={{
- paddingRight: 10,
- marginTop: 5,
+ borderRadius: 5,
+ backgroundColor: colors.nav,
+ }}
+ ref={ref => (setMenuRef = ref)}
+ button={
+ <AnimatedTouchableOpacity
+ transition={['width', 'height']}
+ duration={250}
+ onPress={() => setMenuRef.show()}
+ style={{
+ width: resize ? 35 : 40,
+ height: resize ? 35 : 40,
+ }}>
+ <Icon
+ style={{
+ paddingRight: 10,
+ marginTop: 5,
+ }}
+ name="more-vertical"
+ color={colors.icon}
+ size={resize ? SIZE.xl : SIZE.xxl}
+ />
+ </AnimatedTouchableOpacity>
+ }>
+ <MenuItem
+ textStyle={{
+ color: colors.pri,
+
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="star" size={SIZE.sm} color={colors.icon} />
+ {' '}Pin
+ </MenuItem>
+ <MenuItem
+ onPress={() => {
+ setMenuRef.hide();
+ ToastEvent.show(
+ 'Note added to favorites.',
+ 'success',
+ 3000,
+ () => {},
+ 'Ok',
+ );
}}
- name="more-vertical"
- color={colors.icon}
- size={resize ? SIZE.xl : SIZE.xxl}
- />
- </AnimatedTouchableOpacity>
+ textStyle={{
+ color: colors.pri,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="star" size={SIZE.sm} color={colors.icon} />
+ {' '}Favorite
+ </MenuItem>
+ <MenuItem
+ textStyle={{
+ color: colors.pri,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="tag" size={SIZE.sm} color={colors.icon} />
+ {' '}Add Tags
+ </MenuItem>
+
+ <MenuItem
+ textStyle={{
+ color: colors.pri,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="share" size={SIZE.sm} color={colors.icon} />
+ {' '}Share
+ </MenuItem>
+
+ <MenuItem
+ onPress={() => {
+ setMenuRef.hide();
+ NavigationService.navigate('Folders', {
+ note: item,
+ title: 'Choose Notebook',
+ isMove: true,
+ hideMore: true,
+ });
+ }}
+ textStyle={{
+ color: colors.pri,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="arrow-right" size={SIZE.sm} color={colors.icon} />
+ {' '}Move
+ </MenuItem>
+
+ <MenuItem
+ onPress={() => {
+ setMenuRef.hide();
+ setVaultDialog(true);
+ }}
+ textStyle={{
+ color: colors.pri,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="lock" size={SIZE.sm} color={colors.icon} />
+ {' '}Lock
+ </MenuItem>
+
+ <MenuItem
+ onPress={() => {
+ setVisible(true);
+ setMenuRef.hide();
+ }}
+ textStyle={{
+ color: colors.pri,
+
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="trash" size={SIZE.sm} color={colors.icon} />
+ {' '}Delete
+ </MenuItem>
+ </Menu>
</View>
<WebView
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index cbd389ae5..d082fc1a2 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -41,6 +41,7 @@ export const Folders = ({navigation}) => {
const [addNotebook, setAddNotebook] = useState(false);
const [notebooks, setNotebooks] = useState([]);
const [hideHeader, setHideHeader] = useState(false);
+ const [buttonHide, setButtonHide] = useState(false);
const [margin, setMargin] = useState(150);
const forceUpdate = useForceUpdate();
const params = navigation.state.params;
@@ -161,7 +162,10 @@ export const Folders = ({navigation}) => {
renderItem={({item, index}) => (
<NotebookItem
hideMore={params.hideMore}
+ isMove={params.isMove}
+ noteToMove={params.note}
item={item}
+ refresh={() => setNotebooks(storage.getNotebooks())}
index={index}
colors={colors}
/>
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 80f131271..055ef8347 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -36,7 +36,9 @@ import * as Animatable from 'react-native-animatable';
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView,
);
+
export const Home = ({navigation}) => {
+ // State
const [loading, setLoading] = useState(true);
const [colors, setColors] = useState(COLOR_SCHEME);
const [hidden, setHidden] = useState(false);
@@ -47,11 +49,15 @@ export const Home = ({navigation}) => {
const [margin, setMargin] = useState(150);
const [buttonHide, setButtonHide] = useState(false);
const forceUpdate = useForceUpdate();
+
+ // Variables
let offsetY = 0;
let countUp = 1;
let countDown = 0;
let headerHeight = 0;
let searchHeight = 0;
+ let marginSet = false;
+ // Effects
useEffect(() => {
setTimeout(() => {
@@ -70,6 +76,29 @@ export const Home = ({navigation}) => {
};
}, []);
+ useEffect(() => {
+ Keyboard.addListener('keyboardDidShow', () => {
+ setButtonHide(true);
+ });
+ Keyboard.addListener('keyboardDidHide', () => {
+ setTimeout(() => {
+ setButtonHide(false);
+ }, 100);
+ });
+ return () => {
+ Keyboard.removeListener('keyboardDidShow', () => {
+ setButtonHide(true);
+ });
+ Keyboard.removeListener('keyboardDidHide', () => {
+ setTimeout(() => {
+ setButtonHide(false);
+ }, 100);
+ });
+ };
+ }, []);
+
+ // Functions
+
const onChangeText = value => {
setText(value);
};
@@ -106,33 +135,16 @@ export const Home = ({navigation}) => {
let toAdd = h * 0.06;
setTimeout(() => {
- if (margin > headerHeight + searchHeight + toAdd) return;
+ if (marginSet) return;
setMargin(headerHeight + searchHeight + toAdd);
headerHeight = 0;
searchHeight = 0;
+ marginSet = true;
}, 10);
}
};
- useEffect(() => {
- Keyboard.addListener('keyboardDidShow', () => {
- setButtonHide(true);
- });
- Keyboard.addListener('keyboardDidHide', () => {
- setTimeout(() => {
- setButtonHide(false);
- }, 100);
- });
- return () => {
- Keyboard.removeListener('keyboardDidShow', () => {
- setButtonHide(true);
- });
- Keyboard.removeListener('keyboardDidHide', () => {
- setTimeout(() => {
- setButtonHide(false);
- }, 100);
- });
- };
- }, []);
+
+ // Render
return Platform.isPad ? (
<SafeAreaView style={[styles.container, {backgroundColor: colors.bg}]}>
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 686472e3d..bf6b7d72f 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -32,46 +32,57 @@ import NoteItem from '../../components/NoteItem';
import {NotebookItem} from '../../components/NotebookItem';
import {Search} from '../../components/SearchInput';
import {useForceUpdate} from '../ListsEditor';
+import {AddTopicDialog} from '../../components/AddTopicDialog';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
export const Notebook = ({navigation}) => {
+ // State
const [colors, setColors] = useState(COLOR_SCHEME);
const params = navigation.state.params;
const [hideHeader, setHideHeader] = useState(false);
const [margin, setMargin] = useState(150);
+ const [buttonHide, setButtonHide] = useState(false);
+ const [addTopic, setAddTopic] = useState(false);
const forceUpdate = useForceUpdate();
+ // Variables
let offsetY = 0;
let countUp = 0;
let countDown = 0;
let headerHeight = 0;
let searchHeight = 0;
+ let marginSet = false;
+ // Effects
+ useEffect(() => {
+ onThemeUpdate(() => {
+ forceUpdate();
+ });
+ return () => {
+ clearThemeUpdateListener(() => {
+ forceUpdate();
+ });
+ };
+ }, []);
+
+ // Functions
const setMarginTop = () => {
if (margin !== 150) return;
if (headerHeight == 0 || searchHeight == 0) {
let toAdd = h * 0.06;
setTimeout(() => {
- if (margin > headerHeight + searchHeight + toAdd) return;
+ if (marginSet) return;
setMargin(headerHeight + searchHeight + toAdd);
headerHeight = 0;
searchHeight = 0;
- }, 10);
+ marginSet = true;
+ }, 50);
}
};
- useEffect(() => {
- onThemeUpdate(() => {
- forceUpdate();
- });
- return () => {
- clearThemeUpdateListener(() => {
- forceUpdate();
- });
- };
- }, []);
+ // Render
return (
<SafeAreaView
style={{
@@ -82,6 +93,13 @@ export const Notebook = ({navigation}) => {
style={{
height: '100%',
}}>
+ <AddTopicDialog
+ visible={addTopic}
+ notebookID={params.notebook.dateCreated}
+ close={() => {
+ setAddTopic(false);
+ }}
+ />
<View
style={{
position: 'absolute',
@@ -107,7 +125,7 @@ export const Notebook = ({navigation}) => {
searchHeight = height;
setMarginTop();
}}
- placeholder="Search your notebook"
+ placeholder={`Search in ${params.title}`}
hide={hideHeader}
/>
</View>
@@ -136,7 +154,9 @@ export const Notebook = ({navigation}) => {
}}
ListHeaderComponent={
<>
- {params.hideMore ? null : (
+ {params.hideMore ? (
+ <View style={{marginTop: margin}} />
+ ) : (
<TouchableOpacity
activeOpacity={opacity}
onPress={() => {
@@ -172,6 +192,12 @@ export const Notebook = ({navigation}) => {
<NotebookItem
hideMore={params.hideMore}
isTopic={true}
+ noteToMove={params.note}
+ notebookID={params.notebook.dateCreated}
+ isMove={params.isMove}
+ refresh={() => {
+ forceUpdate();
+ }}
item={item}
index={index}
colors={colors}
@@ -181,7 +207,7 @@ export const Notebook = ({navigation}) => {
<TouchableOpacity
activeOpacity={opacity}
onPress={() => {
- setAddNotebook(true);
+ setAddTopic(true);
}}
style={{
borderRadius: 5,
@@ -202,7 +228,7 @@ export const Notebook = ({navigation}) => {
color: 'white',
}}>
<Icon name="plus" color="white" size={SIZE.lg} />
- Add a new topic
+ {' '}Add a new topic
</Text>
</TouchableOpacity>
</KeyboardAvoidingView>
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 4e7c154e2..517fcb0f6 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -8,6 +8,7 @@ import {
Image,
SafeAreaView,
Platform,
+ KeyboardAvoidingView,
} from 'react-native';
import NavigationService from '../../services/NavigationService';
import {
@@ -22,20 +23,32 @@ import {
onThemeUpdate,
clearThemeUpdateListener,
} from '../../common/common';
-import Icon from 'react-native-vector-icons/Ionicons';
+import Icon from 'react-native-vector-icons/Feather';
import {Reminder} from '../../components/Reminder';
import {ListItem} from '../../components/ListItem';
import {Header} from '../../components/header';
import {Search} from '../../components/SearchInput';
import {useForceUpdate} from '../ListsEditor';
+import {NotesList} from '../../components/NotesList';
+import {AnimatedSafeAreaView} from '../Home';
+import {storage} from '../../../App';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
export const Notes = ({navigation}) => {
const [colors, setColors] = useState(COLOR_SCHEME);
+ const [hideHeader, setHideHeader] = useState(false);
+ const [margin, setMargin] = useState(150);
+ const [buttonHide, setButtonHide] = useState(false);
+ const [notes, setNotes] = useState([]);
const forceUpdate = useForceUpdate();
let params = navigation.state ? navigation.state.params : null;
+ let offsetY = 0;
+ let countUp = 0;
+ let countDown = 0;
+ let headerHeight = 0;
+ let searchHeight = 0;
useEffect(() => {
onThemeUpdate(() => {
forceUpdate();
@@ -55,11 +68,123 @@ export const Notes = ({navigation}) => {
}
}, []);
+ useEffect(() => {
+ let notes = [];
+
+ params.notes.forEach(note => {
+ let noteToAdd = storage.getNote(note);
+ notes[notes.length] = noteToAdd;
+ });
+ setNotes(notes);
+ }, []);
+
+ const setMarginTop = () => {
+ if (margin !== 150) return;
+ if (headerHeight == 0 || searchHeight == 0) {
+ let toAdd = h * 0.06;
+
+ setTimeout(() => {
+ if (margin > headerHeight + searchHeight + toAdd) return;
+ setMargin(headerHeight + searchHeight + toAdd);
+ headerHeight = 0;
+ searchHeight = 0;
+ }, 10);
+ }
+ };
+
return (
- <SafeAreaView>
- <Header colors={colors} heading={params.heading} canGoBack={false} />
- <Search />
- </SafeAreaView>
+ <AnimatedSafeAreaView
+ transition="backgroundColor"
+ duration={250}
+ style={{
+ height: '100%',
+ backgroundColor: colors.night ? colors.bg : colors.bg,
+ }}>
+ <KeyboardAvoidingView
+ style={{
+ height: '100%',
+ }}>
+ <View
+ style={{
+ position: 'absolute',
+ backgroundColor: colors.night ? colors.bg : colors.bg,
+ zIndex: 10,
+ width: '100%',
+ }}>
+ <Header
+ sendHeight={height => (headerHeight = height)}
+ hide={hideHeader}
+ showSearch={() => {
+ setHideHeader(false);
+ countUp = 0;
+ countDown = 0;
+ }}
+ colors={colors}
+ canGoBack={false}
+ colors={colors}
+ heading={params.title}
+ canGoBack={true}
+ />
+ <Search
+ sendHeight={height => {
+ searchHeight = height;
+ setMarginTop();
+ }}
+ placeholder={`Search in ${params.title}`}
+ hide={hideHeader}
+ />
+ </View>
+
+ <NotesList
+ margin={margin}
+ onScroll={y => {
+ if (buttonHide) return;
+ if (y < 30) setHideHeader(false);
+ if (y > offsetY) {
+ if (y - offsetY < 150 || countDown > 0) return;
+ countDown = 1;
+ countUp = 0;
+ setHideHeader(true);
+ } else {
+ if (offsetY - y < 150 || countUp > 0) return;
+ countDown = 0;
+ countUp = 1;
+ setHideHeader(false);
+ }
+ offsetY = y;
+ }}
+ notes={notes}
+ />
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ onPress={() => {
+ setAddNotebook(true);
+ }}
+ style={{
+ borderRadius: 5,
+ width: '90%',
+ marginHorizontal: '5%',
+ paddingHorizontal: ph,
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: 15,
+ backgroundColor: colors.accent,
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.semibold,
+ color: 'white',
+ }}>
+ <Icon name="plus" color="white" size={SIZE.lg} />
+ {' '} Create a new note
+ </Text>
+ </TouchableOpacity>
+ </KeyboardAvoidingView>
+ </AnimatedSafeAreaView>
);
};