Skip to content

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

update screens

ammarahm-ed680db4999070
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index 88e77d58f..32a02f5b9 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -10,6 +10,7 @@ import SearchService from '../../services/SearchService';
import {eScrollEvent} from '../../utils/Events';
import Navigation from '../../services/Navigation';
import {DDS} from '../../services/DeviceDetection';
+import { InteractionManager } from '../../utils';
export const Folders = ({route, navigation}) => {
const [state, dispatch] = useTracked();
@@ -18,9 +19,6 @@ export const Folders = ({route, navigation}) => {
let pageIsLoaded = false;
let ranAfterInteractions = false;
- const InteractionManager = {
- runAfterInteractions:(func) => setTimeout(func,300)
- }
const onFocus = useCallback(() => {
if (!ranAfterInteractions) {
ranAfterInteractions = true;
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index eeefa50da..651005504 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -1,19 +1,16 @@
-import React, {useCallback, useEffect, useState} from 'react';
-import {AsyncStorage} from 'react-native';
-import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';
+import React, { useCallback, useEffect, useState } from 'react';
+import { ContainerBottomButton } from '../../components/Container/ContainerBottomButton';
import SimpleList from '../../components/SimpleList';
-import {useTracked} from '../../provider';
-import {Actions} from '../../provider/Actions';
-import {DDS} from '../../services/DeviceDetection';
-import {eSendEvent} from '../../services/EventManager';
+import { useTracked } from '../../provider';
+import { Actions } from '../../provider/Actions';
+import { DDS } from '../../services/DeviceDetection';
+import { eSendEvent } from '../../services/EventManager';
import Navigation from '../../services/Navigation';
import SearchService from '../../services/SearchService';
-import {InteractionManager, scrollRef} from '../../utils';
-import {db} from '../../utils/DB';
-import {eOnLoadNote, eScrollEvent} from '../../utils/Events';
-import {tabBarRef} from '../../utils/Refs';
-import Storage from '../../utils/storage';
-import Keychain from 'react-native-keychain';
+import { InteractionManager, scrollRef } from '../../utils';
+import { db } from '../../utils/DB';
+import { eOnLoadNote, eScrollEvent } from '../../utils/Events';
+import { tabBarRef } from '../../utils/Refs';
export const Home = ({route, navigation}) => {
const [state, dispatch] = useTracked();
const {loading} = state;
@@ -96,6 +93,8 @@ export const Home = ({route, navigation}) => {
}, [notes]);
const updateSearch = () => {
+
+
SearchService.update({
placeholder: 'Type a keyword to search in notes',
data: db?.notes?.all,
@@ -105,6 +104,7 @@ export const Home = ({route, navigation}) => {
};
const _onPressBottomButton = async () => {
+
if (!DDS.isLargeTablet()) {
tabBarRef.current?.goToPage(1);
} else {
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 564e319fe..d449ed6af 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -12,6 +12,7 @@ import {InteractionManager} from '../../utils';
import {db} from '../../utils/DB';
import {
eOnNewTopicAdded,
+ eOpenAddNotebookDialog,
eOpenAddTopicDialog,
eScrollEvent,
} from '../../utils/Events';
@@ -24,17 +25,20 @@ export const Notebook = ({route, navigation}) => {
let ranAfterInteractions = false;
- const runAfterInteractions = () => {
+ const runAfterInteractions = (time = 300) => {
InteractionManager.runAfterInteractions(() => {
+ let notebook = db.notebooks.notebook(params.notebook?.id).data;
+ params.notebook = notebook;
+ params.title = params.notebook.title
+ setTopics(notebook.topics);
if (loading) {
setLoading(false);
}
- Navigation.routeNeedsUpdate('Notebooks', () => {
+ Navigation.routeNeedsUpdate('Notebook', () => {
onLoad();
});
-
eSendEvent(eScrollEvent, {name: params.title, type: 'in'});
- if (route.params.menu) {
+ if (params.menu) {
navigation.setOptions({
animationEnabled: false,
gestureEnabled: false,
@@ -47,18 +51,17 @@ export const Notebook = ({route, navigation}) => {
}
updateSearch();
ranAfterInteractions = false;
- });
+ },time);
};
- const onLoad = () => {
- InteractionManager.runAfterInteractions(() => {
- setTopics(db.notebooks.notebook(route.params.notebook.id).data.topics);
- });
+ const onLoad = (data) => {
+ if (data) {
+ setLoading(true);
+ params = data;
+ }
+ console.log('calling on load')
+ runAfterInteractions(data? 500 : 1);
};
- useEffect(() => {
- onLoad();
- }, [route.params]);
-
useEffect(() => {
eSubscribeEvent(eOnNewTopicAdded, onLoad);
return () => {
@@ -113,8 +116,8 @@ export const Notebook = ({route, navigation}) => {
};
const _onPressBottomButton = () => {
- let n = route.params.notebook;
- eSendEvent(eOpenAddTopicDialog, n.id);
+ let n = params.notebook;
+ eSendEvent(eOpenAddTopicDialog, {notebookId: n.id});
};
return (
@@ -127,11 +130,16 @@ export const Notebook = ({route, navigation}) => {
}}
headerProps={{
heading: params.title,
+ paragraph: 'Edit notebook',
+ onPress: () => {
+ eSendEvent(eOpenAddNotebookDialog, params.notebook);
+ },
+ icon: 'pencil',
}}
loading={loading}
focused={() => navigation.isFocused()}
placeholderData={{
- heading: route.params.notebook.title,
+ heading: params.notebook.title,
paragraph: 'You have not added any topics yet.',
button: 'Add a topic',
action: _onPressBottomButton,
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 6041979e5..741c77f53 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -15,7 +15,12 @@ import SearchService from '../../services/SearchService';
import {editing, InteractionManager} from '../../utils';
import {COLORS_NOTE} from '../../utils/Colors';
import {db} from '../../utils/DB';
-import {eOnLoadNote, eScrollEvent, refreshNotesPage} from '../../utils/Events';
+import {
+ eOnLoadNote,
+ eOpenAddTopicDialog,
+ eScrollEvent,
+ refreshNotesPage,
+} from '../../utils/Events';
import {tabBarRef} from '../../utils/Refs';
export const Notes = ({route, navigation}) => {
@@ -27,22 +32,16 @@ export const Notes = ({route, navigation}) => {
let pageIsLoaded = false;
let ranAfterInteractions = false;
- const runAfterInteractions = (data) => {
+ const runAfterInteractions = (time = 300) => {
InteractionManager.runAfterInteractions(() => {
if (localLoad) {
setLocalLoad(false);
}
-
Navigation.routeNeedsUpdate('NotesPage', () => {
-
init();
});
- params = route.params;
- if (data) {
- params = data;
- }
- if (route.params.menu) {
+ if (params.menu) {
navigation.setOptions({
animationEnabled: false,
gestureEnabled: false,
@@ -53,26 +52,26 @@ export const Notes = ({route, navigation}) => {
gestureEnabled: Platform.OS === 'ios',
});
}
- let allNotes = [];
+
+ let _notes = [];
if (params.type === 'tag') {
- allNotes = db.notes.tagged(params.tag?.id);
+ _notes = db.notes.tagged(params.tag?.id);
} else if (params.type === 'color') {
- allNotes = db.notes.colored(params.color?.id);
+ _notes = db.notes.colored(params.color?.id);
} else {
- allNotes = db.notebooks
+ _notes = db.notebooks
.notebook(params.notebookId)
- .topics.topic(params.title).all;
+ .topics.topic(params.id).all;
}
if (
(params.type === 'tag' || params.type === 'color') &&
- (!allNotes || allNotes.length === 0)
+ (!_notes || _notes.length === 0)
) {
Navigation.goBack();
}
- setNotes([...allNotes]);
- setActionAfterFirstSave();
+ setNotes([..._notes]);
updateSearch();
dispatch({
type: Actions.CONTAINER_BOTTOM_BUTTON,
@@ -82,7 +81,7 @@ export const Notes = ({route, navigation}) => {
},
});
ranAfterInteractions = false;
- });
+ }, time);
};
useEffect(() => {
@@ -121,10 +120,14 @@ export const Notes = ({route, navigation}) => {
};
const init = (data) => {
+ if (data) {
+ setLocalLoad(true);
+ params = data;
+ setActionAfterFirstSave();
+ }
if (!ranAfterInteractions) {
- console.log('focus');
ranAfterInteractions = true;
- runAfterInteractions(data);
+ runAfterInteractions(data ? 500 : 1);
}
if (!pageIsLoaded) {
@@ -149,7 +152,7 @@ export const Notes = ({route, navigation}) => {
});
};
- const onFocus = useCallback(() => {
+ const onFocus = () => {
eSendEvent(eScrollEvent, {
name:
params.type === 'tag'
@@ -158,7 +161,7 @@ export const Notes = ({route, navigation}) => {
type: 'in',
});
init();
- }, []);
+ };
const onBlur = useCallback(() => {
setNotes([]);
@@ -208,7 +211,7 @@ export const Notes = ({route, navigation}) => {
});
};
- const _onPressBottomButton = useCallback(() => {
+ const _onPressBottomButton = () => {
setActionAfterFirstSave();
if (DDS.isPhone || DDS.isSmallTab) {
@@ -216,12 +219,12 @@ export const Notes = ({route, navigation}) => {
} else {
eSendEvent(eOnLoadNote, {type: 'new'});
}
- }, [params.type]);
+ };
return (
<>
<SimpleList
- listData={notes}
+ listData={notes.reverse()}
type="notes"
refreshCallback={() => {
init();
@@ -232,6 +235,20 @@ export const Notes = ({route, navigation}) => {
? '#' + params.title
: params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
color: params.type === 'color' ? params.title.toLowerCase() : null,
+ paragraph:
+ route.params.type === 'topic' && route.params.title !== 'General'
+ ? 'Edit topic'
+ : null,
+ onPress: () => {
+ console.log(route.params);
+ if (route.params.type !== 'topic') return;
+
+ eSendEvent(eOpenAddTopicDialog, {
+ notebookId: route.params.notebookId,
+ toEdit: route.params,
+ });
+ },
+ icon: 'pencil',
}}
loading={loading || localLoad}
focused={() => navigation.isFocused()}