Skip to content

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

add a new Search View

ammarahm-ed771d67969b15
diff --git a/apps/mobile/src/views/Search/index.js b/apps/mobile/src/views/Search/index.js
new file mode 100644
index 000000000..bd04fbbf8
--- /dev/null
+++ b/apps/mobile/src/views/Search/index.js
@@ -0,0 +1,51 @@
+import React, { useCallback, useEffect } from 'react';
+import SimpleList from '../../components/SimpleList';
+import { useTracked } from '../../provider';
+import { Actions } from '../../provider/Actions';
+import { inputRef } from '../../utils/Refs';
+import { sleep } from '../../utils/TimeUtils';
+
+export const Search = ({route, navigation}) => {
+ const [state, dispatch] = useTracked();
+ const {colors, searchResults} = state;
+
+ const onFocus = useCallback(() => {
+ dispatch({
+ type: Actions.CURRENT_SCREEN,
+ screen: 'search',
+ });
+
+ dispatch({
+ type: Actions.HEADER_STATE,
+ state: false,
+ });
+
+
+ sleep(300).then(() => inputRef.current?.focus());
+ }, []);
+
+ useEffect(() => {
+ navigation.addListener('focus', onFocus);
+ return () => {
+ navigation.removeListener('focus', onFocus);
+ };
+ });
+
+ return (
+ <>
+ <SimpleList
+ data={searchResults}
+ type="search"
+ focused={() => navigation.isFocused()}
+ placeholderText={`Notes you write appear here`}
+ jumpToDialog={true}
+ CustomHeader={true}
+ placeholderData={{
+ heading: 'Search',
+ paragraph: 'Type a keyword to search in notes.',
+ button: null,
+ }}
+ />
+ </>
+ );
+};