Skip to content

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

add placeholders

Ammar Ahmedbdfb1ab09bd1
diff --git a/apps/mobile/src/components/delaylayout/defaultplaceholder.tsx b/apps/mobile/src/components/delaylayout/defaultplaceholder.tsx
new file mode 100644
index 000000000..c212fd760
--- /dev/null
+++ b/apps/mobile/src/components/delaylayout/defaultplaceholder.tsx
@@ -0,0 +1,194 @@
+import React from 'react';
+import { View } from 'react-native';
+import { useMessageStore } from '../../stores/use-message-store';
+import { useThemeStore } from '../../stores/use-theme-store';
+
+export const DefaultPlaceholder = () => {
+ const colors = useThemeStore(state => state.colors);
+ const message = useMessageStore(state => state.message);
+ const annoucements = useMessageStore(state => state.announcements);
+ const hasAnnoucements = annoucements.length > 0;
+
+ return (
+ <View
+ style={{
+ width: '100%',
+ paddingHorizontal: 12
+ }}
+ >
+ {hasAnnoucements ? (
+ <View
+ style={{
+ width: '100%',
+ height: 100,
+ borderRadius: 10,
+ marginBottom: 20,
+ backgroundColor: colors.nav,
+ padding: 12
+ }}
+ >
+ <View
+ style={{
+ width: 150,
+ height: 20,
+ backgroundColor: colors.transGray,
+ borderRadius: 5,
+ marginBottom: 10
+ }}
+ />
+ <View
+ style={{
+ width: 250,
+ height: 14,
+ backgroundColor: colors.transGray,
+ borderRadius: 5
+ }}
+ />
+
+ <View
+ style={{
+ width: 60,
+ height: 15,
+ backgroundColor: colors.shade,
+ borderRadius: 3,
+ marginTop: 10
+ }}
+ />
+ </View>
+ ) : null}
+
+ {message ? (
+ <View
+ style={{
+ width: '100%',
+ height: 60,
+ borderRadius: 10,
+ marginBottom: 20,
+ flexDirection: 'row',
+ alignItems: 'center',
+ paddingHorizontal: 20
+ }}
+ >
+ <View
+ style={{
+ width: 40,
+ height: 40,
+ backgroundColor: colors.shade,
+ borderRadius: 100,
+ marginRight: 10
+ }}
+ />
+ <View>
+ <View
+ style={{
+ width: 150,
+ height: 12,
+ backgroundColor: colors.nav,
+ borderRadius: 5,
+ marginBottom: 10
+ }}
+ />
+ <View
+ style={{
+ width: 250,
+ height: 16,
+ backgroundColor: colors.nav,
+ borderRadius: 5
+ }}
+ />
+ </View>
+ </View>
+ ) : null}
+
+ <View
+ style={{
+ width: '100%',
+ height: 30,
+ backgroundColor: colors.nav,
+ borderRadius: 10,
+ marginBottom: 20,
+ padding: 5,
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ alignItems: 'center'
+ }}
+ >
+ <View
+ style={{
+ width: 60,
+ height: 15,
+ backgroundColor: colors.shade,
+ borderRadius: 3
+ }}
+ />
+
+ <View
+ style={{
+ flexDirection: 'row'
+ }}
+ >
+ <View
+ style={{
+ width: 15,
+ height: 15,
+ backgroundColor: colors.transGray,
+ borderRadius: 100,
+ marginRight: 10
+ }}
+ />
+ <View
+ style={{
+ width: 60,
+ height: 15,
+ backgroundColor: colors.transGray,
+ borderRadius: 3
+ }}
+ />
+ </View>
+ </View>
+
+ <View
+ style={{
+ width: 200,
+ height: 16,
+ backgroundColor: colors.nav,
+ borderRadius: 5
+ }}
+ />
+ <View
+ style={{
+ width: '85%',
+ height: 13,
+ backgroundColor: colors.nav,
+ borderRadius: 5,
+ marginTop: 10
+ }}
+ />
+
+ <View
+ style={{
+ flexDirection: 'row',
+ marginTop: 10
+ }}
+ >
+ <View
+ style={{
+ width: 50,
+ height: 10,
+ backgroundColor: colors.nav,
+ borderRadius: 5
+ }}
+ />
+ <View
+ style={{
+ width: 60,
+ height: 10,
+ backgroundColor: colors.nav,
+ borderRadius: 5,
+ marginLeft: 10
+ }}
+ />
+ </View>
+ </View>
+ );
+};
diff --git a/apps/mobile/src/components/delaylayout/index.tsx b/apps/mobile/src/components/delaylayout/index.tsx
new file mode 100644
index 000000000..213db3f0a
--- /dev/null
+++ b/apps/mobile/src/components/delaylayout/index.tsx
@@ -0,0 +1,40 @@
+import React from 'react';
+import { ViewProps } from 'react-native';
+import Animated, { FadeOut } from 'react-native-reanimated';
+import { useThemeStore } from '../../stores/use-theme-store';
+import { useDelayLayout } from '../../utils/hooks/use-delay-layout';
+import { DefaultPlaceholder } from './default-placeholder';
+import { SettingsPlaceholder } from './settings-placeholder';
+
+interface IDelayLayoutProps extends ViewProps {
+ delay?: number;
+ wait?: boolean;
+ type?: 'default' | 'settings';
+}
+
+const placeholder = {
+ default: DefaultPlaceholder,
+ settings: SettingsPlaceholder
+};
+
+export default function DelayLayout(props: IDelayLayoutProps) {
+ const colors = useThemeStore(state => state.colors);
+ const loading = useDelayLayout(props.delay || 300);
+
+ const Placeholder = placeholder[props.type || 'default'];
+
+ return loading || props.wait ? (
+ <Animated.View
+ exiting={FadeOut}
+ style={{
+ backgroundColor: colors.bg,
+ flex: 1,
+ paddingTop: 20
+ }}
+ >
+ <Placeholder />
+ </Animated.View>
+ ) : (
+ <>{props.children}</>
+ );
+}
diff --git a/apps/mobile/src/components/delaylayout/settingsplaceholder.tsx b/apps/mobile/src/components/delaylayout/settingsplaceholder.tsx
new file mode 100644
index 000000000..5c0181de4
--- /dev/null
+++ b/apps/mobile/src/components/delaylayout/settingsplaceholder.tsx
@@ -0,0 +1,127 @@
+import React from 'react';
+import { View } from 'react-native';
+import { useThemeStore } from '../../stores/use-theme-store';
+
+export const SettingsPlaceholder = () => {
+ const colors = useThemeStore(state => state.colors);
+
+ return (
+ <View>
+ <View
+ style={{
+ width: 100,
+ height: 12,
+ backgroundColor: colors.shade,
+ borderRadius: 5,
+ marginLeft: 12,
+ marginBottom: 12
+ }}
+ />
+ <View
+ style={{
+ width: '100%',
+ height: 60,
+ borderRadius: 10,
+ marginBottom: 20,
+ flexDirection: 'row',
+ alignItems: 'center',
+ paddingHorizontal: 16
+ }}
+ >
+ <View
+ style={{
+ width: 40,
+ height: 40,
+ backgroundColor: colors.gray,
+ borderRadius: 100,
+ marginRight: 20
+ }}
+ />
+ <View>
+ <View
+ style={{
+ width: 150,
+ height: 12,
+ backgroundColor: colors.nav,
+ borderRadius: 5,
+ marginBottom: 10
+ }}
+ />
+ <View
+ style={{
+ width: 250,
+ height: 16,
+ backgroundColor: colors.nav,
+ borderRadius: 5
+ }}
+ />
+ </View>
+ </View>
+
+ <View
+ style={{
+ width: '100%',
+ height: 60,
+ borderRadius: 10,
+ marginBottom: 20,
+ flexDirection: 'row',
+ alignItems: 'center',
+ paddingHorizontal: 16,
+ justifyContent: 'space-between'
+ }}
+ >
+ <View
+ style={{
+ width: 40,
+ height: 40,
+ backgroundColor: colors.shade,
+ borderRadius: 100,
+ marginRight: 20
+ }}
+ />
+ <View>
+ <View
+ style={{
+ width: 150,
+ height: 12,
+ backgroundColor: colors.nav,
+ borderRadius: 5,
+ marginBottom: 10
+ }}
+ />
+ <View
+ style={{
+ width: 250,
+ height: 16,
+ backgroundColor: colors.nav,
+ borderRadius: 5
+ }}
+ />
+ </View>
+
+ <View
+ style={{
+ width: 40,
+ height: 20,
+ backgroundColor: colors.nav,
+ borderRadius: 100,
+ marginLeft: 15,
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ paddingHorizontal: 4
+ }}
+ >
+ <View
+ style={{
+ width: 15,
+ height: 15,
+ backgroundColor: colors.shade,
+ borderRadius: 100,
+ marginLeft: 15
+ }}
+ />
+ </View>
+ </View>
+ </View>
+ );
+};
diff --git a/apps/mobile/src/components/listitems/headers/header.js b/apps/mobile/src/components/listitems/headers/header.js
index 9ad6a0a4d..f1f8d6934 100644
--- a/apps/mobile/src/components/listitems/headers/header.js
+++ b/apps/mobile/src/components/listitems/headers/header.js
@@ -38,9 +38,7 @@ export const Header = React.memo(
) : announcements.length !== 0 && !noAnnouncement ? (
<Announcement color={color || colors.accent} />
) : type === 'search' ? null : !shouldShow ? (
- <Animated.View
- entering={FadeInUp.delay(500)}
- exiting={FadeOutUp}
+ <View
style={{
marginBottom: 5,
padding: 0,
@@ -52,7 +50,7 @@ export const Header = React.memo(
{messageCard ? (
<Card color={COLORS_NOTE[color?.toLowerCase()] || colors.accent} />
) : null}
- </Animated.View>
+ </View>
) : null}
</>
);
diff --git a/apps/mobile/src/screens/favorites/index.tsx b/apps/mobile/src/screens/favorites/index.tsx
index b12881e37..d2e52c991 100644
--- a/apps/mobile/src/screens/favorites/index.tsx
+++ b/apps/mobile/src/screens/favorites/index.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import DelayLayout from '../../components/delay-layout';
import List from '../../components/list';
import Navigation, { NavigationProps } from '../../services/navigation';
import SearchService from '../../services/search';
@@ -43,7 +44,7 @@ export const Favorites = ({ navigation, route }: NavigationProps<'Favorites'>) =
});
return (
- <>
+ <DelayLayout wait={loading}>
<List
listData={favorites}
type="notes"
@@ -57,7 +58,7 @@ export const Favorites = ({ navigation, route }: NavigationProps<'Favorites'>) =
heading: 'Favorites'
}}
/>
- </>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/home/index.tsx b/apps/mobile/src/screens/home/index.tsx
index 7c52fa712..1b5dc4a7b 100755
--- a/apps/mobile/src/screens/home/index.tsx
+++ b/apps/mobile/src/screens/home/index.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { FloatingButton } from '../../components/container/floating-button';
+import DelayLayout from '../../components/delay-layout';
import { RightMenus } from '../../components/header/right-menus';
import List from '../../components/list';
import Navigation, { NavigationProps } from '../../services/navigation';
@@ -46,7 +47,7 @@ export const Home = ({ navigation, route }: NavigationProps<'Notes'>) => {
});
return (
- <>
+ <DelayLayout wait={loading} delay={500}>
<List
listData={notes}
type="notes"
@@ -57,10 +58,9 @@ export const Home = ({ navigation, route }: NavigationProps<'Notes'>) => {
}}
placeholderData={PLACEHOLDER_DATA}
/>
- {!notes || notes.length === 0 || !isFocused ? null : (
- <FloatingButton title="Create a new note" onPress={openEditor} />
- )}
- </>
+
+ <FloatingButton title="Create a new note" onPress={openEditor} />
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/notebook/index.tsx b/apps/mobile/src/screens/notebook/index.tsx
index 31c188edb..da5fe20c0 100644
--- a/apps/mobile/src/screens/notebook/index.tsx
+++ b/apps/mobile/src/screens/notebook/index.tsx
@@ -2,6 +2,7 @@ import { groupArray } from 'notes-core/utils/grouping';
import { qclone } from 'qclone';
import React, { useEffect, useRef, useState } from 'react';
import { FloatingButton } from '../../components/container/floating-button';
+import DelayLayout from '../../components/delay-layout';
import List from '../../components/list';
import { NotebookHeader } from '../../components/list-items/headers/notebook-header';
import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
@@ -87,7 +88,7 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
};
return (
- <>
+ <DelayLayout>
<List
listData={topics}
type="topics"
@@ -110,7 +111,7 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
/>
<FloatingButton title="Add new topic" onPress={onPressFloatingButton} />
- </>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/notebooks/index.tsx b/apps/mobile/src/screens/notebooks/index.tsx
index 971471d5c..5c0f96b31 100644
--- a/apps/mobile/src/screens/notebooks/index.tsx
+++ b/apps/mobile/src/screens/notebooks/index.tsx
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react';
import { ContainerHeader } from '../../components/container/containerheader';
import { FloatingButton } from '../../components/container/floating-button';
+import DelayLayout from '../../components/delay-layout';
import { AddNotebookEvent } from '../../components/dialog-provider/recievers';
import { Header } from '../../components/header';
import { RightMenus } from '../../components/header/right-menus';
@@ -63,7 +64,7 @@ export const Notebooks = ({ navigation, route }: NavigationProps<'Notebooks'>) =
}, [notebooks]);
return (
- <>
+ <DelayLayout>
<List
listData={notebooks}
type="notebooks"
@@ -78,7 +79,7 @@ export const Notebooks = ({ navigation, route }: NavigationProps<'Notebooks'>) =
{!notebooks || notebooks.length === 0 || !isFocused ? null : (
<FloatingButton title="Create a new notebook" onPress={onPressFloatingButton} />
)}
- </>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/notes/index.tsx b/apps/mobile/src/screens/notes/index.tsx
index 9a97b6f4c..918dba03e 100644
--- a/apps/mobile/src/screens/notes/index.tsx
+++ b/apps/mobile/src/screens/notes/index.tsx
@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { FloatingButton } from '../../components/container/floating-button';
+import DelayLayout from '../../components/delay-layout';
import { RightMenus } from '../../components/header/right-menus';
import List from '../../components/list';
import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
@@ -55,7 +56,7 @@ const NotesPage = ({
get,
placeholderData,
onPressFloatingButton,
- focusControl,
+ focusControl = true,
canGoBack,
rightButtons
}: RouteProps<'NotesPage' | 'TaggedNotes' | 'Monographs' | 'ColoredNotes' | 'TopicNotes'>) => {
@@ -63,6 +64,7 @@ const NotesPage = ({
const [notes, setNotes] = useState<NoteType[]>(get(route.params, true));
const [warning, setWarning] = useState(!isSynced(route.params));
const loading = useNoteStore(state => state.loading);
+ const [loadingNotes, setLoadingNotes] = useState(false);
const alias = getAlias(params.current);
const isMonograph = route.name === 'Monographs';
console.log(warning, 'isWarning', isSynced(route.params));
@@ -108,9 +110,11 @@ const NotesPage = ({
const onRequestUpdate = (data?: NotesScreenParams) => {
if (data) params.current = data;
+ const isNew = data?.item?.id !== params.current?.item?.id;
params.current.title = params.current.title || params.current.item.title;
const { item } = params.current;
try {
+ if (isNew) setLoadingNotes(true);
let notes = get(params.current, true) as NoteType[];
if ((item.type === 'tag' || item.type === 'color') && (!notes || notes.length === 0)) {
return Navigation.goBack();
@@ -121,6 +125,10 @@ const NotesPage = ({
} catch (e) {}
};
+ useEffect(() => {
+ if (loadingNotes) setLoadingNotes(false);
+ }, [notes]);
+
useEffect(() => {
eSubscribeEvent(route.name, onRequestUpdate);
return () => {
@@ -141,7 +149,7 @@ const NotesPage = ({
};
return (
- <>
+ <DelayLayout wait={loading || loadingNotes}>
<List
listData={notes}
warning={warning ? WARNING_DATA : null}
@@ -160,7 +168,7 @@ const NotesPage = ({
{notes?.length > 0 || isFocused ? (
<FloatingButton title="Create a note" onPress={onPressFloatingButton} />
) : null}
- </>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/search/index.js b/apps/mobile/src/screens/search/index.js
index a2da384bf..a3fc194ab 100644
--- a/apps/mobile/src/screens/search/index.js
+++ b/apps/mobile/src/screens/search/index.js
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import { ContainerHeader } from '../../components/container/containerheader';
+import DelayLayout from '../../components/delay-layout';
import List from '../../components/list';
import SearchService from '../../services/search';
import useNavigationStore from '../../stores/use-navigation-store';
@@ -7,7 +7,6 @@ import { useSearchStore } from '../../stores/use-search-store';
import { inputRef } from '../../utils/global-refs';
import { useNavigationFocus } from '../../utils/hooks/use-navigation-focus';
import { sleep } from '../../utils/time';
-import { SearchBar } from './search-bar';
export const Search = ({ navigation, route }) => {
const searchResults = useSearchStore(state => state.searchResults);
@@ -35,7 +34,7 @@ export const Search = ({ navigation, route }) => {
}, []);
return (
- <>
+ <DelayLayout wait={searching}>
<List
listData={searchResults}
type="search"
@@ -54,6 +53,6 @@ export const Search = ({ navigation, route }) => {
loading: 'Searching...'
}}
/>
- </>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/settings/group.tsx b/apps/mobile/src/screens/settings/group.tsx
index c74cec23b..8ba54c204 100644
--- a/apps/mobile/src/screens/settings/group.tsx
+++ b/apps/mobile/src/screens/settings/group.tsx
@@ -1,49 +1,16 @@
import { NativeStackScreenProps } from '@react-navigation/native-stack';
-import React, { useEffect, useState } from 'react';
-import { ActivityIndicator, FlatList, View } from 'react-native';
-import Animated, { FadeIn, FadeInDown, Layout, ZoomIn } from 'react-native-reanimated';
-import { Empty } from '../../components/list/empty';
+import React, { useEffect } from 'react';
+import { FlatList, View } from 'react-native';
+import DelayLayout from '../../components/delay-layout';
import useNavigationStore from '../../stores/use-navigation-store';
-import { useThemeStore } from '../../stores/use-theme-store';
import { tabBarRef } from '../../utils/global-refs';
import { useNavigationFocus } from '../../utils/hooks/use-navigation-focus';
import { SectionItem } from './section-item';
import { RouteParams, SettingSection } from './types';
-const useDelayLayout = (delay: number) => {
- const [loading, setLoading] = useState(true);
-
- useEffect(() => {
- let timeout = setTimeout(() => {
- setLoading(false);
- }, delay);
- return () => {
- clearTimeout(timeout);
- };
- }, []);
-
- return loading;
-};
-
-const Loading = () => {
- const colors = useThemeStore(state => state.colors.accent);
-
- return (
- <Empty
- placeholderData={{
- paragraph: 'Personalize Notesnook the way you wish to.',
- heading: 'Minimal & meaningful',
- loading: 'Personalize Notesnook the way you wish to.'
- }}
- headerProps={{
- color: 'accent'
- }}
- />
- );
-};
+const keyExtractor = (item: SettingSection, index: number) => item.id;
const Group = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'SettingsGroup'>) => {
- const loading = useDelayLayout(300);
useNavigationFocus(navigation, {
onFocus: () => {
tabBarRef.current?.lock();
@@ -68,20 +35,18 @@ const Group = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'Setti
<SectionItem item={item} />
);
- return loading ? (
- <Loading />
- ) : (
- <View>
- {route.params.sections ? (
- <Animated.View entering={FadeInDown}>
+ return (
+ <DelayLayout>
+ <View>
+ {route.params.sections ? (
<FlatList
data={route.params.sections}
- keyExtractor={(item, index) => item.name || index.toString()}
+ keyExtractor={keyExtractor}
renderItem={renderItem}
/>
- </Animated.View>
- ) : null}
- </View>
+ ) : null}
+ </View>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/settings/home.tsx b/apps/mobile/src/screens/settings/home.tsx
index 68849b599..f56ab690b 100644
--- a/apps/mobile/src/screens/settings/home.tsx
+++ b/apps/mobile/src/screens/settings/home.tsx
@@ -2,9 +2,8 @@ import { NativeStackScreenProps } from '@react-navigation/native-stack';
import React, { useEffect, useRef, useState } from 'react';
import { FlatList, View } from 'react-native';
import { Bar } from 'react-native-progress';
-import { ContainerHeader } from '../../components/container/containerheader';
+import DelayLayout from '../../components/delay-layout';
import BaseDialog from '../../components/dialog/base-dialog';
-import { Header } from '../../components/header';
import Heading from '../../components/ui/typography/heading';
import Paragraph from '../../components/ui/typography/paragraph';
import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
@@ -17,6 +16,8 @@ import { settingsGroups } from './settings-data';
import { RouteParams, SettingSection } from './types';
import SettingsUserSection from './user-section';
+const keyExtractor = (item: SettingSection, index: number) => item.id;
+
const Home = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'SettingsHome'>) => {
const colors = useThemeStore(state => state.colors);
const [loading, setLoading] = useState(false);
@@ -26,15 +27,16 @@ const Home = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'Settin
useNavigationStore.getState().update({
name: 'Settings'
});
- return true;
+ return false;
},
onBlur: () => {
flatlistRef.current?.scrollToOffset({
offset: 0,
animated: false
});
- return navigation.getState().index === 0;
- }
+ return false;
+ },
+ focusOnInit: true
});
const renderItem = ({ item, index }: { item: SettingSection; index: number }) =>
@@ -48,59 +50,58 @@ const Home = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'Settin
}, []);
return (
- <View>
- {loading && (
- <BaseDialog animated={false} bounce={false} visible={true}>
- <View
- style={{
- width: '100%',
- height: '100%',
- backgroundColor: colors.bg,
- justifyContent: 'center',
- alignItems: 'center'
- }}
- >
- <Heading color={colors.pri} size={SIZE.lg}>
- Logging out
- </Heading>
- <Paragraph color={colors.icon}>
- Please wait while we log out and clear app data.
- </Paragraph>
+ <DelayLayout type="settings">
+ <View>
+ {loading && (
+ //@ts-ignore
+ <BaseDialog animated={false} bounce={false} visible={true}>
<View
style={{
- flexDirection: 'row',
- width: 100,
- marginTop: 15
+ width: '100%',
+ height: '100%',
+ backgroundColor: colors.bg,
+ justifyContent: 'center',
+ alignItems: 'center'
}}
>
- <Bar
- height={5}
- width={100}
- animated={true}
- useNativeDriver
- indeterminate
- indeterminateAnimationDuration={2000}
- unfilledColor={colors.nav}
- color={colors.accent}
- borderWidth={0}
- />
+ <Heading color={colors.pri} size={SIZE.lg}>
+ Logging out
+ </Heading>
+ <Paragraph color={colors.icon}>
+ Please wait while we log out and clear app data.
+ </Paragraph>
+ <View
+ style={{
+ flexDirection: 'row',
+ width: 100,
+ marginTop: 15
+ }}
+ >
+ <Bar
+ height={5}
+ width={100}
+ animated={true}
+ useNativeDriver
+ indeterminate
+ indeterminateAnimationDuration={2000}
+ unfilledColor={colors.nav}
+ color={colors.accent}
+ borderWidth={0}
+ />
+ </View>
</View>
- </View>
- </BaseDialog>
- )}
+ </BaseDialog>
+ )}
- <FlatList
- data={isFocused ? settingsGroups : settingsGroups.slice(0, 3)}
- ref={flatlistRef}
- keyExtractor={(item, index) =>
- typeof item.name === 'function'
- ? item.name({}) || index.toString()
- : item.name || index.toString()
- }
- ListFooterComponent={<View style={{ height: 200 }} />}
- renderItem={renderItem}
- />
- </View>
+ <FlatList
+ data={settingsGroups}
+ ref={flatlistRef}
+ keyExtractor={keyExtractor}
+ ListFooterComponent={<View style={{ height: 200 }} />}
+ renderItem={renderItem}
+ />
+ </View>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/settings/settingsdata.tsx b/apps/mobile/src/screens/settings/settingsdata.tsx
index 5cb1ec35b..b8c30cd30 100644
--- a/apps/mobile/src/screens/settings/settingsdata.tsx
+++ b/apps/mobile/src/screens/settings/settingsdata.tsx
@@ -51,11 +51,13 @@ const format = (ver: number) => {
export const settingsGroups: SettingSection[] = [
{
+ id: 'account',
name: 'account',
useHook: () => useUserStore(state => state.user),
hidden: current => !current,
sections: [
{
+ id: 'subscription-status',
useHook: () => useUserStore(state => state.user),
hidden: current => !current,
name: current => {
@@ -93,12 +95,14 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'account-settings',
type: 'screen',
name: 'Account Settings',
icon: 'account-cog',
description: 'Manage account',
sections: [
{
+ id: 'recovery-key',
name: 'Save data recovery key',
modifer: async () => {
verifyUser(null, async () => {
@@ -109,6 +113,7 @@ export const settingsGroups: SettingSection[] = [
description: 'Recover your data using the recovery key if your password is lost.'
},
{
+ id: 'manage-attachments',
name: 'Manage attachments',
icon: 'attachment',
modifer: () => {
@@ -117,6 +122,7 @@ export const settingsGroups: SettingSection[] = [
description: 'Manage all attachments in one place.'
},
{
+ id: 'change-password',
name: 'Change password',
modifer: async () => {
ChangePassword.present();
@@ -124,12 +130,14 @@ export const settingsGroups: SettingSection[] = [
description: 'Setup a new password for your account.'
},
{
+ id: '2fa-settings',
type: 'screen',
name: 'Two factor authentication',
description: 'Manage 2FA settings',
icon: 'two-factor-authentication',
sections: [
{
+ id: 'enable-2fa',
name: 'Enable two-factor authentication',
modifer: () => {
verifyUser('global', async () => {
@@ -143,6 +151,7 @@ export const settingsGroups: SettingSection[] = [
description: 'Increased security for your account'
},
{
+ id: '2fa-fallback',
name: 'Add fallback 2FA method',
useHook: () => useUserStore(state => state.user),
hidden: user => {
@@ -157,6 +166,7 @@ export const settingsGroups: SettingSection[] = [
'You can use fallback 2FA method incase you are unable to login via primary method'
},
{
+ id: 'change-2fa-method',
name: 'Reconfigure fallback 2FA method',
useHook: () => useUserStore(state => state.user),
hidden: user => {
@@ -171,6 +181,7 @@ export const settingsGroups: SettingSection[] = [
'You can use fallback 2FA method incase you are unable to login via primary method'
},
{
+ id: 'view-2fa-codes',
name: 'View recovery codes',
modifer: () => {
verifyUser('global', async () => {
@@ -184,6 +195,7 @@ export const settingsGroups: SettingSection[] = [
description: 'View and save recovery codes for to recover your account'
},
{
+ id: 'disabled-2fa',
name: 'Disable two-factor authentication',
modifer: () => {
verifyUser('global', async () => {
@@ -202,6 +214,7 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'subscription-not-active',
name: 'Subscription not activated?',
hidden: () => Platform.OS !== 'ios',
modifer: async () => {
@@ -233,6 +246,7 @@ export const settingsGroups: SettingSection[] = [
description: 'Verify your subscription to Notesnook Pro'
},
{
+ id: 'logout',
name: 'Log out',
description: 'Clear all your data and reset the app.',
icon: 'logout',
@@ -273,6 +287,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'delete-account',
type: 'danger',
name: 'Delete account',
icon: 'alert',
@@ -319,6 +334,7 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'sync-issues-fix',
name: 'Having problems with sync',
description: 'Try force sync to resolve issues with syncing',
icon: 'sync-alert',
@@ -331,21 +347,25 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'customize',
name: 'Customize',
sections: [
{
+ id: 'personalization',
type: 'screen',
name: 'Theme',
description: 'Change app look and feel',
icon: 'shape',
sections: [
{
+ id: 'accent-color-picker',
type: 'component',
name: 'Accent color',
description: 'Pick the color that matches your mood',
component: 'colorpicker'
},
{
+ id: 'use-system-theme',
type: 'switch',
name: 'Use system theme',
description: 'Automatically switch to dark mode when system theme changes',
@@ -353,6 +373,7 @@ export const settingsGroups: SettingSection[] = [
icon: 'circle-half'
},
{
+ id: 'enable-dark-mode',
type: 'switch',
name: 'Dark mode',
description: 'Strain your eyes no more at night',
@@ -364,6 +385,7 @@ export const settingsGroups: SettingSection[] = [
getter: () => useSettingStore.getState().settings.theme.dark
},
{
+ id: 'pitch-black',
type: 'switch',
name: 'Pitch black',
description: 'Save battery on device with amoled screen at night.',
@@ -379,11 +401,13 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'behaviour',
type: 'screen',
name: 'Behaviour',
description: 'Change app homepage',
sections: [
{
+ id: 'default-home',
type: 'component',
name: 'Homepage',
description: 'Default screen to open on app startup',
@@ -394,9 +418,11 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'privacy-security',
name: 'Privacy and security',
sections: [
{
+ id: 'temeltery',
type: 'switch',
name: 'Telemetry',
icon: 'radar',
@@ -405,12 +431,14 @@ export const settingsGroups: SettingSection[] = [
property: 'telemetry'
},
{
+ id: 'vault',
type: 'screen',
name: 'Vault',
description: 'Multi-layer encryption to most important notes',
icon: 'key',
sections: [
{
+ id: 'create-vault',
name: 'Create vault',
description: 'Set a password to create vault and lock notes.',
icon: 'key',
@@ -428,6 +456,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'change-vault-password',
useHook: useVaultStatus,
name: 'Change vault password',
description: 'Setup a new password for your vault.',
@@ -442,6 +471,7 @@ export const settingsGroups: SettingSection[] = [
})
},
{
+ id: 'clear-vault',
useHook: useVaultStatus,
name: 'Clear vault',
description: 'Unlock all locked notes',
@@ -457,6 +487,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'delete-vault',
name: 'Delete vault',
description: 'Delete vault (and optionally remove all notes).',
useHook: useVaultStatus,
@@ -472,6 +503,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'biometic-unlock',
type: 'switch',
name: 'Biometric unlocking',
icon: 'fingerprint',
@@ -497,6 +529,7 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'privacy-mode',
type: 'switch',
icon: 'eye-off-outline',
name: 'Privacy mode',
@@ -512,6 +545,7 @@ export const settingsGroups: SettingSection[] = [
property: 'privacyScreen'
},
{
+ id: 'app-lock',
name: 'App lock',
description: 'Change app lock mode to suit your needs',
icon: 'fingerprint',
@@ -522,15 +556,18 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'back-restore',
name: 'Backup and restore',
sections: [
{
+ id: 'backups',
type: 'screen',
name: 'Backups',
icon: 'backup-restore',
description: 'Create a backup or change backup settings',
sections: [
{
+ id: 'backup-now',
name: 'Backup now',
description: 'Create a backup of your data',
modifer: async () => {
@@ -543,12 +580,14 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'auto-backups',
type: 'component',
name: 'Automatic backups',
description: 'Backup your data once every week or daily automatically.',
component: 'autobackups'
},
{
+ id: 'select-backup-dir',
name: 'Select backup directory',
description: 'Select directory to store backups',
icon: 'folder',
@@ -571,6 +610,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'change-backup-dir',
name: 'Change backup directory',
description: () => SettingsService.get().backupDirectoryAndroid?.name || '',
icon: 'folder',
@@ -593,6 +633,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'enable-backup-encryption',
type: 'switch',
name: 'Backup encryption',
description: 'Encrypt all your backups.',
@@ -618,6 +659,7 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'restore-backup',
name: 'Restore backup',
description: `Restore backup from phone storage.`,
modifer: () => {
@@ -637,10 +679,12 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'productivity',
name: 'Productivity',
hidden: () => Platform.OS !== 'android',
sections: [
{
+ id: 'notification-notes',
type: 'switch',
name: 'Notes in notifications',
description: `Add quick notes from notifications without opening the app.`,
@@ -659,9 +703,11 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'help-support',
name: 'Help and support',
sections: [
{
+ id: 'report-issue',
name: 'Report an issue',
icon: 'bug',
modifer: () => {
@@ -672,6 +718,7 @@ export const settingsGroups: SettingSection[] = [
description: 'Faced an issue or have a suggestion? Click here to create a bug report'
},
{
+ id: 'docs-link',
name: 'Documentation',
modifer: async () => {
Linking.openURL('https://docs.notesnook.com');
@@ -680,6 +727,7 @@ export const settingsGroups: SettingSection[] = [
icon: 'file-document'
},
{
+ id: 'debug-mode',
type: 'switch',
name: 'Debug mode',
description: 'Show debug options on items',
@@ -688,9 +736,11 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'community',
name: 'community',
sections: [
{
+ id: 'join-telegram',
name: 'Join our Telegram group',
description: "We are on telegram, let's talk",
icon: 'telegram',
@@ -699,6 +749,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'join-discord',
name: 'Join our Discord community',
icon: 'discord',
modifer: async () => {
@@ -727,9 +778,11 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'legal',
name: 'legal',
sections: [
{
+ id: 'tos',
name: 'Terms of service',
modifer: async () => {
try {
@@ -739,6 +792,7 @@ export const settingsGroups: SettingSection[] = [
description: 'Read our terms of service'
},
{
+ id: 'privacy-policy',
name: 'Privacy policy',
modifer: async () => {
try {
@@ -750,9 +804,11 @@ export const settingsGroups: SettingSection[] = [
]
},
{
+ id: 'about',
name: 'about',
sections: [
{
+ id: 'download',
name: 'Download on desktop',
icon: 'monitor',
modifer: async () => {
@@ -763,6 +819,7 @@ export const settingsGroups: SettingSection[] = [
description: 'Get Notesnook app on your desktop and access all notes'
},
{
+ id: 'roadmap',
name: 'Roadmap',
icon: 'chart-timeline',
modifer: async () => {
@@ -773,6 +830,7 @@ export const settingsGroups: SettingSection[] = [
description: 'See what the future of Notesnook is going to be like.'
},
{
+ id: 'check-for-updates',
name: 'Check for updates',
icon: 'cellphone-arrow-down',
description: 'Check for new version of Notesnook',
@@ -792,6 +850,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
+ id: 'app-version',
name: 'App version',
icon: 'alpha-v',
modifer: async () => {
diff --git a/apps/mobile/src/screens/settings/types.ts b/apps/mobile/src/screens/settings/types.ts
index dda2da80b..8da3d30d2 100644
--- a/apps/mobile/src/screens/settings/types.ts
+++ b/apps/mobile/src/screens/settings/types.ts
@@ -1,8 +1,9 @@
import { Settings } from '../../stores/interfaces';
export type SettingSection = {
+ id: string;
type?: 'screen' | 'switch' | 'component' | 'danger';
- name?: string | ((current: any) => string);
+ name?: string | ((current?: any) => string);
description?: string | ((current: any) => string);
icon?: string;
property?: keyof Settings;
diff --git a/apps/mobile/src/screens/tags/index.tsx b/apps/mobile/src/screens/tags/index.tsx
index eb93fe039..c66aaff44 100644
--- a/apps/mobile/src/screens/tags/index.tsx
+++ b/apps/mobile/src/screens/tags/index.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import DelayLayout from '../../components/delay-layout';
import List from '../../components/list';
import Navigation, { NavigationProps } from '../../services/navigation';
import SearchService from '../../services/search';
@@ -41,7 +42,7 @@ export const Tags = ({ navigation, route }: NavigationProps<'Tags'>) => {
});
return (
- <>
+ <DelayLayout>
<List
listData={tags}
type="tags"
@@ -52,7 +53,7 @@ export const Tags = ({ navigation, route }: NavigationProps<'Tags'>) => {
screen="Tags"
placeholderData={PLACEHOLDER_DATA}
/>
- </>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/screens/trash/index.tsx b/apps/mobile/src/screens/trash/index.tsx
index 694864d82..f7c158ab9 100644
--- a/apps/mobile/src/screens/trash/index.tsx
+++ b/apps/mobile/src/screens/trash/index.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { FloatingButton } from '../../components/container/floating-button';
+import DelayLayout from '../../components/delay-layout';
import { presentDialog } from '../../components/dialog/functions';
import List from '../../components/list';
import { ToastEvent } from '../../services/event-manager';
@@ -61,14 +62,13 @@ export const Trash = ({ navigation, route }: NavigationProps<'Trash'>) => {
useTrashStore.getState().setTrash();
}
SearchService.prepareSearch = prepareSearch;
- return !prev?.current;
+ return false;
},
- onBlur: () => false,
- delay: SettingsService.get().homepage === route.name ? 1 : -1
+ onBlur: () => false
});
return (
- <>
+ <DelayLayout>
<List
listData={trash}
type="trash"
@@ -83,7 +83,7 @@ export const Trash = ({ navigation, route }: NavigationProps<'Trash'>) => {
{trash && trash.length !== 0 ? (
<FloatingButton title="Clear all trash" onPress={onPressFloatingButton} shouldShow={true} />
) : null}
- </>
+ </DelayLayout>
);
};
diff --git a/apps/mobile/src/services/navigation.ts b/apps/mobile/src/services/navigation.ts
index bb9049e1b..bc5ffed4a 100755
--- a/apps/mobile/src/services/navigation.ts
+++ b/apps/mobile/src/services/navigation.ts
@@ -1,5 +1,6 @@
import { BottomTabScreenProps } from '@react-navigation/bottom-tabs';
import { StackActions } from '@react-navigation/native';
+import { NativeStackScreenProps } from '@react-navigation/native-stack';
import { useFavoriteStore } from '../stores/use-favorite-store';
import useNavigationStore, { CurrentScreen, Route, RouteName } from '../stores/use-navigation-store';
import { useNotebookStore } from '../stores/use-notebook-store';
@@ -63,7 +64,7 @@ export type RouteParams = {
Monographs: NotesScreenParams;
};
-export type NavigationProps<T extends RouteName> = BottomTabScreenProps<RouteParams, T>;
+export type NavigationProps<T extends RouteName> = NativeStackScreenProps<RouteParams, T>;
/**
* Functions to update each route when required.
@@ -96,6 +97,7 @@ function routeNeedsUpdate(routeName: Route, callback: () => void) {
console.log('routeName', routesUpdateQueue);
if (routesUpdateQueue.indexOf(routeName) > -1) {
clearRouteFromQueue(routeName);
+ console.log('CALL ROUTE UPDATE');
callback();
}
}
@@ -126,7 +128,8 @@ function queueRoutesForUpdate(...routes: Route[]) {
function navigate<T extends RouteName>(screen: CurrentScreen, params: RouteParams[T]) {
useNavigationStore.getState().update(screen, params?.canGoBack);
if (screen.name === 'Notebook') routeUpdateFunctions['Notebook'](params);
- if (screen.name.endsWith('Notes')) routeUpdateFunctions[screen.name](params);
+ if (screen.name.endsWith('Notes') && screen.name !== 'Notes')
+ routeUpdateFunctions[screen.name](params);
//@ts-ignore
rootNavigatorRef.current?.navigate(screen.name, params);
}
diff --git a/apps/mobile/src/utils/hooks/useDelayLayout.ts b/apps/mobile/src/utils/hooks/useDelayLayout.ts
new file mode 100644
index 000000000..d9eec5d7c
--- /dev/null
+++ b/apps/mobile/src/utils/hooks/useDelayLayout.ts
@@ -0,0 +1,16 @@
+import { useEffect, useState } from 'react';
+
+export const useDelayLayout = (delay: number) => {
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ let timeout = setTimeout(() => {
+ setLoading(false);
+ }, delay);
+ return () => {
+ clearTimeout(timeout);
+ };
+ }, [delay]);
+
+ return loading;
+};
diff --git a/apps/mobile/src/utils/hooks/useNavigationFocus.ts b/apps/mobile/src/utils/hooks/useNavigationFocus.ts
index 6a5333f41..d129d3c03 100644
--- a/apps/mobile/src/utils/hooks/useNavigationFocus.ts
+++ b/apps/mobile/src/utils/hooks/useNavigationFocus.ts
@@ -1,7 +1,5 @@
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
-import { RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import SettingsService from '../../services/settings';
-import useNavigationStore from '../../stores/use-navigation-store';
+import { RefObject, useCallback, useEffect, useRef, useState } from 'react';
type NavigationFocus = {
onFocus?: (prev: RefObject<boolean>) => boolean;
@@ -12,7 +10,7 @@ type NavigationFocus = {
export const useNavigationFocus = (
navigation: NativeStackNavigationProp<any>,
- { onFocus, onBlur, delay, focusOnInit }: NavigationFocus
+ { onFocus, onBlur, delay, focusOnInit = true }: NavigationFocus
) => {
const [isFocused, setFocused] = useState(focusOnInit);
const prev = useRef(false);