Skip to content

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

refactor all screens & use new navigation

ammarahm-ededc8a558a89f
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 0c54d9a9f..22b123250 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -1,44 +1,16 @@
-import React, {createRef, useEffect, useState} from 'react';
-import {
- BackHandler,
- KeyboardAvoidingView,
- Linking,
- Platform,
- SafeAreaView,
- StatusBar,
- Text,
- TouchableOpacity,
- View,
-} from 'react-native';
+import React, { createRef, useEffect, useState } from 'react';
+import { BackHandler, KeyboardAvoidingView, Linking, Platform, SafeAreaView, StatusBar, TouchableOpacity, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import WebView from 'react-native-webview';
-import {normalize, SIZE, WEIGHT} from '../../common/common';
-import {
- ActionSheetEvent,
- simpleDialogEvent,
-} from '../../components/DialogManager/recievers';
-import {
- TEMPLATE_EXIT_FULLSCREEN,
- TEMPLATE_INFO,
-} from '../../components/DialogManager/templates';
-import {useTracked} from '../../provider';
-import {ACTIONS} from '../../provider/actions';
-import {
- eSendEvent,
- eSubscribeEvent,
- eUnSubscribeEvent,
-} from '../../services/eventManager';
-import {
- eClearEditor,
- eCloseFullscreenEditor,
- eOnLoadNote,
- eOpenFullscreenEditor,
- refreshNotesPage,
-} from '../../services/events';
-import {exitEditorAnimation} from '../../utils/animations';
-import {sideMenuRef} from '../../utils/refs';
-import {db, DDS, editing, timeConverter, ToastEvent} from '../../utils/utils';
-import InfoBar from './InfoBar';
+import { normalize, SIZE } from '../../common/common';
+import { ActionSheetEvent, simpleDialogEvent } from '../../components/DialogManager/recievers';
+import { TEMPLATE_EXIT_FULLSCREEN } from '../../components/DialogManager/templates';
+import { useTracked } from '../../provider';
+import { ACTIONS } from '../../provider/actions';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/eventManager';
+import { eClearEditor, eCloseFullscreenEditor, eOnLoadNote, eOpenFullscreenEditor, refreshNotesPage } from '../../services/events';
+import { exitEditorAnimation } from '../../utils/animations';
+import { db, DDS, editing, timeConverter, ToastEvent } from '../../utils/utils';
const InfoBarRef = createRef();
const EditorWebView = createRef();
diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.js
index d2f459977..781480733 100644
--- a/apps/mobile/src/views/Favorites/index.js
+++ b/apps/mobile/src/views/Favorites/index.js
@@ -1,30 +1,16 @@
+import {useIsFocused} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
-import Container from '../../components/Container';
-import {FavoritesPlaceHolder} from '../../components/ListPlaceholders';
-import {NotebookItem} from '../../components/NotebookItem';
-import NoteItem from '../../components/NoteItem';
-import SelectionWrapper from '../../components/SelectionWrapper';
+import SimpleList from '../../components/SimpleList';
+import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
-import {ToastEvent, w, db} from '../../utils/utils';
-import SimpleList from '../../components/SimpleList';
-import { useIsFocused } from '@react-navigation/native';
-export const Favorites = ({navigation}) => {
+import {db, ToastEvent} from '../../utils/utils';
+export const Favorites = ({route, navigation}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode, favorites} = state;
+ const {favorites} = state;
const [refreshing, setRefreshing] = useState(false);
const isFocused = useIsFocused();
- useEffect(() => {
- if (isFocused) {
- dispatch({
- type: ACTIONS.CURRENT_SCREEN,
- screen: 'favorites',
- });
- dispatch({type: ACTIONS.FAVORITES});
- }
- }, [isFocused]);
-
const _onRefresh = async () => {
setRefreshing(true);
try {
@@ -40,82 +26,72 @@ export const Favorites = ({navigation}) => {
}
};
- const _renderItem = ({item, index}) => (
- <SelectionWrapper item={item}>
- {item.type === 'note' ? (
- <NoteItem
- customStyle={{
- width: selectionMode ? w - 74 : '100%',
- marginHorizontal: 0,
- }}
- colors={colors}
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: !selectionMode,
- });
- }
- dispatch({
- type: ACTIONS.SELECTED_ITEMS,
- item: item,
- });
- }}
- item={item}
- index={index}
- isTrash={false}
- />
- ) : (
- <NotebookItem
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: !selectionMode,
- });
- }
- dispatch({
- type: ACTIONS.SELECTED_ITEMS,
- item: item,
- });
- }}
- customStyle={{
- width: selectionMode ? w - 74 : '100%',
- marginHorizontal: 0,
- }}
- item={item}
- isTrash={false}
- index={index}
- />
- )}
- </SelectionWrapper>
- );
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: 'notes',
+ menu: true,
+ canGoBack: false,
+ route: route,
+ color: null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ visible: false,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: 'Favorites',
+ },
+ });
+
+ dispatch({
+ type: ACTIONS.CURRENT_SCREEN,
+ screen: 'favorites',
+ });
+ dispatch({type: ACTIONS.FAVORITES});
+ }
+ }, [isFocused]);
+
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ placeholder: 'Search all favorites',
+ data: favorites,
+ noSearch: false,
+ type: 'notes',
+ color: null,
+ },
+ });
+ }
+ }, [favorites, isFocused]);
return (
- <Container
- menu={true}
- heading="Favorites"
- placeholder="Search your notes"
- canGoBack={false}
- customIcon="menu"
+ <SimpleList
data={favorites}
type="notes"
- noBottomButton={true}>
- <SimpleList
- data={favorites}
- type="notes"
- refreshing={refreshing}
- focused={isFocused}
- onRefresh={_onRefresh}
- renderItem={_renderItem}
- placeholder={<FavoritesPlaceHolder />}
- placeholderText="Notes you favorite appear here"
- />
- </Container>
+ refreshing={refreshing}
+ focused={isFocused}
+ onRefresh={_onRefresh}
+ RenderItem={NoteItemWrapper}
+ placeholder={<></>}
+ placeholderText="Notes you favorite appear here"
+ />
);
};
-
export default Favorites;
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index 3f9701784..42e952cee 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -1,28 +1,17 @@
import {useIsFocused} from '@react-navigation/native';
import React, {useEffect} from 'react';
import {BackHandler} from 'react-native';
-import Container from '../../components/Container';
import {AddNotebookEvent} from '../../components/DialogManager/recievers';
-import {NotebookPlaceHolder} from '../../components/ListPlaceholders';
-import {NotebookItem} from '../../components/NotebookItem';
-import SelectionWrapper from '../../components/SelectionWrapper';
import SimpleList from '../../components/SimpleList';
+import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapper';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {eScrollEvent} from '../../services/events';
import NavigationService from '../../services/NavigationService';
-import {slideRight} from '../../utils/animations';
-import {w} from '../../utils/utils';
export const Folders = ({route, navigation}) => {
const [state, dispatch] = useTracked();
- const {
- colors,
- selectionMode,
- pinned,
- notebooks,
- preventDefaultMargins,
- } = state;
+ const {notebooks} = state;
let isFocused = useIsFocused();
const handleBackPress = () => {
@@ -35,8 +24,40 @@ export const Folders = ({route, navigation}) => {
};
useEffect(() => {
-
if (isFocused) {
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: 'notebooks',
+ menu: !params.canGoBack,
+ canGoBack: params.canGoBack,
+ route: route,
+ color: null,
+ navigation: navigation,
+ ind:!params.root
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ bottomButtonText: 'Create a new notebook',
+ bottomButtonOnPress: () => AddNotebookEvent(),
+ color: null,
+ visible: true,
+ ind:!params.root
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: params.title,
+ ind:!params.root
+ },
+ });
dispatch({type: ACTIONS.PINNED});
dispatch({type: ACTIONS.NOTEBOOKS});
dispatch({
@@ -44,8 +65,25 @@ export const Folders = ({route, navigation}) => {
screen: 'notebooks',
});
}
+
}, [isFocused]);
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ placeholder:params.root? 'Search all notebooks' : 'Select a notebook',
+ data: notebooks,
+ noSearch: false,
+ type: 'notebooks',
+ color: null,
+ ind:!params.root
+ },
+ });
+ }
+ }, [notebooks, isFocused]);
+
useEffect(() => {
eSendEvent(eScrollEvent, 0);
let backhandler;
@@ -64,70 +102,19 @@ export const Folders = ({route, navigation}) => {
const params = route.params;
- const _renderItem = ({item, index}) => (
- <SelectionWrapper item={item}>
- <NotebookItem
- hideMore={params.hideMore}
- navigation={navigation}
- route={route}
- customStyle={{
- width: selectionMode ? w - 74 : '100%',
- marginHorizontal: 0,
- }}
- isMove={params.isMove}
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: !selectionMode,
- });
- }
-
- dispatch({
- type: ACTIONS.SELECTED_ITEMS,
- item: item,
- });
- }}
- noteToMove={params.note}
- item={item}
- index={index}
- />
- </SelectionWrapper>
- );
-
return (
- <Container
- bottomButtonText="Create a new notebook"
- menu={route.params.canGoBack ? false : true}
- preventDefaultMargins={preventDefaultMargins}
- heading={params.title}
- canGoBack={params.canGoBack}
- route={route}
- navigation={navigation}
- placeholder="Search all notebooks"
+ <SimpleList
data={notebooks}
type="notebooks"
- bottomButtonOnPress={() => {
- AddNotebookEvent(null);
- }}>
- <SimpleList
- data={notebooks}
- type="notebooks"
- focused={isFocused}
- renderItem={_renderItem}
- hideMore={params.hideMore}
- isMove={params.isMove}
- noteToMove={params.note}
- placeholder={
- <>
- <NotebookPlaceHolder animation={slideRight} colors={colors} />
- </>
- }
- pinned={pinned.notebooks}
- placeholderText="Notebooks you add will appear here"
- />
- </Container>
+ focused={isFocused}
+ RenderItem={NotebookItemWrapper}
+ hideMore={params.hideMore}
+ isMove={params.isMove}
+ noteToMove={params.note}
+ placeholder={<></>}
+ pinned={true}
+ placeholderText="Notebooks you add will appear here"
+ />
);
};
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 08c6e3e88..2731bcfe1 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -1,30 +1,17 @@
-import { useIsFocused } from '@react-navigation/native';
-import React, { useEffect } from 'react';
-import Container from '../../components/Container';
-import { NotesPlaceHolder } from '../../components/ListPlaceholders';
-import NoteItem from '../../components/NoteItem';
-import SelectionHeader from '../../components/SelectionHeader';
-import SelectionWrapper from '../../components/SelectionWrapper';
+import {useIsFocused} from '@react-navigation/native';
+import React, {useEffect} from 'react';
import SimpleList from '../../components/SimpleList';
-import { useTracked } from '../../provider';
-import { ACTIONS } from '../../provider/actions';
-import { eSendEvent } from '../../services/eventManager';
-import { eOnLoadNote, eScrollEvent } from '../../services/events';
-import { openEditorAnimation } from '../../utils/animations';
-import { sideMenuRef } from '../../utils/refs';
-import { DDS } from '../../utils/utils';
-let count = 0;
+import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';
+import {useTracked} from '../../provider';
+import {ACTIONS} from '../../provider/actions';
+import {eSendEvent} from '../../services/eventManager';
+import {eOnLoadNote, eScrollEvent} from '../../services/events';
+import {openEditorAnimation} from '../../utils/animations';
+import {DDS} from '../../utils/utils';
-export const Home = ({navigation}) => {
+export const Home = ({route, navigation}) => {
const [state, dispatch] = useTracked();
- const {
- colors,
- selectionMode,
- currentEditingNote,
- loading,
- notes,
- pinned,
- } = state;
+ const {notes} = state;
const isFocused = useIsFocused();
useEffect(() => {
@@ -33,79 +20,87 @@ export const Home = ({navigation}) => {
type: ACTIONS.CURRENT_SCREEN,
screen: 'home',
});
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: 'notes',
+ menu: true,
+ canGoBack: false,
+ route: route,
+ color: null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: true,
+ });
+
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ bottomButtonText: 'Create a new Note',
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: 'Home',
+ },
+ });
+
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ bottomButtonText: 'Create a new note',
+ bottomButtonOnPress: () => {
+ if (DDS.isTab) {
+ eSendEvent(eOnLoadNote, {type: 'new'});
+ } else {
+ eSendEvent(eOnLoadNote, {type: 'new'});
+ openEditorAnimation();
+ }
+ },
+ color: null,
+ visible: true,
+ },
+ });
eSendEvent(eScrollEvent, 0);
dispatch({type: ACTIONS.COLORS});
dispatch({type: ACTIONS.NOTES});
dispatch({type: ACTIONS.PINNED});
}
}, [isFocused]);
- const _renderItem = ({item, index}) => (
- <SelectionWrapper
- index={index}
- currentEditingNote={
- currentEditingNote === item.id ? currentEditingNote : null
- }
- item={item}>
- <NoteItem
- colors={colors}
- customStyle={{
- width: selectionMode ? '90%' : '100%',
- marginHorizontal: 0,
- }}
- currentEditingNote={
- currentEditingNote === item.id ? currentEditingNote : null
- }
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
- }
- dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
- }}
- update={() => {
- dispatch({type: ACTIONS.NOTES});
- }}
- item={item}
- index={index}
- />
- </SelectionWrapper>
- );
- return (
- <Container
- bottomButtonText="Create a new note"
- heading="Home"
- customIcon="menu"
- verticalMenu
- type="notes"
- menu
- placeholder="Search all notes"
- canGoBack={false}
- bottomButtonOnPress={() => {
- if (DDS.isTab) {
- eSendEvent(eOnLoadNote, {type: 'new'});
- } else {
- eSendEvent(eOnLoadNote, {type: 'new'});
- openEditorAnimation();
- }
- }}
- data={notes ? notes : []}>
- <SelectionHeader />
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ placeholder: 'Search all notes',
+ data: notes,
+ noSearch: false,
+ type: 'notes',
+ color: null,
+ },
+ });
+ }
+ }, [notes, isFocused]);
+ return (
+ <>
<SimpleList
data={notes}
type="notes"
isHome={true}
- pinned={pinned.notes}
+ pinned={true}
focused={isFocused}
- renderItem={_renderItem}
- placeholder={<NotesPlaceHolder colors={colors} />}
+ RenderItem={NoteItemWrapper}
+ placeholder={<></>}
placeholderText={`Notes you write appear here`}
/>
- </Container>
+ </>
);
};
-
-
export default Home;
diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js
index 7284dee27..64fa8b59d 100644
--- a/apps/mobile/src/views/Login/index.js
+++ b/apps/mobile/src/views/Login/index.js
@@ -119,6 +119,56 @@ export const Login = ({route, navigation}) => {
}
};
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: null,
+ menu: false,
+ canGoBack: true,
+ route: route,
+ color: null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ visible: false,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_STATE,
+ state: {
+ noSelectionHeader: true,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: 'Login',
+ },
+ });
+
+ dispatch({
+ type: ACTIONS.CURRENT_SCREEN,
+ screen: 'login',
+ });
+
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ noSearch: true,
+ },
+ });
+ }
+ }, [isFocused]);
return (
<View
style={{
@@ -156,13 +206,11 @@ export const Login = ({route, navigation}) => {
{loggingIn ? null : (
<>
- <Header
- navigation={navigation}
- route={route}
- isLoginNavigator={isLoginNavigator}
- colors={colors}
- heading="Login"
- />
+ <View
+ style={{
+ marginTop: Platform.OS == 'ios' ? 125 - 60 : 125 - 60,
+ }}
+ />
<View
style={{
@@ -479,7 +527,7 @@ export const Login = ({route, navigation}) => {
onPress={_logIn}
style={{
...getElevation(5),
- padding: pv,
+ padding: pv + 2,
backgroundColor: colors.accent,
borderRadius: 5,
marginHorizontal: 12,
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 56fcb6517..2711841ef 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -1,5 +1,4 @@
import React, {useEffect, useState} from 'react';
-import Container from '../../components/Container';
import {AddTopicEvent} from '../../components/DialogManager/recievers';
import {NotebookPlaceHolder} from '../../components/ListPlaceholders';
import {NotebookItem} from '../../components/NotebookItem';
@@ -7,7 +6,7 @@ import SelectionWrapper from '../../components/SelectionWrapper';
import SimpleList from '../../components/SimpleList';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
-import { useIsFocused } from '@react-navigation/native';
+import {useIsFocused} from '@react-navigation/native';
import {
eSendEvent,
eSubscribeEvent,
@@ -17,12 +16,12 @@ import {
eMoveNoteDialogNavigateBack,
eOnNewTopicAdded,
eScrollEvent,
+ eSetModalNavigator,
} from '../../services/events';
import {db, ToastEvent, w} from '../../utils/utils';
-export const Notebook = ({route,navigation}) => {
+export const Notebook = ({route, navigation}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode, preventDefaultMargins} = state;
const [topics, setTopics] = useState([]);
const [refreshing, setRefreshing] = useState(false);
@@ -33,11 +32,8 @@ export const Notebook = ({route,navigation}) => {
const onLoad = () => {
let allTopics;
- allTopics = db.notebooks.notebook(route.params.notebook.id).data
- .topics;
-
+ allTopics = db.notebooks.notebook(route.params.notebook.id).data.topics;
notebook = db.notebooks.notebook(route.params.notebook.id);
-
setTopics(allTopics);
};
@@ -62,14 +58,72 @@ export const Notebook = ({route,navigation}) => {
useEffect(() => {
if (isFocused) {
+ onLoad();
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: 'topics',
+ menu: false,
+ canGoBack: true,
+ heading:params.title,
+ route: route,
+ color: null,
+ navigation: navigation,
+ ind: !params.root,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ visible: true,
+ bottomButtonOnPress: () => {
+ let n = route.params.notebook;
+ AddTopicEvent(n);
+ },
+ color: null,
+ bottomButtonText: 'Add new topic',
+ ind: !params.root
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: params.title,
+ ind: !params.root
+ },
+ });
+
dispatch({
type: ACTIONS.CURRENT_SCREEN,
screen: 'notebook',
});
- onLoad();
+ if (!params.root) {
+ eSendEvent(eSetModalNavigator,true);
+ }
}
}, [isFocused]);
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ placeholder: `Search in "${params.title}"`,
+ data: topics,
+ noSearch: false,
+ type: 'topics',
+ color: null,
+ ind: !params.root
+ },
+ });
+ }
+ }, [topics, isFocused]);
+
useEffect(() => {
eSubscribeEvent(eMoveNoteDialogNavigateBack, handleBackPress);
return () => {
@@ -77,10 +131,47 @@ export const Notebook = ({route,navigation}) => {
};
}, []);
- const _renderItem = ({item, index}) => (
+ const _onRefresh = async () => {
+ setRefreshing(true);
+ try {
+ await db.sync();
+
+ onLoad();
+ dispatch({type: ACTIONS.USER});
+ setRefreshing(false);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
+ setRefreshing(false);
+ ToastEvent.show('Sync failed, network error', 'error');
+ }
+ };
+
+ return (
+ <SimpleList
+ data={topics}
+ type="topics"
+ customRefreshing={refreshing}
+ focused={isFocused}
+ customRefresh={_onRefresh}
+ RenderItem={RenderItem}
+ placeholder={<></>}
+ placeholderText=""
+ />
+ );
+};
+
+export default Notebook;
+
+const RenderItem = ({item, index}) => {
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, preventDefaultMargins} = state;
+ let headerState = preventDefaultMargins? state.indHeaderState : state.headerState;
+ let params = headerState.route.params? headerState.route.params : {};
+
+ return (
<SelectionWrapper item={item}>
<NotebookItem
- hideMore={params.hideMore}
+ hideMore={preventDefaultMargins}
isTopic={true}
customStyle={{
width: selectionMode ? w - 74 : '100%',
@@ -100,58 +191,14 @@ export const Notebook = ({route,navigation}) => {
});
}}
noteToMove={params.note}
- notebookID={params.notebook.id}
- isMove={params.isMove}
+ notebookID={params.notebook?.id}
+ isMove={preventDefaultMargins}
refresh={() => {}}
item={item}
index={index}
colors={colors}
- data={topics}
+ data={params.notebook?.topics}
/>
</SelectionWrapper>
);
-
- const _onRefresh = async () => {
- setRefreshing(true);
- try {
- await db.sync();
-
- onLoad();
- dispatch({type: ACTIONS.USER});
- setRefreshing(false);
- ToastEvent.show('Sync Complete', 'success');
- } catch (e) {
- setRefreshing(false);
- ToastEvent.show('Sync failed, network error', 'error');
- }
- };
-
- return (
- <Container
- bottomButtonText="Create a new topic"
- preventDefaultMargins={preventDefaultMargins}
- navigation={navigation}
- placeholder={`Search in "${params.title}"`}
- heading={params.title}
- canGoBack={true}
- type="topics"
- data={topics}
- bottomButtonOnPress={() => {
- let n = navigation.state.params.notebook;
- AddTopicEvent(n);
- }}>
- <SimpleList
- data={topics}
- type="topics"
- customRefreshing={refreshing}
- focused={isFocused}
- customRefresh={_onRefresh}
- renderItem={_renderItem}
- placeholder={<NotebookPlaceHolder colors={colors} />}
- placeholderText="Topics added to notebook appear here."
- />
- </Container>
- );
};
-
-export default Notebook;
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index eb2f225e5..7efad06ca 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -1,10 +1,7 @@
+import {useIsFocused} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
-import { useIsFocused } from '@react-navigation/native';
-import Container from '../../components/Container';
-import {NotesPlaceHolder} from '../../components/ListPlaceholders';
-import NoteItem from '../../components/NoteItem';
-import SelectionWrapper from '../../components/SelectionWrapper';
import SimpleList from '../../components/SimpleList';
+import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapper';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {
@@ -19,11 +16,11 @@ import {
} from '../../services/events';
import {openEditorAnimation} from '../../utils/animations';
import {db, DDS, editing, ToastEvent} from '../../utils/utils';
-import {sideMenuRef} from '../../utils/refs';
+import { NoteItemWrapper } from '../../components/SimpleList/NoteItemWrapper';
-export const Notes = ({route,navigation}) => {
+export const Notes = ({route, navigation}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode, currentEditingNote, colorNotes} = state;
+ const {colorNotes} = state;
const allNotes = state.notes;
const [notes, setNotes] = useState([]);
const [refreshing, setRefreshing] = useState(false);
@@ -63,7 +60,7 @@ export const Notes = ({route,navigation}) => {
};
}, []);
- const init = (data) => {
+ const init = data => {
params = route.params;
if (data) {
params = data;
@@ -85,41 +82,70 @@ export const Notes = ({route,navigation}) => {
}
};
- const _renderItem = ({item, index}) => (
- <SelectionWrapper
- index={index}
- currentEditingNote={
- currentEditingNote === item.dateCreated ? currentEditingNote : null
- }
- item={item}>
- <NoteItem
- colors={colors}
- customStyle={{
- width: selectionMode ? '90%' : '100%',
- marginHorizontal: 0,
- }}
- currentEditingNote={
- currentEditingNote === item.dateCreated ? currentEditingNote : null
- }
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: !selectionMode,
- });
- }
- dispatch({
- type: ACTIONS.SELECTED_ITEMS,
- item: item,
- });
- }}
- update={() => {}}
- item={item}
- index={index}
- />
- </SelectionWrapper>
- );
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: 'notes',
+ menu: params.type === 'color' ? true : false,
+ canGoBack: params.type === 'color' ? false : true,
+ route: route,
+ color: params.type == 'color' ? params.title : null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ visible: true,
+ color: params.type == 'color' ? params.title : null,
+ bottomButtonOnPress: _bottomBottomOnPress,
+ bottomButtonText: 'Create a new note',
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading:
+ params.type == 'tag'
+ ? '#' + params.title
+ : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
+ },
+ });
+ init();
+ dispatch({
+ type: ACTIONS.CURRENT_SCREEN,
+ screen: params.type,
+ });
+ } else {
+ setNotes([]);
+ editing.actionAfterFirstSave = {
+ type: null,
+ };
+ }
+ }, [isFocused, allNotes, colorNotes]);
+
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ placeholder: `Search in ${
+ params.type == 'tag' ? '#' + params.title : params.title
+ }`,
+ data: notes,
+ noSearch: false,
+ type: 'notes',
+ color: params.type == 'color' ? params.title : null,
+ },
+ });
+ }
+ }, [favorites, isFocused]);
const _onRefresh = async () => {
setRefreshing(true);
@@ -163,35 +189,18 @@ export const Notes = ({route,navigation}) => {
};
return (
- <Container
- bottomButtonText="Create a new note"
- canGoBack={params.type === 'color' ? false : true}
- menu={params.type === 'color' ? true : false}
- heading={
- params.type == 'tag'
- ? '#' + params.title
- : params.title.slice(0, 1).toUpperCase() + params.title.slice(1)
- }
- headerColor={params.type == 'color' ? params.title : null}
+ <SimpleList
data={notes}
type="notes"
- placeholder={`Search in ${
- params.type == 'tag' ? '#' + params.title : params.title
+ customRefreshing={refreshing}
+ focused={isFocused}
+ customRefresh={_onRefresh}
+ RenderItem={NoteItemWrapper}
+ placeholder={<></>}
+ placeholderText={`Add some notes to this" ${
+ params.type ? params.type : 'topic.'
}`}
- bottomButtonOnPress={_bottomBottomOnPress}>
- <SimpleList
- data={notes}
- type="notes"
- customRefreshing={refreshing}
- focused={isFocused}
- customRefresh={_onRefresh}
- renderItem={_renderItem}
- placeholder={<NotesPlaceHolder colors={colors} />}
- placeholderText={`Add some notes to this" ${
- params.type ? params.type : 'topic.'
- }`}
- />
- </Container>
+ />
);
};
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index 6806ea2a7..283cfceae 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -33,13 +33,15 @@ import {eOpenLoginDialog} from '../../services/events';
import NavigationService from '../../services/NavigationService';
import {hexToRGBA, w, DDS, setSetting, db, ToastEvent} from '../../utils/utils';
import {Toast} from '../../components/Toast';
+import {useIsFocused} from '@react-navigation/native';
+import * as Animatable from 'react-native-animatable';
-export const Settings = ({navigation}) => {
+export const Settings = ({route, navigation}) => {
const [state, dispatch] = useTracked();
const {colors, user, settings} = state;
const [key, setKey] = useState('');
const [modalVisible, setModalVisible] = useState(false);
-
+ const isFocused = useIsFocused();
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent);
StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
@@ -54,20 +56,58 @@ export const Settings = ({navigation}) => {
}
useEffect(() => {
- dispatch({
- type: ACTIONS.CURRENT_SCREEN,
- screen: 'settings',
- });
- },[])
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ visible: false,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: null,
+ menu: true,
+ canGoBack: false,
+ route: route,
+ color: null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: 'Settings',
+ },
+ });
+
+ dispatch({
+ type: ACTIONS.CURRENT_SCREEN,
+ screen: 'settings',
+ });
+
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ noSearch: true,
+ },
+ });
+ }
+ }, [isFocused]);
return (
- <Container
- menu={true}
- heading="Settings"
- canGoBack={false}
- noSearch={true}
- noSelectionHeader={true}
- noBottomButton={true}>
+ <Animatable.View
+ transition="backgroundColor"
+ duration={300}
+ style={{
+ height: '100%',
+ backgroundColor: colors.bg,
+ }}>
<View
style={{
marginTop: Platform.OS == 'ios' ? 125 - 60 : 125 - 60,
@@ -631,95 +671,6 @@ export const Settings = ({navigation}) => {
/>
</TouchableOpacity>
) : null}
- {/*
- <Text
- style={{
- fontSize: SIZE.xs,
- fontFamily: WEIGHT.bold,
- textAlignVertical: 'center',
- color: colors.accent,
-
- borderBottomColor: colors.nav,
- borderBottomWidth: 0.5,
- paddingBottom: 3,
- }}>
- Editor Settings
- </Text>
-
- <TouchableOpacity
- activeOpacity={opacity}
- onPress={async () => {
- await setSetting(
- settings,
- 'showToolbarOnTop',
- !settings.showToolbarOnTop,
- );
- }}
- style={{
- width: '100%',
- marginHorizontal: 0,
- flexDirection: 'row',
- marginTop: pv + 5,
- alignItems: 'center',
- justifyContent: 'space-between',
- paddingBottom: pv + 5,
- }}>
- <Text
- style={{
- fontSize: SIZE.sm,
- fontFamily: WEIGHT.regular,
- textAlignVertical: 'center',
- color: colors.pri,
- }}>
- Show toolbar on top
- </Text>
- <Icon
- size={SIZE.xl}
- color={settings.showToolbarOnTop ? colors.accent : colors.icon}
- name={
- settings.showToolbarOnTop ? 'toggle-switch' : 'toggle-switch-off'
- }
- />
- </TouchableOpacity>
- <TouchableOpacity
- activeOpacity={opacity}
- onPress={async () => {
- await setSetting(
- settings,
- 'showKeyboardOnOpen',
- !settings.showKeyboardOnOpen,
- );
- }}
- style={{
- width: '100%',
- marginHorizontal: 0,
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between',
-
- paddingVertical: pv + 5,
- }}>
- <Text
- style={{
- fontSize: SIZE.sm,
- fontFamily: WEIGHT.regular,
- textAlignVertical: 'center',
- color: colors.pri,
- }}>
- Show keyboard on open
- </Text>
- <Icon
- size={SIZE.xl}
- color={settings.showKeyboardOnOpen ? colors.accent : colors.icon}
- name={
- settings.showKeyboardOnOpen
- ? 'toggle-switch'
- : 'toggle-switch-off'
- }
- />
- </TouchableOpacity>
-
- */}
<Text
style={{
@@ -776,9 +727,8 @@ export const Settings = ({navigation}) => {
}}
/>
</ScrollView>
- </Container>
+ </Animatable.View>
);
};
-
export default Settings;
diff --git a/apps/mobile/src/views/Signup/index.js b/apps/mobile/src/views/Signup/index.js
index ec0f00c52..2542a08a9 100644
--- a/apps/mobile/src/views/Signup/index.js
+++ b/apps/mobile/src/views/Signup/index.js
@@ -114,6 +114,57 @@ export const Signup = ({route, navigation}) => {
}
};
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: null,
+ menu: false,
+ canGoBack: true,
+ route: route,
+ color: null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ visible: false,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_STATE,
+ state: {
+ noSelectionHeader: true,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: 'Create Account',
+ },
+ });
+
+ dispatch({
+ type: ACTIONS.CURRENT_SCREEN,
+ screen: 'signup',
+ });
+
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ noSearch: true,
+ },
+ });
+ }
+ }, [isFocused]);
+
return (
<View
style={{
@@ -289,12 +340,10 @@ export const Signup = ({route, navigation}) => {
{signingIn ? null : (
<>
- <Header
- isLoginNavigator={isLoginNavigator}
- navigation={navigation}
- colors={colors}
- route={route}
- heading="Create Account"
+ <View
+ style={{
+ marginTop: Platform.OS == 'ios' ? 125 - 60 : 125 - 60,
+ }}
/>
<View
@@ -658,7 +707,7 @@ export const Signup = ({route, navigation}) => {
onPress={_signUp}
style={{
...getElevation(5),
- padding: pv,
+ padding: pv+2,
backgroundColor: colors.accent,
borderRadius: 5,
marginHorizontal: 12,
diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.js
index c6a58783c..a972f605a 100644
--- a/apps/mobile/src/views/Tags/index.js
+++ b/apps/mobile/src/views/Tags/index.js
@@ -1,6 +1,6 @@
import React, {useEffect} from 'react';
import {Text, TouchableOpacity, View} from 'react-native';
-import { useIsFocused } from '@react-navigation/native';
+import {useIsFocused} from '@react-navigation/native';
import {pv, SIZE, WEIGHT} from '../../common/common';
import Container from '../../components/Container';
import {TagsPlaceHolder} from '../../components/ListPlaceholders';
@@ -9,12 +9,42 @@ import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import NavigationService from '../../services/NavigationService';
-export const Tags = ({navigation}) => {
+export const Tags = ({route, navigation}) => {
const [state, dispatch] = useTracked();
const {colors, tags} = state;
const isFocused = useIsFocused();
+
useEffect(() => {
if (isFocused) {
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: 'trash',
+ menu: true,
+ canGoBack: false,
+ route: route,
+ color: null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ visible: false,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: 'Tags',
+ },
+ });
+
dispatch({type: ACTIONS.TAGS});
dispatch({
type: ACTIONS.CURRENT_SCREEN,
@@ -23,7 +53,39 @@ export const Tags = ({navigation}) => {
}
}, [isFocused]);
- const _renderItem = ({item, index}) => (
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ placeholder: 'Search all tags',
+ data: tags,
+ noSearch: false,
+ type: 'tags',
+ color: null,
+ },
+ });
+ }
+ }, [tags, isFocused]);
+
+ return (
+ <SimpleList
+ data={tags}
+ type="tags"
+ focused={isFocused}
+ RenderItem={RenderItem}
+ placeholder={<TagsPlaceHolder colors={colors} />}
+ placeholderText="Tags added to notes appear here"
+ />
+ );
+};
+
+export default Tags;
+
+const RenderItem = ({item, index}) => {
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+ return (
<TouchableOpacity
key={item.title}
onPress={() => {
@@ -70,33 +132,4 @@ export const Tags = ({navigation}) => {
</Text>
</TouchableOpacity>
);
-
- return (
- <Container
- canGoBack={false}
- heading="Tags"
- noBottomButton={true}
- placeholder="Search for #tags"
- data={tags}
- type="tags"
- menu>
- <View
- style={{
- paddingHorizontal: 12,
- height: '100%',
- width: '100%',
- }}>
- <SimpleList
- data={tags}
- type="tags"
- focused={isFocused}
- renderItem={_renderItem}
- placeholder={<TagsPlaceHolder colors={colors} />}
- placeholderText="Tags added to notes appear here"
- />
- </View>
- </Container>
- );
};
-
-export default Tags;
diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js
index 17b3ef37c..4d79f8d28 100644
--- a/apps/mobile/src/views/Trash/index.js
+++ b/apps/mobile/src/views/Trash/index.js
@@ -1,6 +1,5 @@
+import {useIsFocused} from '@react-navigation/native';
import React, {useEffect} from 'react';
-import { useIsFocused } from '@react-navigation/native';
-import Container from '../../components/Container';
import {simpleDialogEvent} from '../../components/DialogManager/recievers';
import {TEMPLATE_EMPTY_TRASH} from '../../components/DialogManager/templates';
import {TrashPlaceHolder} from '../../components/ListPlaceholders';
@@ -11,14 +10,49 @@ import SimpleList from '../../components/SimpleList';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {w} from '../../utils/utils';
+import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';
+import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapper';
-export const Trash = ({navigation}) => {
+export const Trash = ({route, navigation}) => {
const [state, dispatch] = useTracked();
const {colors, selectionMode, trash} = state;
const isFocused = useIsFocused();
+
useEffect(() => {
if (isFocused) {
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ type: 'trash',
+ menu: true,
+ canGoBack: false,
+ route: route,
+ color: null,
+ navigation: navigation,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ bottomButtonText: 'Clear all trash',
+ bottomButtonOnPress: () => simpleDialogEvent(TEMPLATE_EMPTY_TRASH),
+ color: null,
+ visible: true,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_VERTICAL_MENU,
+ state: false,
+ });
+
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: 'Trash',
+ },
+ });
+
dispatch({
type: ACTIONS.TRASH,
});
@@ -30,82 +64,39 @@ export const Trash = ({navigation}) => {
}
}, [isFocused]);
- const _renderItem = ({item, index}) => (
- <SelectionWrapper colors={colors} item={item}>
- {item.type === 'note' ? (
- <NoteItem
- customStyle={{
- width: selectionMode ? w - 74 : '100%',
- marginHorizontal: 0,
- }}
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: !selectionMode,
- });
- }
- dispatch({
- type: ACTIONS.SELECTED_ITEMS,
- item: item,
- });
- }}
- colors={colors}
- item={item}
- index={index}
- isTrash={true}
- />
- ) : (
- <NotebookItem
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: !selectionMode,
- });
- }
- dispatch({
- type: ACTIONS.SELECTED_ITEMS,
- item: item,
- });
- }}
- customStyle={{
- width: selectionMode ? w - 74 : '100%',
- marginHorizontal: 0,
- }}
- item={item}
- isTrash={true}
- index={index}
- />
- )}
- </SelectionWrapper>
- );
+ useEffect(() => {
+ if (isFocused) {
+ dispatch({
+ type: ACTIONS.SEARCH_STATE,
+ state: {
+ placeholder: 'Search all trash',
+ data: trash,
+ noSearch: false,
+ type: 'trash',
+ color: null,
+ },
+ });
+ }
+ }, [trash, isFocused]);
return (
- <Container
- bottomButtonOnPress={() => {
- simpleDialogEvent(TEMPLATE_EMPTY_TRASH);
- }}
- placeholder="Search in trash"
- noSearch={false}
- heading="Trash"
- canGoBack={false}
- menu={true}
- type="trash"
+ <SimpleList
data={trash}
- bottomButtonText="Clear all trash">
- <SimpleList
- data={trash}
- type="trash"
- focused={isFocused}
- renderItem={_renderItem}
- placeholder={<TrashPlaceHolder colors={colors} />}
- placeholderText="Deleted notes & notebooks appear here."
- />
- </Container>
+ type="trash"
+ focused={isFocused}
+ RenderItem={RenderItem}
+ placeholder={<TrashPlaceHolder colors={colors} />}
+ placeholderText="Deleted notes & notebooks appear here."
+ />
);
};
export default Trash;
+
+const RenderItem = ({item, index}) => {
+ return item.type === 'note' ? (
+ <NoteItemWrapper item={item} index={index} isTrash={true} />
+ ) : (
+ <NotebookItemWrapper item={item} index={index} isTrash={true} />
+ );
+};