Skip to content

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

refactor

ammarahm-ed6fd462ad139d
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 9eb06b338..19c367130 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -2,18 +2,17 @@ import React, { useEffect } from 'react';
import Orientation from 'react-native-orientation';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import Launcher from './src/components/launcher';
-import { useTracked } from './src/provider';
-import { initialize, useSettingStore, useUserStore } from './src/provider/stores';
-import { DDS } from './src/services/DeviceDetection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from './src/services/EventManager';
-import Notifications from './src/services/Notifications';
-import SettingsService from './src/services/SettingsService';
+import { ApplicationHolder } from './src/navigation';
+import { useThemeStore } from './src/stores/theme';
+import { initialize, useSettingStore, useUserStore } from './src/stores/stores';
+import { DDS } from './src/services/device-detection';
+import { eSendEvent } from './src/services/event-manager';
+import Notifications from './src/services/notifications';
+import SettingsService from './src/services/settings';
import { TipManager } from './src/services/tip-manager';
import { db } from './src/utils/database';
-import { eDispatchAction } from './src/utils/events';
-import { useAppEvents } from './src/utils/hooks/use-app-events';
import { MMKV } from './src/utils/database/mmkv';
-import { ApplicationHolder } from './src/navigation';
+import { useAppEvents } from './src/utils/hooks/use-app-events';
let databaseHasLoaded = false;
@@ -55,14 +54,12 @@ function checkOrientation() {
const loadMainApp = () => {
if (databaseHasLoaded) {
- SettingsService.setAppLoaded();
eSendEvent('load_overlay');
initialize();
}
};
checkOrientation();
const App = () => {
- const [, dispatch] = useTracked();
const setVerifyUser = useUserStore(state => state.setVerifyUser);
const appEvents = useAppEvents();
@@ -85,17 +82,6 @@ const App = () => {
})();
}, []);
- const _dispatch = data => {
- dispatch(data);
- };
-
- useEffect(() => {
- eSubscribeEvent(eDispatchAction, _dispatch);
- return () => {
- eUnSubscribeEvent(eDispatchAction, _dispatch);
- };
- }, []);
-
return (
<SafeAreaProvider>
<ApplicationHolder />
diff --git a/apps/mobile/index.js b/apps/mobile/index.js
index 063845d2b..813832779 100644
--- a/apps/mobile/index.js
+++ b/apps/mobile/index.js
@@ -1,10 +1,10 @@
import React from 'react';
-import { AppRegistry, LayoutAnimation, LogBox, Platform, UIManager } from 'react-native';
+import { AppRegistry, LogBox, Platform, UIManager } from 'react-native';
import 'react-native-gesture-handler';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { enableScreens } from 'react-native-screens';
import { name as appName } from './app.json';
-import Notifications from './src/services/Notifications';
+import Notifications from './src/services/notifications';
global.Buffer = require('buffer').Buffer;
enableScreens(true);
UIManager.setLayoutAnimationEnabledExperimental &&
@@ -14,20 +14,14 @@ if (__DEV__) {
LogBox.ignoreAllLogs();
}
-let Provider;
let App;
let NotesnookShare;
Notifications.init();
let QuickNoteIOS;
const AppProvider = () => {
- Provider = require('./src/provider').Provider;
App = require('./App').default;
- return (
- <Provider>
- <App />
- </Provider>
- );
+ return <App />;
};
AppRegistry.registerComponent(appName, () => AppProvider);
diff --git a/apps/mobile/releasenotes.md b/apps/mobile/releasenotes.md
new file mode 100644
index 000000000..9701907f1
--- /dev/null
+++ b/apps/mobile/releasenotes.md
@@ -0,0 +1,24 @@
+- Add new "Move notes" button in topic properties to quickly move notes to a topic
+- Overhauled Auth flows with new UI/UX
+- Overhauled App lock UI
+- Added new placeholders with useful tips about app features
+- Added Auto search on typing in Search/Replace
+- Added new walkthrough for notesnooks for new users
+- Added read only mode for notes
+- Added walkthroughs for pro/trial users
+- Allow to opt-out of getting "Backup completed" dialogs on app launch when automatic backups are turned on
+- Disable swipe gestures when selecting multiple notes
+- Fixed Search/Replace does not accept spaces
+- Fixed inline markdown transforms not working
+- Fixed tags in editor hide/flicker on opening a note
+- Fixed Home screen widget not launching on Android 12
+- Fixed codeblocks are not scrollable in editor
+- Fixed collapsing/expanding a heading causes cursor to jump on iOS
+- Do not show title in notification pinned note
+- Do not lock app if requesting fingerprint unlock for vault
+- Reuse backup folder if it exists in subfolders of selected directory on android
+- Fixed app hangs and becomes unusable on some phones
+- Improved web clipper in widget to handle tables & codeblocks and remove invalid elements
+- Disable swipe to close gesture in editor as it interferes with editing or scrolling.
+
+Thank you for using Notesnook!
\ No newline at end of file
diff --git a/apps/mobile/share/index.js b/apps/mobile/share/index.js
index a7d86a336..14f63a606 100644
--- a/apps/mobile/share/index.js
+++ b/apps/mobile/share/index.js
@@ -25,7 +25,7 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import WebView from 'react-native-webview';
import ShareExtension from 'rn-extensions-share';
import isURL from 'validator/lib/isURL';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../src/services/EventManager';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../src/services/event-manager';
import { getElevation } from '../src/utils';
import { db } from '../src/utils/database';
import Storage from '../src/utils/database/storage';
diff --git a/apps/mobile/src/components/announcements/announcement.js b/apps/mobile/src/components/announcements/announcement.js
index 29a2c408e..c06e278a7 100644
--- a/apps/mobile/src/components/announcements/announcement.js
+++ b/apps/mobile/src/components/announcements/announcement.js
@@ -1,13 +1,12 @@
import React from 'react';
import { FlatList, View } from 'react-native';
-import { useTracked } from '../../provider';
-import { useMessageStore, useSelectionStore } from '../../provider/stores';
+import { useThemeStore } from '../../stores/theme';
+import { useMessageStore, useSelectionStore } from '../../stores/stores';
import { Button } from '../ui/button';
import { allowedOnPlatform, renderItem } from './functions';
export const Announcement = ({ color }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const announcements = useMessageStore(state => state.announcements);
const remove = useMessageStore(state => state.remove);
let announcement = announcements.length > 0 ? announcements[0] : null;
diff --git a/apps/mobile/src/components/announcements/body.js b/apps/mobile/src/components/announcements/body.js
index ea2a4b1e0..0b0ac6896 100644
--- a/apps/mobile/src/components/announcements/body.js
+++ b/apps/mobile/src/components/announcements/body.js
@@ -1,11 +1,10 @@
import React from 'react';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import Paragraph from '../ui/typography/paragraph';
import { getStyle } from './functions';
export const Body = ({ text, style = {} }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<Paragraph
diff --git a/apps/mobile/src/components/announcements/cta.js b/apps/mobile/src/components/announcements/cta.js
index 99a72c1db..dc57ddd07 100644
--- a/apps/mobile/src/components/announcements/cta.js
+++ b/apps/mobile/src/components/announcements/cta.js
@@ -1,7 +1,7 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSendEvent, presentSheet } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, presentSheet } from '../../services/event-manager';
import { eCloseAnnouncementDialog } from '../../utils/events';
import { openLinkInBrowser } from '../../utils/functions';
import { SIZE } from '../../utils/size';
@@ -13,8 +13,7 @@ import { PricingPlans } from '../premium/pricing-plans';
import { allowedOnPlatform, getStyle } from './functions';
export const Cta = ({ actions, style = {}, color, inline }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
let buttons = actions.filter(item => allowedOnPlatform(item.platforms)) || [];
const onPress = async item => {
diff --git a/apps/mobile/src/components/announcements/description.js b/apps/mobile/src/components/announcements/description.js
index 070375d2f..c1b808285 100644
--- a/apps/mobile/src/components/announcements/description.js
+++ b/apps/mobile/src/components/announcements/description.js
@@ -1,12 +1,11 @@
import React from 'react';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import Paragraph from '../ui/typography/paragraph';
import { getStyle } from './functions';
export const Description = ({ text, style = {} }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<Paragraph
size={SIZE.md}
diff --git a/apps/mobile/src/components/announcements/functions.js b/apps/mobile/src/components/announcements/functions.js
index 46787979f..e549c6c2e 100644
--- a/apps/mobile/src/components/announcements/functions.js
+++ b/apps/mobile/src/components/announcements/functions.js
@@ -1,6 +1,6 @@
import React, { Fragment } from 'react';
import { View } from 'react-native';
-import { allowedPlatforms } from '../../provider/stores';
+import { allowedPlatforms } from '../../stores/stores';
import { ProFeatures } from '../dialogs/result/pro-features';
import { Body } from './body';
import { Cta } from './cta';
diff --git a/apps/mobile/src/components/announcements/index.js b/apps/mobile/src/components/announcements/index.js
index e482a6bde..a14ec26b1 100644
--- a/apps/mobile/src/components/announcements/index.js
+++ b/apps/mobile/src/components/announcements/index.js
@@ -1,16 +1,15 @@
import React, { useEffect, useState } from 'react';
import { FlatList, View } from 'react-native';
-import { useTracked } from '../../provider';
-import { useMessageStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { useMessageStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { eCloseAnnouncementDialog, eOpenAnnouncementDialog } from '../../utils/events';
import BaseDialog from '../dialog/base-dialog';
import { allowedOnPlatform, renderItem } from './functions';
export const AnnouncementDialog = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [info, setInfo] = useState(null);
const remove = useMessageStore(state => state.remove);
diff --git a/apps/mobile/src/components/announcements/list.js b/apps/mobile/src/components/announcements/list.js
index cb988e18d..3b2a13222 100644
--- a/apps/mobile/src/components/announcements/list.js
+++ b/apps/mobile/src/components/announcements/list.js
@@ -1,13 +1,12 @@
import React from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import Paragraph from '../ui/typography/paragraph';
import { getStyle } from './functions';
export const List = ({ items, listType, style = {} }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<View
diff --git a/apps/mobile/src/components/announcements/subheading.js b/apps/mobile/src/components/announcements/subheading.js
index 4548adb81..c44066eca 100644
--- a/apps/mobile/src/components/announcements/subheading.js
+++ b/apps/mobile/src/components/announcements/subheading.js
@@ -1,12 +1,11 @@
import React from 'react';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import Heading from '../ui/typography/heading';
import { getStyle } from './functions';
export const SubHeading = ({ text, style = {} }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<Heading
diff --git a/apps/mobile/src/components/announcements/title.js b/apps/mobile/src/components/announcements/title.js
index efd4b4d8c..46e3d9250 100644
--- a/apps/mobile/src/components/announcements/title.js
+++ b/apps/mobile/src/components/announcements/title.js
@@ -1,11 +1,10 @@
import React from 'react';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import Heading from '../ui/typography/heading';
import { getStyle } from './functions';
export const Title = ({ text, style = {} }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<Heading
diff --git a/apps/mobile/src/components/attachments/attachmentitem.js b/apps/mobile/src/components/attachments/attachmentitem.js
index 2174f62a7..5dacc1898 100644
--- a/apps/mobile/src/components/attachments/attachmentitem.js
+++ b/apps/mobile/src/components/attachments/attachmentitem.js
@@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react';
import { TouchableOpacity, View } from 'react-native';
import * as Progress from 'react-native-progress';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { useAttachmentStore } from '../../provider/stores';
+import { useThemeStore } from '../../stores/theme';
+import { useAttachmentStore } from '../../stores/stores';
import { db } from '../../utils/database';
import filesystem from '../../utils/filesystem';
import { SIZE } from '../../utils/size';
@@ -29,8 +29,7 @@ function getFileExtension(filename) {
}
export const AttachmentItem = ({ attachment, encryption }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const progress = useAttachmentStore(state => state.progress);
const [currentProgress, setCurrentProgress] = useState(
encryption
diff --git a/apps/mobile/src/components/attachments/index.js b/apps/mobile/src/components/attachments/index.js
index 2ddb464d7..72fe1193a 100644
--- a/apps/mobile/src/components/attachments/index.js
+++ b/apps/mobile/src/components/attachments/index.js
@@ -2,8 +2,8 @@ import React, { useEffect, useRef, useState } from 'react';
import { View } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { db } from '../../utils/database';
import { eCloseAttachmentDialog, eOpenAttachmentsDialog } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -12,8 +12,7 @@ import SheetWrapper from '../ui/sheet';
import Paragraph from '../ui/typography/paragraph';
import { AttachmentItem } from './attachment-item';
export const AttachmentDialog = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [note, setNote] = useState(null);
const actionSheetRef = useRef();
diff --git a/apps/mobile/src/components/auth/changepassword.js b/apps/mobile/src/components/auth/changepassword.js
index fbd628cbb..a0be4952d 100644
--- a/apps/mobile/src/components/auth/changepassword.js
+++ b/apps/mobile/src/components/auth/changepassword.js
@@ -1,8 +1,8 @@
import React, { useRef, useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
import { db } from '../../utils/database';
import { eCloseProgressDialog } from '../../utils/events';
import { Button } from '../ui/button';
@@ -12,8 +12,7 @@ import { Notice } from '../ui/notice';
import Seperator from '../ui/seperator';
export const ChangePassword = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const passwordInputRef = useRef();
const password = useRef();
const oldPasswordInputRef = useRef();
diff --git a/apps/mobile/src/components/auth/forgotpassword.js b/apps/mobile/src/components/auth/forgotpassword.js
index dc854608f..d2ade888e 100644
--- a/apps/mobile/src/components/auth/forgotpassword.js
+++ b/apps/mobile/src/components/auth/forgotpassword.js
@@ -1,9 +1,9 @@
import React, { useRef, useState } from 'react';
import { View } from 'react-native';
import ActionSheet from 'react-native-actions-sheet';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
-import { ToastEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { DDS } from '../../services/device-detection';
+import { ToastEvent } from '../../services/event-manager';
import { db } from '../../utils/database';
import { MMKV } from '../../utils/database/mmkv';
import { IconButton } from '../ui/icon-button';
@@ -15,8 +15,7 @@ import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
export const ForgotPassword = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const email = useRef();
const emailInputRef = useRef();
const [error, setError] = useState(false);
diff --git a/apps/mobile/src/components/auth/index.js b/apps/mobile/src/components/auth/index.js
index bcdf81581..26630c67f 100644
--- a/apps/mobile/src/components/auth/index.js
+++ b/apps/mobile/src/components/auth/index.js
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
-import { useTracked } from '../../provider/index';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { eCloseLoginDialog, eOpenLoginDialog } from '../../utils/events';
import { sleep } from '../../utils/time';
import BaseDialog from '../dialog/base-dialog';
@@ -16,8 +16,7 @@ export const AuthMode = {
};
const Auth = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [currentAuthMode, setCurrentAuthMode] = useState(AuthMode.login);
const actionSheetRef = useRef();
diff --git a/apps/mobile/src/components/auth/login.js b/apps/mobile/src/components/auth/login.js
index 9260c799d..dee852481 100644
--- a/apps/mobile/src/components/auth/login.js
+++ b/apps/mobile/src/components/auth/login.js
@@ -2,12 +2,12 @@ import React, { useEffect, useRef, useState } from 'react';
import { Platform, View } from 'react-native';
import { SheetManager } from 'react-native-actions-sheet';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';
-import { clearMessage } from '../../services/Message';
-import PremiumService from '../../services/PremiumService';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
+import { clearMessage } from '../../services/message';
+import PremiumService from '../../services/premium';
import { db } from '../../utils/database';
import { eCloseLoginDialog } from '../../utils/events';
import { MMKV } from '../../utils/database/mmkv';
@@ -25,8 +25,7 @@ import { SVG } from './background';
import { ForgotPassword } from './forgot-password';
export const Login = ({ changeMode }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const email = useRef();
const emailInputRef = useRef();
const passwordInputRef = useRef();
diff --git a/apps/mobile/src/components/auth/sessionexpired.js b/apps/mobile/src/components/auth/sessionexpired.js
index e60d360ab..6e8fece4f 100644
--- a/apps/mobile/src/components/auth/sessionexpired.js
+++ b/apps/mobile/src/components/auth/sessionexpired.js
@@ -1,18 +1,18 @@
import React, { useEffect, useRef, useState } from 'react';
import { Modal, View } from 'react-native';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import BiometricService from '../../services/BiometricService';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import BiometricService from '../../services/biometrics';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet,
ToastEvent
-} from '../../services/EventManager';
-import { clearMessage } from '../../services/Message';
-import PremiumService from '../../services/PremiumService';
-import Sync from '../../services/Sync';
+} from '../../services/event-manager';
+import { clearMessage } from '../../services/message';
+import PremiumService from '../../services/premium';
+import Sync from '../../services/sync';
import { db } from '../../utils/database';
import { MMKV } from '../../utils/database/mmkv';
import { SIZE } from '../../utils/size';
@@ -37,8 +37,7 @@ function getEmail(email) {
}
export const SessionExpired = () => {
- const [state, dispatch] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const email = useRef();
const emailInputRef = useRef();
const passwordInputRef = useRef();
diff --git a/apps/mobile/src/components/auth/signup.js b/apps/mobile/src/components/auth/signup.js
index ac259e2c6..72fb796b4 100644
--- a/apps/mobile/src/components/auth/signup.js
+++ b/apps/mobile/src/components/auth/signup.js
@@ -1,12 +1,12 @@
import React, { useRef, useState } from 'react';
import { Dimensions, Platform, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, ToastEvent } from '../../services/EventManager';
-import { clearMessage, setEmailVerifyMessage } from '../../services/Message';
-import PremiumService from '../../services/PremiumService';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent, ToastEvent } from '../../services/event-manager';
+import { clearMessage, setEmailVerifyMessage } from '../../services/message';
+import PremiumService from '../../services/premium';
import { db } from '../../utils/database';
import { eCloseLoginDialog } from '../../utils/events';
import { openLinkInBrowser } from '../../utils/functions';
@@ -24,8 +24,7 @@ import Paragraph from '../ui/typography/paragraph';
import { SVG } from './background';
export const Signup = ({ changeMode, welcome, trial }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const email = useRef();
const emailInputRef = useRef();
const passwordInputRef = useRef();
diff --git a/apps/mobile/src/components/container/containerheader.js b/apps/mobile/src/components/container/containerheader.js
index c2ebf161b..8d0580731 100644
--- a/apps/mobile/src/components/container/containerheader.js
+++ b/apps/mobile/src/components/container/containerheader.js
@@ -1,11 +1,10 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { useSelectionStore } from '../../provider/stores';
+import { useThemeStore } from '../../stores/theme';
+import { useSelectionStore } from '../../stores/stores';
export const ContainerHeader = ({ children }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const selectionMode = useSelectionStore(state => state.selectionMode);
return !selectionMode ? (
diff --git a/apps/mobile/src/components/container/floatingbutton.js b/apps/mobile/src/components/container/floatingbutton.js
index 9f24b81dd..5b22de256 100644
--- a/apps/mobile/src/components/container/floatingbutton.js
+++ b/apps/mobile/src/components/container/floatingbutton.js
@@ -4,7 +4,7 @@ import Animated, { Easing } from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { notesnook } from '../../../e2e/test.ids';
-import { useSelectionStore, useSettingStore } from '../../provider/stores';
+import { useSelectionStore, useSettingStore } from '../../stores/stores';
import { editing, getElevation, showTooltip, TOOLTIP_POSITIONS } from '../../utils';
import { normalize, SIZE } from '../../utils/size';
import { PressableButton } from '../ui/pressable';
diff --git a/apps/mobile/src/components/container/index.js b/apps/mobile/src/components/container/index.js
index b275e52e3..59af9fbce 100644
--- a/apps/mobile/src/components/container/index.js
+++ b/apps/mobile/src/components/container/index.js
@@ -1,10 +1,9 @@
import React from 'react';
import { KeyboardAvoidingView, Platform, SafeAreaView } from 'react-native';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import useIsFloatingKeyboard from '../../utils/hooks/use-is-floating-keyboard';
export const Container = ({ children }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const floating = useIsFloatingKeyboard();
return (
<KeyboardAvoidingView
diff --git a/apps/mobile/src/components/dialog/BaseDialog.js b/apps/mobile/src/components/dialog/BaseDialog.js
index 6c4ab85da..e9b3690b7 100644
--- a/apps/mobile/src/components/dialog/BaseDialog.js
+++ b/apps/mobile/src/components/dialog/BaseDialog.js
@@ -8,7 +8,7 @@ import {
TouchableOpacity,
View
} from 'react-native';
-import { useSettingStore } from '../../provider/stores';
+import { useSettingStore } from '../../stores/stores';
import useIsFloatingKeyboard from '../../utils/hooks/use-is-floating-keyboard';
import { BouncingView } from '../ui/transitions/bouncing-view';
diff --git a/apps/mobile/src/components/dialog/DialogButtons.js b/apps/mobile/src/components/dialog/DialogButtons.js
index abcaddeda..50029cfa3 100644
--- a/apps/mobile/src/components/dialog/DialogButtons.js
+++ b/apps/mobile/src/components/dialog/DialogButtons.js
@@ -1,6 +1,6 @@
import React from 'react';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
import Paragraph from '../ui/typography/paragraph';
@@ -16,8 +16,7 @@ const DialogButtons = ({
doneText,
positiveType
}) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<View
diff --git a/apps/mobile/src/components/dialog/DialogContainer.js b/apps/mobile/src/components/dialog/DialogContainer.js
index ca16079c6..f3be91445 100644
--- a/apps/mobile/src/components/dialog/DialogContainer.js
+++ b/apps/mobile/src/components/dialog/DialogContainer.js
@@ -1,12 +1,11 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
+import { useThemeStore } from '../../stores/theme';
+import { DDS } from '../../services/device-detection';
import { getElevation } from '../../utils';
const DialogContainer = ({ width, height, ...restProps }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<View
diff --git a/apps/mobile/src/components/dialog/DialogHeader.js b/apps/mobile/src/components/dialog/DialogHeader.js
index 90fc15660..c974f39c7 100644
--- a/apps/mobile/src/components/dialog/DialogHeader.js
+++ b/apps/mobile/src/components/dialog/DialogHeader.js
@@ -1,7 +1,7 @@
import React from 'react';
import { Text } from 'react-native';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
import Heading from '../ui/typography/heading';
@@ -17,8 +17,7 @@ const DialogHeader = ({
centered,
titlePart
}) => {
- const [state, dispatch] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<>
diff --git a/apps/mobile/src/components/dialog/functions.ts b/apps/mobile/src/components/dialog/functions.ts
index 9b41436e5..3724cfdc2 100644
--- a/apps/mobile/src/components/dialog/functions.ts
+++ b/apps/mobile/src/components/dialog/functions.ts
@@ -1,4 +1,4 @@
-import { eSendEvent } from '../../services/EventManager';
+import { eSendEvent } from '../../services/event-manager';
import { eCloseSimpleDialog, eOpenSimpleDialog } from '../../utils/events';
type DialogInfo = {
diff --git a/apps/mobile/src/components/dialog/index.js b/apps/mobile/src/components/dialog/index.js
index 495a61a5e..331d29f25 100644
--- a/apps/mobile/src/components/dialog/index.js
+++ b/apps/mobile/src/components/dialog/index.js
@@ -1,8 +1,8 @@
import React, { useEffect, useRef, useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { DDS } from '../../services/device-detection';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { getElevation } from '../../utils';
import { eCloseSimpleDialog, eOpenSimpleDialog } from '../../utils/events';
import { sleep } from '../../utils/time';
@@ -14,8 +14,7 @@ import DialogButtons from './dialog-buttons';
import DialogHeader from './dialog-header';
export const Dialog = ({ context = 'global' }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [inputValue, setInputValue] = useState(null);
const inputRef = useRef();
diff --git a/apps/mobile/src/components/dialogprovider/Recievers.js b/apps/mobile/src/components/dialogprovider/Recievers.js
index 2dcf5048a..f1f439563 100644
--- a/apps/mobile/src/components/dialogprovider/Recievers.js
+++ b/apps/mobile/src/components/dialogprovider/Recievers.js
@@ -1,10 +1,9 @@
-import { eSendEvent } from '../../services/EventManager';
+import { eSendEvent } from '../../services/event-manager';
import {
eCloseActionSheet,
eCloseAddNotebookDialog,
eCloseAddTopicDialog,
eCloseMoveNoteDialog,
- eDispatchAction,
eOpenActionSheet,
eOpenAddNotebookDialog,
eOpenAddTopicDialog,
@@ -40,7 +39,3 @@ export const AddTopicEvent = topic => {
export const HideAddTopicEvent = notebook => {
eSendEvent(eCloseAddTopicDialog, notebook);
};
-
-export const updateEvent = data => {
- eSendEvent(eDispatchAction, data);
-};
diff --git a/apps/mobile/src/components/dialogprovider/index.js b/apps/mobile/src/components/dialogprovider/index.js
index 5d5857951..a30d7db90 100644
--- a/apps/mobile/src/components/dialogprovider/index.js
+++ b/apps/mobile/src/components/dialogprovider/index.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { EditorSettings } from '../../screens/editor/EditorSettings';
import { AddNotebookSheet } from '../sheets/add-notebook';
import { AddTopicDialog } from '../dialogs/add-topic';
@@ -24,8 +24,7 @@ import ManageTagsSheet from '../sheets/manage-tags';
import { VaultDialog } from '../dialogs/vault';
function DialogProvider() {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<>
diff --git a/apps/mobile/src/components/dialogs/addtopic/index.js b/apps/mobile/src/components/dialogs/addtopic/index.js
index 633d9e54a..c1055b4ea 100644
--- a/apps/mobile/src/components/dialogs/addtopic/index.js
+++ b/apps/mobile/src/components/dialogs/addtopic/index.js
@@ -1,9 +1,9 @@
import React, { createRef } from 'react';
import { Keyboard, LayoutAnimation, UIManager, View } from 'react-native';
import { Transition, Transitioning, TransitioningView } from 'react-native-reanimated';
-import { useMenuStore } from '../../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useMenuStore } from '../../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { db } from '../../../utils/database';
import { eCloseAddTopicDialog, eOpenAddTopicDialog } from '../../../utils/events';
import { sleep } from '../../../utils/time';
diff --git a/apps/mobile/src/components/dialogs/jumptosection/index.js b/apps/mobile/src/components/dialogs/jumptosection/index.js
index f9128c9de..a7ccc6756 100644
--- a/apps/mobile/src/components/dialogs/jumptosection/index.js
+++ b/apps/mobile/src/components/dialogs/jumptosection/index.js
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from 'react';
import { ScrollView, View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { useMessageStore } from '../../../provider/stores';
-import { DDS } from '../../../services/DeviceDetection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/EventManager';
+import { useThemeStore } from '../../../stores/theme';
+import { useMessageStore } from '../../../stores/stores';
+import { DDS } from '../../../services/device-detection';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
import { getElevation } from '../../../utils';
import { eCloseJumpToDialog, eOpenJumpToDialog, eScrollEvent } from '../../../utils/events';
import { SIZE } from '../../../utils/size';
@@ -14,8 +14,7 @@ import Paragraph from '../../ui/typography/paragraph';
const offsets = [];
let timeout = null;
const JumpToSectionDialog = ({ scrollRef, data, type, screen }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const notes = data;
const [visible, setVisible] = useState(false);
const [currentIndex, setCurrentIndex] = useState(null);
diff --git a/apps/mobile/src/components/dialogs/result/ProFeatures.js b/apps/mobile/src/components/dialogs/result/ProFeatures.js
index bf95b576b..7793a6a40 100644
--- a/apps/mobile/src/components/dialogs/result/ProFeatures.js
+++ b/apps/mobile/src/components/dialogs/result/ProFeatures.js
@@ -1,8 +1,8 @@
import React from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../provider';
-import { eSendEvent } from '../../../services/EventManager';
+import { useThemeStore } from '../../../stores/theme';
+import { eSendEvent } from '../../../services/event-manager';
import {
eCloseProgressDialog,
eCloseResultDialog,
@@ -12,8 +12,7 @@ import { SIZE } from '../../../utils/size';
import { sleep } from '../../../utils/time';
import Paragraph from '../../ui/typography/paragraph';
export const ProFeatures = ({ count = 6 }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<>
diff --git a/apps/mobile/src/components/dialogs/result/index.js b/apps/mobile/src/components/dialogs/result/index.js
index 05f4675bd..751e390e4 100644
--- a/apps/mobile/src/components/dialogs/result/index.js
+++ b/apps/mobile/src/components/dialogs/result/index.js
@@ -1,8 +1,8 @@
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { DDS } from '../../../services/DeviceDetection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/EventManager';
+import { useThemeStore } from '../../../stores/theme';
+import { DDS } from '../../../services/device-detection';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
import { getElevation } from '../../../utils';
import { eCloseResultDialog, eOpenResultDialog } from '../../../utils/events';
import { SIZE } from '../../../utils/size';
@@ -14,8 +14,7 @@ import Paragraph from '../../ui/typography/paragraph';
import { ProFeatures } from './pro-features';
const ResultDialog = () => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [dialogData, setDialogData] = useState({
title: 'Thank you for signing up!',
diff --git a/apps/mobile/src/components/dialogs/vault/index.js b/apps/mobile/src/components/dialogs/vault/index.js
index 599971d75..6e00972e4 100644
--- a/apps/mobile/src/components/dialogs/vault/index.js
+++ b/apps/mobile/src/components/dialogs/vault/index.js
@@ -3,15 +3,15 @@ import React, { Component, createRef } from 'react';
import { InteractionManager, View } from 'react-native';
import Share from 'react-native-share';
import { notesnook } from '../../../../e2e/test.ids';
-import BiometricService from '../../../services/BiometricService';
-import { DDS } from '../../../services/DeviceDetection';
+import BiometricService from '../../../services/biometrics';
+import { DDS } from '../../../services/device-detection';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent
-} from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+} from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { getElevation, toTXT } from '../../../utils';
import { db } from '../../../utils/database';
import {
@@ -124,7 +124,7 @@ export class VaultDialog extends Component {
/**
*
- * @param {import('../../../services/EventManager').vaultType} data
+ * @param {import('../../../services/event-manager').vaultType} data
*/
open = async data => {
if (!Keychain) {
diff --git a/apps/mobile/src/components/header/index.js b/apps/mobile/src/components/header/index.js
index aeef40dc9..5a2a62d33 100644
--- a/apps/mobile/src/components/header/index.js
+++ b/apps/mobile/src/components/header/index.js
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useTracked } from '../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import SearchService from '../../services/SearchService';
+import { useThemeStore } from '../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import SearchService from '../../services/search';
import { eScrollEvent } from '../../utils/events';
import { IconButton } from '../ui/icon-button';
import { SearchInput } from '../SearchInput';
@@ -13,8 +13,7 @@ import { Title } from './title';
export const Header = React.memo(
({ root, title, screen, isBack, color, action, rightButtons, notebook }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const insets = useSafeAreaInsets();
const [hide, setHide] = useState(true);
diff --git a/apps/mobile/src/components/header/leftmenus.js b/apps/mobile/src/components/header/leftmenus.js
index e151efa02..8a374c2f0 100644
--- a/apps/mobile/src/components/header/leftmenus.js
+++ b/apps/mobile/src/components/header/leftmenus.js
@@ -1,14 +1,13 @@
import React from 'react';
import { notesnook } from '../../../e2e/test.ids';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import Navigation from '../../services/navigation';
import { IconButton } from '../ui/icon-button';
export const LeftMenus = ({ currentScreen, headerMenuState }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const deviceMode = useSettingStore(state => state.deviceMode);
const onLeftButtonPress = () => {
diff --git a/apps/mobile/src/components/header/rightmenus.js b/apps/mobile/src/components/header/rightmenus.js
index fb795c9ea..99675cf42 100644
--- a/apps/mobile/src/components/header/rightmenus.js
+++ b/apps/mobile/src/components/header/rightmenus.js
@@ -2,16 +2,15 @@ import React, { useRef } from 'react';
import { StyleSheet, View } from 'react-native';
import Menu from 'react-native-reanimated-material-menu';
import { notesnook } from '../../../e2e/test.ids';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
+import Navigation from '../../services/navigation';
import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
import { IconButton } from '../ui/icon-button';
export const RightMenus = ({ currentScreen, action, rightButtons }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const deviceMode = useSettingStore(state => state.deviceMode);
const menuRef = useRef();
return (
diff --git a/apps/mobile/src/components/header/title.js b/apps/mobile/src/components/header/title.js
index 778cd32e1..8249d6543 100644
--- a/apps/mobile/src/components/header/title.js
+++ b/apps/mobile/src/components/header/title.js
@@ -1,16 +1,15 @@
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { eOnNewTopicAdded, eScrollEvent } from '../../utils/events';
import { SIZE } from '../../utils/size';
import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
export const Title = ({ heading, headerColor, screen, notebook }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [hide, setHide] = useState(screen === 'Notebook' ? true : false);
const onScroll = data => {
diff --git a/apps/mobile/src/components/imagepreview/index.js b/apps/mobile/src/components/imagepreview/index.js
index 811c21fad..72fb3478f 100644
--- a/apps/mobile/src/components/imagepreview/index.js
+++ b/apps/mobile/src/components/imagepreview/index.js
@@ -5,7 +5,7 @@ import RNFetchBlob from 'rn-fetch-blob';
import Storage from '../../utils/database/storage';
import { IconButton } from '../ui/icon-button';
import BaseDialog from '../dialog/base-dialog';
-const { eSubscribeEvent, eUnSubscribeEvent } = require('../../services/EventManager');
+const { eSubscribeEvent, eUnSubscribeEvent } = require('../../services/eventmanager');
const ImagePreview = () => {
const [visible, setVisible] = useState(false);
diff --git a/apps/mobile/src/components/intro/index.js b/apps/mobile/src/components/intro/index.js
index bbd33383d..4f86d6715 100644
--- a/apps/mobile/src/components/intro/index.js
+++ b/apps/mobile/src/components/intro/index.js
@@ -3,9 +3,9 @@ import { Dimensions, Image, TouchableOpacity, useWindowDimensions, View } from '
import Animated, { Easing, timing, useValue } from 'react-native-reanimated';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
+import SettingsService from '../../services/settings';
import { getElevation } from '../../utils';
import umami from '../../utils/analytics';
import { MMKV } from '../../utils/database/mmkv';
@@ -23,8 +23,7 @@ let SVG_D = `<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="
const SVG_Z = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 245.487 113.9115"><g transform="translate(15.9581 -70.1437)"><path fill="#f2f2f2" d="M181.8672 183.796H88.3134v-54.8973l-.43-.2765 15.1857-14.7907a41.4878 41.4878 0 0 1 28.6939-11.8174l27.916-.2551.04.0477 22.2131 26.426-.0655.7316z" style="stroke-width:.264583"/><path fill="#fff" d="M105.9334 112.1178h55.9519v.5292h-55.9519zM100.3772 117.6741h55.9519v.5292h-55.9519z" style="stroke-width:.264583"/><path fill="#fff" d="M178.6826 154.0514h10.1706v8.9897h-10.1706z" data-name="Rectangle 371" style="stroke-width:.264583"/><path fill="#fff" d="M178.6826 138.4916h10.1706v8.8471h-10.1706z" data-name="Rectangle 372" style="stroke-width:.264583"/><path fill="#f2f2f2" d="M166.653 102.649h9.1202v31.5648h-9.1202z" style="stroke-width:.264583"/><path fill="#e6e6e6" d="M181.8672 183.7957h-50.0656v-36.3798a35.3975 35.3975 0 0 1 8.4588-22.9515l19.3804-22.7213 22.2264 26.4599z" style="stroke-width:.264583"/><path fill="#fff" d="M155.3064 156.4369h10.1706v8.9897h-10.1706z" data-name="Rectangle 374" style="stroke-width:.264583"/><path fill="#fff" d="M155.3064 140.8768h10.1706v8.8471h-10.1706z" data-name="Rectangle 375" style="stroke-width:.264583"/><path fill="#fff" d="M106.7252 154.0514h10.1706v8.9897h-10.1706z" data-name="Rectangle 378" style="stroke-width:.264583"/><path fill="#fff" d="M106.7252 138.4916h10.1706v8.8471h-10.1706z" data-name="Rectangle 379" style="stroke-width:.264583"/><path fill="#f2f2f2" d="M91.7626 85.332h11.0675v38.3117H91.7626z" style="stroke-width:.264583"/><path fill="#f2f2f2" d="M110.199 183.7954H-3.295v-66.6167l-.5047-.325.119-.116 20.73-20.1916A41.863 41.863 0 0 1 46.0038 84.621l37.2782-.3406.0402.0477 26.9535 32.0651-.0773.8764z" style="stroke-width:.264583"/><path fill="#e6e6e6" d="M110.199 183.7954H49.4881V134.88a29.9322 29.9322 0 0 1 7.1528-19.408l26.6087-31.1956 26.9492 32.0815Z" style="stroke-width:.264583"/><path fill="#fff" d="M80.3413 150.6172h9.8174v8.6775h-9.8174zM80.3413 135.5359h9.8174v8.6775h-9.8174z" data-name="Rectangle 381" style="stroke-width:.264583"/><path fill="#fff" d="M19.0243 147.7216H31.369v10.9112H19.0243z" data-name="Rectangle 385" style="stroke-width:.264583"/><path fill="#fff" d="M19.0243 128.8356H31.369v10.7381H19.0243z" data-name="Rectangle 386" style="stroke-width:.264583"/><ellipse cx="20.8891" cy="154.324" fill="#3f3d56" data-name="Ellipse 519" rx="8.7979" ry="17.9515" style="stroke-width:.264583"/><path fill="#808080" d="M21.7016 183.7075c-3.5237-21.1402-.0354-42.2063 0-42.4164l.6856.1162c-.0355.209-3.5036 21.1635 0 42.1862z" data-name="Path 2702" style="fill:#999;stroke-width:.264583"/><path fill="#808080" d="M-54.7406 146.1809h9.0223v.6953h-9.0223z" data-name="Rectangle 388" style="fill:#b3b3b3;stroke-width:.264583" transform="rotate(-28.142)"/><path fill="#808080" d="M-129.2795 83.128h.6953v9.0226h-.6953z" data-name="Rectangle 389" style="fill:#b3b3b3;stroke-width:.264583" transform="rotate(-61.842)"/><ellipse cx="-.4146" cy="141.6901" fill="#808080" data-name="Ellipse 520" rx="12.6968" ry="25.9067" style="fill:#333;stroke-width:.264583"/><path fill="#3f3d56" d="M.9996 184.0552c-5.0784-30.47-.0514-60.829 0-61.1323l.5056.0857c-.0513.3025-5.0636 30.5798 0 60.9624z" data-name="Path 2703" style="fill:#e6e6e6;stroke-width:.264583"/><path fill="#3f3d56" d="M-67.7316 125.3486h13.0209v.513h-13.0209z" data-name="Rectangle 390" style="fill:#ccc;stroke-width:.264583" transform="rotate(-28.142)"/><path fill="#3f3d56" d="M-129.3145 54.7885h.513v13.0209h-.513z" data-name="Rectangle 391" style="fill:#b3b3b3;stroke-width:.264583" transform="rotate(-61.842)"/><path fill="#3f3d56" d="m159.149 89.5463 2.7831-2.2262c-2.1621-.2381-3.0506.9406-3.413 1.874-1.6892-.7014-3.5283.2178-3.5283.2178l5.5687 2.0217a4.2137 4.2137 0 0 0-1.4097-1.8876z" data-name="Path 2708" style="stroke-width:.264583"/><path fill="#3f3d56" d="m108.853 72.401 2.7831-2.2262c-2.1621-.2381-3.0506.9406-3.413 1.874-1.6892-.7013-3.5283.2178-3.5283.2178l5.5687 2.0217a4.214 4.214 0 0 0-1.4105-1.8873z" data-name="Path 2709" style="stroke-width:.264583"/><path fill="#3f3d56" d="m178.9044 76.546 2.7831-2.2262c-2.1622-.2381-3.0506.9406-3.4131 1.874-1.6891-.7014-3.5282.2178-3.5282.2178l5.5687 2.0217a4.2138 4.2138 0 0 0-1.4097-1.8876z" data-name="Path 2710" style="stroke-width:.264583"/><path fill="#3f3d56" d="M60.5922 179.896a4.2088 4.2088 0 0 0-2.1077.5656 4.5297 4.5297 0 0 0-7.567 3.365h13.8924a4.2299 4.2299 0 0 0-4.2174-3.9304z" data-name="Path 2712" style="stroke-width:.264583"/><path fill="#3f3d56" d="M132.852 179.896a4.2088 4.2088 0 0 0-2.1076.5656 4.5297 4.5297 0 0 0-7.5671 3.365h13.8925a4.2299 4.2299 0 0 0-4.2178-3.9307z" data-name="Path 2713" style="stroke-width:.264583"/><g fill="#3f3d56" data-name="Group 204"><path d="M97.2576 176.8633H77.5234v.6366h3.0777v6.0476h.6365v-6.0476H93.225v6.0476h.6365v-6.0476h3.396z" data-name="Path 2714"/><path d="M77.5623 174.9588h19.7342v.6366H77.5623z" data-name="Rectangle 400"/><path d="M77.5623 173.3674h19.7342v.6365H77.5623z" data-name="Rectangle 401"/></g><ellipse cx="215.2396" cy="158.3491" fill="#e6e6e6" data-name="Ellipse 525" rx="7.7041" ry="15.7197" style="stroke-width:.264583"/><path fill="#3f3d56" d="M214.3815 184.0552c3.0816-18.4886.031-36.9094 0-37.0946l-.3069.053c.031.1833 3.0726 18.5551 0 36.9908z" data-name="Path 2716" style="stroke-width:.264583"/><path fill="#3f3d56" d="M-38.7353 256.9106h.3115v7.9035h-.3115z" data-name="Rectangle 406" style="stroke-width:.264583" transform="rotate(-61.847)"/><path fill="#3f3d56" d="M114.2645 243.4071h7.9035v.3115h-7.9035z" data-name="Rectangle 407" style="stroke-width:.264583" transform="rotate(-28.153)"/><g fill="#3f3d56" data-name="Group 205"><path d="M169.5172 176.8633H149.783v.6366h3.0776v6.0476h.6366v-6.0476h11.9872v6.0476h.6366v-6.0476h3.396z" data-name="Path 2714-2"/><path d="M149.8219 174.9588h19.7342v.6366h-19.7342z" data-name="Rectangle 400-2"/><path d="M149.8219 173.3674h19.7342v.6365h-19.7342z" data-name="Rectangle 401-2"/></g><path fill="#f2f2f2" d="m90.2625 105.5306-2.3728-5.5049-4.763.085-2.8892 5.488.0583.0732h-.0208v11.4152h9.981v-11.4153zM164.4423 119.3093l-1.9175-4.0238-3.849.062-2.3348 4.0115.0471.0535h-.0168v8.3438h8.0658v-8.3438z" data-name="Path 2700" style="stroke-width:.264583"/><path fill="#fff" d="M10.3066 102.6488h55.9519v.5292H10.3066zM10.3066 103.178h55.9519v.5292H10.3066zM166.653 104.181h9.1202v.5292h-9.1202zM166.653 109.7372h9.1202v.5292h-9.1202zM91.7626 87.2476h11.0675v.5292H91.7626zM91.7626 92.8039h11.0675v.5292H91.7626z" style="stroke-width:.264583"/></g></svg>`;
const Intro = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const isIntroCompleted = useSettingStore(state => state.isIntroCompleted);
const setIntroCompleted = useSettingStore(state => state.setIntroCompleted);
const settings = useSettingStore(state => state.settings);
diff --git a/apps/mobile/src/components/intro/welcome.js b/apps/mobile/src/components/intro/welcome.js
index 7334f8985..e5b2f0d00 100644
--- a/apps/mobile/src/components/intro/welcome.js
+++ b/apps/mobile/src/components/intro/welcome.js
@@ -1,8 +1,8 @@
import React from 'react';
import { View } from 'react-native';
import umami from '../../utils/analytics';
-import { useTracked } from '../../provider';
-import { eSendEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent } from '../../services/event-manager';
import { getElevation } from '../../utils';
import { eCloseProgressDialog, eOpenLoginDialog } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -15,8 +15,7 @@ const IMAGE = color =>
`<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width="1100.50064" height="691.70682" viewBox="0 0 1100.50064 691.70682" xmlns:xlink="http://www.w3.org/1999/xlink"><title>two_factor_authentication</title><path d="M1150.25032,388.23743h-1.85859V337.32194a29.4685,29.4685,0,0,0-29.46859-29.46853H1011.05186a29.4685,29.4685,0,0,0-29.46859,29.46853V616.64827a29.46851,29.46851,0,0,0,29.46859,29.46854h107.87128a29.46851,29.46851,0,0,0,29.46859-29.46854V424.47994h1.85859Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M1142.121,339.05342v278.92a22.01111,22.01111,0,0,1-22.01,22.01h-108.39a22.00248,22.00248,0,0,1-22-22.01v-278.92a22.00031,22.00031,0,0,1,22-22h13.15a10.4608,10.4608,0,0,0,9.68,14.4h61.8a10.44027,10.44027,0,0,0,9.67993-14.4H1120.111A22.00894,22.00894,0,0,1,1142.121,339.05342Z" transform="translate(-49.74968 -104.14659)" fill="#d0cde1"/><rect x="945.85129" y="355.70682" width="126" height="34" fill="${color}"/><path d="M1126.601,487.85341h-122a3.00328,3.00328,0,0,1-3-3v-30a3.00328,3.00328,0,0,1,3-3h122a3.00328,3.00328,0,0,1,3,3v30A3.00328,3.00328,0,0,1,1126.601,487.85341Zm-122-34a1.001,1.001,0,0,0-1,1v30a1.00067,1.00067,0,0,0,1,1h122a1.00067,1.00067,0,0,0,1-1v-30a1.001,1.001,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="959.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="981.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="1003.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="1025.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="1047.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><path d="M1142.121,589.61342v28.36a22.01111,22.01111,0,0,1-22.01,22.01h-108.39a22.00248,22.00248,0,0,1-22-22.01v-130.46Z" transform="translate(-49.74968 -104.14659)" opacity="0.1"/><rect x="99.85129" y="459.70682" width="473" height="232" fill="#d0cde1"/><path d="M502.351,795.85341H151.601a2.00591,2.00591,0,0,1-2-2v-228a2.00587,2.00587,0,0,1,2-2h4.44Z" transform="translate(-49.74968 -104.14659)" opacity="0.1"/><rect x="318.85129" y="490.70682" width="732.99951" height="2" fill="#3f3d56"/><path d="M600.34268,108.46435H390.853v-4.31776H295.86217v4.31776H85.5089a14.17039,14.17039,0,0,0-14.1704,14.1704V409.4906a14.17043,14.17043,0,0,0,14.1704,14.17045H600.34268a14.17044,14.17044,0,0,0,14.1704-14.17045V122.63475A14.17039,14.17039,0,0,0,600.34268,108.46435Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="40.59128" y="29.35679" width="505.16998" height="284.98004" fill="#d0cde1"/><circle cx="292.74433" cy="16.4075" r="5.18132" fill="${color}"/><path d="M240.601,239.85341h-12a3.00328,3.00328,0,0,1-3-3v-12a3.00328,3.00328,0,0,1,3-3h12a3.00328,3.00328,0,0,1,3,3v12A3.00328,3.00328,0,0,1,240.601,239.85341Zm-12-16a1.0013,1.0013,0,0,0-1,1v12a1.0013,1.0013,0,0,0,1,1h12a1.0013,1.0013,0,0,0,1-1v-12a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="176.85129" y="133.70682" width="228" height="2" fill="#3f3d56"/><rect x="345.85129" y="188.70682" width="53" height="16" fill="${color}"/><path d="M452.601,304.85341h-49a3.00328,3.00328,0,0,1-3-3v-12a3.00328,3.00328,0,0,1,3-3h49a3.00328,3.00328,0,0,1,3,3v12A3.00328,3.00328,0,0,1,452.601,304.85341Zm-49-16a1.0013,1.0013,0,0,0-1,1v12a1.0013,1.0013,0,0,0,1,1h49a1.0013,1.0013,0,0,0,1-1v-12a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="703.85129" y="206.70682" width="100" height="70" fill="${color}"/><path d="M863.601,375.35341h-96a4.00427,4.00427,0,0,1-4-4v-66a4.00427,4.00427,0,0,1,4-4h96a4.00426,4.00426,0,0,1,4,4v66A4.00426,4.00426,0,0,1,863.601,375.35341Zm-96-70v66H863.6039l-.00293-66Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M852.601,302.85341h-4a33,33,0,1,0-66,0h-4a37,37,0,1,1,74,0Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M825.601,330.35341a10.00023,10.00023,0,1,0-15.29412,8.47258V349.5593a5.29411,5.29411,0,0,0,5.29412,5.29411h0a5.29411,5.29411,0,0,0,5.29411-5.29411V338.826A9.98327,9.98327,0,0,0,825.601,330.35341Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="284.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="306.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="328.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="350.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="372.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><path d="M643.60059,778.85352H174.60107a4.00428,4.00428,0,0,1-4-4v-228a4.00427,4.00427,0,0,1,4-4H643.60059a4.004,4.004,0,0,1,4,4v228A4.004,4.004,0,0,1,643.60059,778.85352Zm-468.99952-232v228H643.60352l-.00293-228Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><circle cx="145.85129" cy="470.70682" r="6" fill="#3f3d56"/><circle cx="166.85129" cy="470.70682" r="6" fill="#3f3d56"/><circle cx="187.85129" cy="470.70682" r="6" fill="#3f3d56"/><path d="M453.601,680.85341h-135a3.00328,3.00328,0,0,1-3-3v-34a3.00328,3.00328,0,0,1,3-3h135a3.00328,3.00328,0,0,1,3,3v34A3.00328,3.00328,0,0,1,453.601,680.85341Zm-135-38a1.001,1.001,0,0,0-1,1v34a1.001,1.001,0,0,0,1,1h135a1.001,1.001,0,0,0,1-1v-34a1.001,1.001,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><circle cx="437.85129" cy="559.70682" r="18" fill="${color}"/><path d="M493.601,679.85341a19,19,0,1,1,19-19A19.02162,19.02162,0,0,1,493.601,679.85341Zm0-36a17,17,0,1,0,17,17A17.019,17.019,0,0,0,493.601,643.85341Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><polygon points="444.118 563.803 434.437 554.121 437.265 551.293 443.584 557.611 461.216 532.555 464.487 534.858 444.118 563.803" fill="#3f3d56"/><polygon points="433.761 314.337 40.591 314.337 40.591 50.947 433.761 314.337" opacity="0.1"/><path d="M628.69739,413.2984H579.39527v-3.55218a.7043.7043,0,0,0-.70431-.70432H561.78737a.70429.70429,0,0,0-.70431.70432v3.55218H550.51832v-3.55218a.7043.7043,0,0,0-.70432-.70432H532.91042a.7043.7043,0,0,0-.70432.70432v3.55218H521.64136v-3.55218a.70429.70429,0,0,0-.70431-.70432H504.03347a.7043.7043,0,0,0-.70432.70432v3.55218H492.76441v-3.55218a.7043.7043,0,0,0-.70432-.70432H475.15651a.70429.70429,0,0,0-.70431.70432v3.55218H463.88746v-3.55218a.7043.7043,0,0,0-.70432-.70432H446.27956a.7043.7043,0,0,0-.70432.70432v3.55218H435.0105v-3.55218a.70429.70429,0,0,0-.70431-.70432H417.4026a.7043.7043,0,0,0-.70431.70432v3.55218H406.13355v-3.55218a.7043.7043,0,0,0-.70432-.70432H273.01784a.7043.7043,0,0,0-.70432.70432v3.55218H261.74878v-3.55218a.7043.7043,0,0,0-.70432-.70432H244.14088a.70429.70429,0,0,0-.70431.70432v3.55218H232.87183v-3.55218a.7043.7043,0,0,0-.70432-.70432H215.26393a.7043.7043,0,0,0-.70432.70432v3.55218H203.99487v-3.55218a.70429.70429,0,0,0-.70431-.70432H186.387a.7043.7043,0,0,0-.70431.70432v3.55218H175.11792v-3.55218a.7043.7043,0,0,0-.70432-.70432H157.51a.7043.7043,0,0,0-.70432.70432v3.55218H146.241v-3.55218a.7043.7043,0,0,0-.70432-.70432H128.63307a.7043.7043,0,0,0-.70432.70432v3.55218H117.364v-3.55218a.7043.7043,0,0,0-.70431-.70432H99.75611a.70429.70429,0,0,0-.70431.70432v3.55218H66.65326A16.90359,16.90359,0,0,0,49.74968,430.202v7.6434a16.90358,16.90358,0,0,0,16.90358,16.90354H628.69739A16.90358,16.90358,0,0,0,645.601,437.84539V430.202A16.90359,16.90359,0,0,0,628.69739,413.2984Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M474.601,321.85341h-264a3.00328,3.00328,0,0,1-3-3v-110a3.00328,3.00328,0,0,1,3-3h264a3.00328,3.00328,0,0,1,3,3v110A3.00328,3.00328,0,0,1,474.601,321.85341Zm-264-114a1.0013,1.0013,0,0,0-1,1v110a1.0013,1.0013,0,0,0,1,1h264a1.0013,1.0013,0,0,0,1-1v-110a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M240.601,269.85341h-12a3.00328,3.00328,0,0,1-3-3v-12a3.00328,3.00328,0,0,1,3-3h12a3.00328,3.00328,0,0,1,3,3v12A3.00328,3.00328,0,0,1,240.601,269.85341Zm-12-16a1.0013,1.0013,0,0,0-1,1v12a1.0013,1.0013,0,0,0,1,1h12a1.0013,1.0013,0,0,0,1-1v-12a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="176.85129" y="163.70682" width="228" height="2" fill="#3f3d56"/><rect x="264.85129" y="269.70682" width="732.99951" height="2" fill="#3f3d56"/><circle cx="264.85129" cy="269.70682" r="14" fill="#3f3d56"/><circle cx="997.85129" cy="271.70682" r="11" fill="#3f3d56"/><circle cx="1051.85129" cy="492.70682" r="11" fill="#3f3d56"/><circle cx="321.85129" cy="492.70682" r="11" fill="#3f3d56"/></svg>`;
export const WelcomeNotice = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<View
style={{
diff --git a/apps/mobile/src/components/launcher/index.js b/apps/mobile/src/components/launcher/index.js
index 35bd8430c..ca3b73811 100644
--- a/apps/mobile/src/components/launcher/index.js
+++ b/apps/mobile/src/components/launcher/index.js
@@ -2,25 +2,25 @@ import React, { useEffect, useRef, useState } from 'react';
import { NativeModules, Platform, StatusBar, View } from 'react-native';
import RNBootSplash from 'react-native-bootsplash';
import { checkVersion } from 'react-native-check-version';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import {
useFavoriteStore,
useMessageStore,
useNoteStore,
useSettingStore,
useUserStore
-} from '../../provider/stores';
-import BiometricService from '../../services/BiometricService';
-import { DDS } from '../../services/DeviceDetection';
+} from '../../stores/stores';
+import BiometricService from '../../services/biometrics';
+import { DDS } from '../../services/device-detection';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet,
ToastEvent
-} from '../../services/EventManager';
-import { setRateAppMessage } from '../../services/Message';
-import PremiumService from '../../services/PremiumService';
+} from '../../services/event-manager';
+import { setRateAppMessage } from '../../services/message';
+import PremiumService from '../../services/premium';
import { editing } from '../../utils';
import { db } from '../../utils/database';
import { eOpenAnnouncementDialog } from '../../utils/events';
@@ -44,8 +44,7 @@ let passwordValue = null;
let didVerifyUser = false;
const Launcher = ({ onLoad }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const setNotes = useNoteStore(state => state.setNotes);
const setFavorites = useFavoriteStore(state => state.setFavorites);
const _setLoading = useNoteStore(state => state.setLoading);
diff --git a/apps/mobile/src/components/list/card.js b/apps/mobile/src/components/list/card.js
index 7249097a9..d995ab52e 100644
--- a/apps/mobile/src/components/list/card.js
+++ b/apps/mobile/src/components/list/card.js
@@ -1,16 +1,15 @@
import React from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { useMessageStore, useSelectionStore } from '../../provider/stores';
+import { useThemeStore } from '../../stores/theme';
+import { useMessageStore, useSelectionStore } from '../../stores/stores';
import { hexToRGBA } from '../../utils/color-scheme/utils';
import { SIZE } from '../../utils/size';
import { PressableButton } from '../ui/pressable';
import Paragraph from '../ui/typography/paragraph';
export const Card = ({ color }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
color = color ? color : colors.accent;
const selectionMode = useSelectionStore(state => state.selectionMode);
diff --git a/apps/mobile/src/components/list/empty.js b/apps/mobile/src/components/list/empty.js
index 0d7d6a650..c5712a920 100644
--- a/apps/mobile/src/components/list/empty.js
+++ b/apps/mobile/src/components/list/empty.js
@@ -1,8 +1,8 @@
import React from 'react';
import { ActivityIndicator, useWindowDimensions, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
import { useTip } from '../../services/tip-manager';
import { COLORS_NOTE } from '../../utils/color-scheme';
import { SIZE } from '../../utils/size';
@@ -14,8 +14,7 @@ import Paragraph from '../ui/typography/paragraph';
export const Empty = React.memo(
({ loading = true, placeholderData, headerProps, type, screen }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const insets = useSafeAreaInsets();
const { height } = useWindowDimensions();
const introCompleted = useSettingStore(state => state.isIntroCompleted);
diff --git a/apps/mobile/src/components/list/index.js b/apps/mobile/src/components/list/index.js
index 116bae5cd..7abbfb198 100644
--- a/apps/mobile/src/components/list/index.js
+++ b/apps/mobile/src/components/list/index.js
@@ -1,10 +1,10 @@
import React, { useEffect, useRef, useState } from 'react';
import { FlatList, RefreshControl, View } from 'react-native';
import { notesnook } from '../../../e2e/test.ids';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { eSendEvent } from '../../services/EventManager';
-import Sync from '../../services/Sync';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { eSendEvent } from '../../services/event-manager';
+import Sync from '../../services/sync';
import { db } from '../../utils/database';
import { eScrollEvent } from '../../utils/events';
import JumpToSectionDialog from '../dialogs/jump-to-section';
@@ -60,8 +60,7 @@ const List = ({
screen,
ListHeader
}) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const scrollRef = useRef();
const [_loading, _setLoading] = useState(true);
const syncing = useUserStore(state => state.syncing);
diff --git a/apps/mobile/src/components/listitems/headers/header.js b/apps/mobile/src/components/listitems/headers/header.js
index 0a53b5ec4..b79972304 100644
--- a/apps/mobile/src/components/listitems/headers/header.js
+++ b/apps/mobile/src/components/listitems/headers/header.js
@@ -1,15 +1,14 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { useMessageStore } from '../../../provider/stores';
+import { useThemeStore } from '../../../stores/theme';
+import { useMessageStore } from '../../../stores/stores';
import { COLORS_NOTE } from '../../../utils/color-scheme';
import { Announcement } from '../../announcements/announcement';
import { Card } from '../../list/card';
export const Header = React.memo(
({ type, messageCard = true, color, shouldShow = false, noAnnouncement }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const announcements = useMessageStore(state => state.announcements);
return (
diff --git a/apps/mobile/src/components/listitems/headers/notebookheader.js b/apps/mobile/src/components/listitems/headers/notebookheader.js
index 0007f5535..a684c0edb 100644
--- a/apps/mobile/src/components/listitems/headers/notebookheader.js
+++ b/apps/mobile/src/components/listitems/headers/notebookheader.js
@@ -1,8 +1,8 @@
import React, { useRef, useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { useMenuStore } from '../../../provider/stores';
-import { ToastEvent } from '../../../services/EventManager';
+import { useThemeStore } from '../../../stores/theme';
+import { useMenuStore } from '../../../stores/stores';
+import { ToastEvent } from '../../../services/event-manager';
import { getTotalNotes } from '../../../utils';
import { db } from '../../../utils/database';
import { SIZE } from '../../../utils/size';
@@ -11,8 +11,7 @@ import Heading from '../../ui/typography/heading';
import Paragraph from '../../ui/typography/paragraph';
export const NotebookHeader = ({ notebook, onEditNotebook }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [isPinnedToMenu, setIsPinnedToMenu] = useState(db.settings.isPinned(notebook.id));
const setMenuPins = useMenuStore(state => state.setMenuPins);
const totalNotes = getTotalNotes(notebook);
diff --git a/apps/mobile/src/components/listitems/headers/sectionheader.js b/apps/mobile/src/components/listitems/headers/sectionheader.js
index 5d44c7ded..aec3ef01e 100644
--- a/apps/mobile/src/components/listitems/headers/sectionheader.js
+++ b/apps/mobile/src/components/listitems/headers/sectionheader.js
@@ -1,14 +1,14 @@
import React, { useEffect, useRef, useState } from 'react';
import { TouchableOpacity, useWindowDimensions, View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { useSettingStore } from '../../../provider/stores';
+import { useThemeStore } from '../../../stores/theme';
+import { useSettingStore } from '../../../stores/stores';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet
-} from '../../../services/EventManager';
-import SettingsService from '../../../services/SettingsService';
+} from '../../../services/event-manager';
+import SettingsService from '../../../services/settings';
import { GROUP } from '../../../utils/constants';
import { COLORS_NOTE } from '../../../utils/color-scheme';
import { db } from '../../../utils/database';
@@ -20,8 +20,7 @@ import Sort from '../../sheets/sort';
import Heading from '../../ui/typography/heading';
export const SectionHeader = ({ item, index, type, color, screen }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const { fontScale } = useWindowDimensions();
const [groupOptions, setGroupOptions] = useState(db.settings?.getGroupOptions(type));
let groupBy = Object.keys(GROUP).find(key => GROUP[key] === groupOptions.groupBy);
diff --git a/apps/mobile/src/components/listitems/note/index.js b/apps/mobile/src/components/listitems/note/index.js
index 412f18836..051889ff0 100644
--- a/apps/mobile/src/components/listitems/note/index.js
+++ b/apps/mobile/src/components/listitems/note/index.js
@@ -3,10 +3,10 @@ import React from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { notesnook } from '../../../../e2e/test.ids';
-import { useTracked } from '../../../provider';
-import { useSettingStore } from '../../../provider/stores';
-import { eSendEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { useSettingStore } from '../../../stores/stores';
+import { eSendEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { COLORS_NOTE } from '../../../utils/color-scheme';
import { db } from '../../../utils/database';
import { refreshNotesPage } from '../../../utils/events';
@@ -52,8 +52,7 @@ const showActionSheet = item => {
};
const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const compactMode = settings.notesListMode === 'compact';
const attachmentCount = db.attachments?.ofNote(item.id, 'all')?.length || 0;
diff --git a/apps/mobile/src/components/listitems/note/wrapper.js b/apps/mobile/src/components/listitems/note/wrapper.js
index ed7eb9301..c65dc2856 100644
--- a/apps/mobile/src/components/listitems/note/wrapper.js
+++ b/apps/mobile/src/components/listitems/note/wrapper.js
@@ -1,10 +1,10 @@
import React from 'react';
import NoteItem from '.';
import { notesnook } from '../../../../e2e/test.ids';
-import { useEditorStore, useSelectionStore, useTrashStore } from '../../../provider/stores';
-import { DDS } from '../../../services/DeviceDetection';
-import { eSendEvent, openVault, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useEditorStore, useSelectionStore, useTrashStore } from '../../../stores/stores';
+import { DDS } from '../../../services/device-detection';
+import { eSendEvent, openVault, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { history } from '../../../utils';
import { db } from '../../../utils/database';
import { eOnLoadNote, eShowMergeDialog } from '../../../utils/events';
diff --git a/apps/mobile/src/components/listitems/notebook/index.js b/apps/mobile/src/components/listitems/notebook/index.js
index fbc3c872b..4d6399249 100644
--- a/apps/mobile/src/components/listitems/notebook/index.js
+++ b/apps/mobile/src/components/listitems/notebook/index.js
@@ -2,10 +2,10 @@ import React from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { notesnook } from '../../../../e2e/test.ids';
-import { useTracked } from '../../../provider';
-import { useSettingStore } from '../../../provider/stores';
-import { eSendEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { useSettingStore } from '../../../stores/stores';
+import { eSendEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { getTotalNotes, history } from '../../../utils';
import { refreshNotesPage } from '../../../utils/events';
import { SIZE } from '../../../utils/size';
@@ -16,8 +16,7 @@ import Heading from '../../ui/typography/heading';
import Paragraph from '../../ui/typography/paragraph';
export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateBy }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const compactMode = settings.notebooksListMode === 'compact';
const topics = item.topics?.slice(0, 3) || [];
diff --git a/apps/mobile/src/components/listitems/notebook/wrapper.js b/apps/mobile/src/components/listitems/notebook/wrapper.js
index d9a4fe2f3..e26741643 100644
--- a/apps/mobile/src/components/listitems/notebook/wrapper.js
+++ b/apps/mobile/src/components/listitems/notebook/wrapper.js
@@ -1,8 +1,8 @@
import React from 'react';
import { NotebookItem } from '.';
-import { useSelectionStore } from '../../../provider/stores';
-import { eSendEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useSelectionStore } from '../../../stores/stores';
+import { eSendEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { history } from '../../../utils';
import { eOnNewTopicAdded, refreshNotesPage } from '../../../utils/events';
import SelectionWrapper from '../selection-wrapper';
diff --git a/apps/mobile/src/components/listitems/selectionwrapper/actionstrip.js b/apps/mobile/src/components/listitems/selectionwrapper/actionstrip.js
index 41d237c6e..6112bbcc8 100644
--- a/apps/mobile/src/components/listitems/selectionwrapper/actionstrip.js
+++ b/apps/mobile/src/components/listitems/selectionwrapper/actionstrip.js
@@ -2,15 +2,15 @@ import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
import Clipboard from '@react-native-clipboard/clipboard';
import Animated, { useValue } from 'react-native-reanimated';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import {
useMenuStore,
useNotebookStore,
useSelectionStore,
useTrashStore
-} from '../../../provider/stores';
-import { openVault, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+} from '../../../stores/stores';
+import { openVault, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { dWidth, getElevation, toTXT } from '../../../utils';
import { db } from '../../../utils/database';
import { deleteItems } from '../../../utils/functions';
@@ -19,8 +19,7 @@ import { Button } from '../../ui/button';
import { presentDialog } from '../../dialog/functions';
export const ActionStrip = ({ note, setActionStrip }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const selectionMode = useSelectionStore(state => state.selectionMode);
const setNotebooks = useNotebookStore(state => state.setNotebooks);
const setMenuPins = useMenuStore(state => state.setMenuPins);
diff --git a/apps/mobile/src/components/listitems/selectionwrapper/backfill.js b/apps/mobile/src/components/listitems/selectionwrapper/backfill.js
index 2302221cf..4f76ce772 100644
--- a/apps/mobile/src/components/listitems/selectionwrapper/backfill.js
+++ b/apps/mobile/src/components/listitems/selectionwrapper/backfill.js
@@ -1,12 +1,11 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { useEditorStore } from '../../../provider/stores';
+import { useThemeStore } from '../../../stores/theme';
+import { useEditorStore } from '../../../stores/stores';
import { hexToRGBA } from '../../../utils/color-scheme/utils';
export const Filler = ({ item, background }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const currentEditingNote = useEditorStore(state => state.currentEditingNote);
diff --git a/apps/mobile/src/components/listitems/selectionwrapper/index.js b/apps/mobile/src/components/listitems/selectionwrapper/index.js
index 340d35a90..10cd90070 100644
--- a/apps/mobile/src/components/listitems/selectionwrapper/index.js
+++ b/apps/mobile/src/components/listitems/selectionwrapper/index.js
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
-import { useTracked } from '../../../provider';
-import { useSettingStore } from '../../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/EventManager';
+import { useThemeStore } from '../../../stores/theme';
+import { useSettingStore } from '../../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
import { history } from '../../../utils';
import { PressableButton } from '../../ui/pressable';
import { ActionStrip } from './action-strip';
@@ -9,8 +9,7 @@ import { Filler } from './back-fill';
import { SelectionIcon } from './selection';
const SelectionWrapper = ({ children, item, background, onLongPress, onPress, testID }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [actionStrip, setActionStrip] = useState(false);
const settings = useSettingStore(state => state.settings);
const listMode = item.type === 'notebook' ? settings.notebooksListMode : settings.notesListMode;
diff --git a/apps/mobile/src/components/listitems/selectionwrapper/selection.js b/apps/mobile/src/components/listitems/selectionwrapper/selection.js
index 0f0572fa9..926a019dc 100644
--- a/apps/mobile/src/components/listitems/selectionwrapper/selection.js
+++ b/apps/mobile/src/components/listitems/selectionwrapper/selection.js
@@ -1,14 +1,13 @@
import React, { useEffect, useState } from 'react';
import { TouchableOpacity, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../provider';
-import { Actions } from '../../../provider/Actions';
-import { useSelectionStore } from '../../../provider/stores';
+import { useThemeStore } from '../../../stores/theme';
+import { Actions } from '../../../stores/Actions';
+import { useSelectionStore } from '../../../stores/stores';
import { SIZE } from '../../../utils/size';
export const SelectionIcon = ({ setActionStrip, item, compactMode }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const selectionMode = useSelectionStore(state => state.selectionMode);
const selectedItemsList = useSelectionStore(state => state.selectedItemsList);
diff --git a/apps/mobile/src/components/listitems/tag/index.js b/apps/mobile/src/components/listitems/tag/index.js
index 84ad3a2db..558e4bcf5 100644
--- a/apps/mobile/src/components/listitems/tag/index.js
+++ b/apps/mobile/src/components/listitems/tag/index.js
@@ -2,9 +2,9 @@ import React from 'react';
import { useWindowDimensions, View } from 'react-native';
import { notesnook } from '../../../../e2e/test.ids';
import { PressableButton } from '../../ui/pressable';
-import { useTracked } from '../../../provider';
-import { eSendEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { eSendEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { db } from '../../../utils/database';
import { refreshNotesPage } from '../../../utils/events';
import { SIZE } from '../../../utils/size';
@@ -15,8 +15,7 @@ import Paragraph from '../../ui/typography/paragraph';
const TagItem = React.memo(
({ item, index }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const { fontScale } = useWindowDimensions();
const onPress = () => {
let params = {
diff --git a/apps/mobile/src/components/mergeconflicts/index.js b/apps/mobile/src/components/mergeconflicts/index.js
index 17535c0b5..81d9cc35c 100644
--- a/apps/mobile/src/components/mergeconflicts/index.js
+++ b/apps/mobile/src/components/mergeconflicts/index.js
@@ -5,16 +5,16 @@ import { Modal, Platform, SafeAreaView, Text, View } from 'react-native';
import Animated from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import WebView from 'react-native-webview';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
+import { useThemeStore } from '../../stores/theme';
+import { DDS } from '../../services/device-detection';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent
-} from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import Sync from '../../services/Sync';
+} from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import Sync from '../../services/sync';
import { dHeight } from '../../utils';
import { db } from '../../utils/database';
import { eApplyChanges, eShowMergeDialog, refreshNotesPage } from '../../utils/events';
@@ -50,8 +50,7 @@ function onMediaLoaded({ hash, src }) {
}
const MergeConflicts = () => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [primary, setPrimary] = useState(true);
const [secondary, setSecondary] = useState(true);
diff --git a/apps/mobile/src/components/notehistory/index.js b/apps/mobile/src/components/notehistory/index.js
index eef1b0522..69b256529 100644
--- a/apps/mobile/src/components/notehistory/index.js
+++ b/apps/mobile/src/components/notehistory/index.js
@@ -2,8 +2,8 @@ import React, { useCallback, useEffect, useState } from 'react';
import { Text, View } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { presentSheet } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { presentSheet } from '../../services/event-manager';
import { db } from '../../utils/database';
import { openLinkInBrowser } from '../../utils/functions';
import { SIZE } from '../../utils/size';
@@ -18,8 +18,7 @@ import NotePreview from './preview';
export default function NoteHistory({ note, ref }) {
const [history, setHistory] = useState([]);
const [loading, setLoading] = useState(true);
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
useEffect(() => {
(async () => {
diff --git a/apps/mobile/src/components/notehistory/preview.js b/apps/mobile/src/components/notehistory/preview.js
index 4ad1a5175..a6706aca4 100644
--- a/apps/mobile/src/components/notehistory/preview.js
+++ b/apps/mobile/src/components/notehistory/preview.js
@@ -1,10 +1,10 @@
import React, { useRef } from 'react';
import { Alert, Platform, View } from 'react-native';
import WebView from 'react-native-webview';
-import { useTracked } from '../../provider';
-import { useEditorStore } from '../../provider/stores';
-import { eSendEvent, ToastEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { useEditorStore } from '../../stores/stores';
+import { eSendEvent, ToastEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { db } from '../../utils/database';
import { eCloseProgressDialog, eOnLoadNote } from '../../utils/events';
import { openLinkInBrowser } from '../../utils/functions';
@@ -17,8 +17,7 @@ import DialogHeader from '../dialog/dialog-header';
import Paragraph from '../ui/typography/paragraph';
export default function NotePreview({ session, content }) {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const webviewRef = useRef();
const onLoad = async () => {
diff --git a/apps/mobile/src/components/premium/component.js b/apps/mobile/src/components/premium/component.js
index 69f691525..f6cf14cc7 100644
--- a/apps/mobile/src/components/premium/component.js
+++ b/apps/mobile/src/components/premium/component.js
@@ -1,11 +1,11 @@
import React, { useState } from 'react';
import { ScrollView, View } from 'react-native';
import { LAUNCH_ROCKET } from '../../assets/images/assets';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, presentSheet } from '../../services/EventManager';
-import PremiumService from '../../services/PremiumService';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent, presentSheet } from '../../services/event-manager';
+import PremiumService from '../../services/premium';
import { getElevation } from '../../utils';
import { db } from '../../utils/database';
import {
@@ -32,8 +32,7 @@ import { Group } from './group';
import { PricingPlans } from './pricing-plans';
export const Component = ({ close, promo, getRef }) => {
- const [state, dispatch] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const user = useUserStore(state => state.user);
const userCanRequestTrial =
user && (!user.subscription || !user.subscription.expiry) ? true : false;
diff --git a/apps/mobile/src/components/premium/expiring.js b/apps/mobile/src/components/premium/expiring.js
index 387ef152f..8a6e5a0a5 100644
--- a/apps/mobile/src/components/premium/expiring.js
+++ b/apps/mobile/src/components/premium/expiring.js
@@ -1,8 +1,8 @@
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import PremiumService from '../../services/PremiumService';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import PremiumService from '../../services/premium';
import { eOpenPremiumDialog, eOpenResultDialog, eOpenTrialEndingDialog } from '../../utils/events';
import { SIZE } from '../../utils/size';
import { sleep } from '../../utils/time';
@@ -16,8 +16,7 @@ import { CompactFeatures } from './compact-features';
import { Offer } from './offer';
export const Expiring = () => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [status, setStatus] = useState({
title: 'Your trial is ending soon',
diff --git a/apps/mobile/src/components/premium/feature.js b/apps/mobile/src/components/premium/feature.js
index b027440ed..6716d751b 100644
--- a/apps/mobile/src/components/premium/feature.js
+++ b/apps/mobile/src/components/premium/feature.js
@@ -1,14 +1,13 @@
import React from 'react';
import { Text, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import Paragraph from '../ui/typography/paragraph';
import { ProTag } from './pro-tag';
export const FeatureBlock = ({ vertical, highlight, content, icon, pro, proTagBg }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return vertical ? (
<View
diff --git a/apps/mobile/src/components/premium/group.js b/apps/mobile/src/components/premium/group.js
index 880b1a5b0..809946be2 100644
--- a/apps/mobile/src/components/premium/group.js
+++ b/apps/mobile/src/components/premium/group.js
@@ -1,6 +1,6 @@
import React from 'react';
import { ScrollView, View } from 'react-native';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
@@ -8,8 +8,7 @@ import { FeatureBlock } from './feature';
import { ProTag } from './pro-tag';
export const Group = ({ item, index }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<View
diff --git a/apps/mobile/src/components/premium/index.js b/apps/mobile/src/components/premium/index.js
index f123af249..ad02a1cb0 100644
--- a/apps/mobile/src/components/premium/index.js
+++ b/apps/mobile/src/components/premium/index.js
@@ -1,5 +1,5 @@
import React, { createRef } from 'react';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { eClosePremiumDialog, eOpenPremiumDialog } from '../../utils/events';
import BaseDialog from '../dialog/base-dialog';
import { Component } from './component';
diff --git a/apps/mobile/src/components/premium/offer.js b/apps/mobile/src/components/premium/offer.js
index 61bbb85f8..be0144000 100644
--- a/apps/mobile/src/components/premium/offer.js
+++ b/apps/mobile/src/components/premium/offer.js
@@ -1,12 +1,11 @@
import React from 'react';
import { Text } from 'react-native';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import Paragraph from '../ui/typography/paragraph';
export const Offer = ({ off = '30', text = 'on yearly plan, offer ends soon', padding = 0 }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<Paragraph
diff --git a/apps/mobile/src/components/premium/premiumtoast.js b/apps/mobile/src/components/premium/premiumtoast.js
index ca9669b9f..7a619e6f6 100644
--- a/apps/mobile/src/components/premium/premiumtoast.js
+++ b/apps/mobile/src/components/premium/premiumtoast.js
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
import Animated, { Easing } from 'react-native-reanimated';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { dWidth, editing, getElevation } from '../../utils';
import { eCloseActionSheet, eOpenPremiumDialog, eShowGetPremium } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -22,8 +22,7 @@ let currentMsg = {
desc: ''
};
export const PremiumToast = ({ close, context = 'global', offset = 0 }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [msg, setMsg] = useState(currentMsg);
const open = event => {
diff --git a/apps/mobile/src/components/premium/pricingitem.js b/apps/mobile/src/components/premium/pricingitem.js
index b9a42ebbf..e10ec5e5f 100644
--- a/apps/mobile/src/components/premium/pricingitem.js
+++ b/apps/mobile/src/components/premium/pricingitem.js
@@ -1,6 +1,6 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { getElevation } from '../../utils';
import { SIZE } from '../../utils/size';
import { PressableButton } from '../ui/pressable';
@@ -8,8 +8,7 @@ import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
export const PricingItem = ({ product, onPress, compact }) => {
- const [state, dispatch] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<PressableButton
diff --git a/apps/mobile/src/components/premium/pricingplans.js b/apps/mobile/src/components/premium/pricingplans.js
index 207f2529f..fa3090220 100644
--- a/apps/mobile/src/components/premium/pricingplans.js
+++ b/apps/mobile/src/components/premium/pricingplans.js
@@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react';
import { ActivityIndicator, Platform, Text, View } from 'react-native';
import * as RNIap from 'react-native-iap';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';
-import PremiumService from '../../services/PremiumService';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
+import PremiumService from '../../services/premium';
import { db } from '../../utils/database';
import {
eClosePremiumDialog,
@@ -45,8 +45,7 @@ export const PricingPlans = ({
trial = false,
showTrialOption = true
}) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const user = useUserStore(state => state.user);
const [product, setProduct] = useState(null);
const [products, setProducts] = useState([]);
diff --git a/apps/mobile/src/components/premium/protag.js b/apps/mobile/src/components/premium/protag.js
index 9d277eb7f..c4ad010a3 100644
--- a/apps/mobile/src/components/premium/protag.js
+++ b/apps/mobile/src/components/premium/protag.js
@@ -1,12 +1,11 @@
import React from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import Paragraph from '../ui/typography/paragraph';
export const ProTag = ({ width, size, background }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
return (
<View
diff --git a/apps/mobile/src/components/properties/colortags.js b/apps/mobile/src/components/properties/colortags.js
index 4a2a09752..d0ed388d0 100644
--- a/apps/mobile/src/components/properties/colortags.js
+++ b/apps/mobile/src/components/properties/colortags.js
@@ -2,10 +2,10 @@ import React, { useState } from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { notesnook } from '../../../e2e/test.ids';
-import { useMenuStore, useSettingStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useMenuStore, useSettingStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { dWidth } from '../../utils';
import { COLORS_NOTE } from '../../utils/color-scheme';
import { db } from '../../utils/database';
diff --git a/apps/mobile/src/components/properties/datemeta.js b/apps/mobile/src/components/properties/datemeta.js
index da0e4067f..b41b4399b 100644
--- a/apps/mobile/src/components/properties/datemeta.js
+++ b/apps/mobile/src/components/properties/datemeta.js
@@ -1,13 +1,12 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
import { timeConverter } from '../../utils/time';
import Paragraph from '../ui/typography/paragraph';
export const DateMeta = ({ item }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const getNameFromKey = key => {
switch (key) {
diff --git a/apps/mobile/src/components/properties/devmode.js b/apps/mobile/src/components/properties/devmode.js
index 74a11f3f9..950537af4 100644
--- a/apps/mobile/src/components/properties/devmode.js
+++ b/apps/mobile/src/components/properties/devmode.js
@@ -1,8 +1,8 @@
import Clipboard from '@react-native-clipboard/clipboard';
import React from 'react';
import { View } from 'react-native';
-import { useSettingStore } from '../../provider/stores';
-import { ToastEvent } from '../../services/EventManager';
+import { useSettingStore } from '../../stores/stores';
+import { ToastEvent } from '../../services/event-manager';
import { db } from '../../utils/database';
import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
diff --git a/apps/mobile/src/components/properties/index.js b/apps/mobile/src/components/properties/index.js
index 75ed079de..74c53c1b2 100644
--- a/apps/mobile/src/components/properties/index.js
+++ b/apps/mobile/src/components/properties/index.js
@@ -1,8 +1,8 @@
import React from 'react';
import { Platform, ScrollView, View } from 'react-native';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
-import { presentSheet } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { DDS } from '../../services/device-detection';
+import { presentSheet } from '../../services/event-manager';
import { db } from '../../utils/database';
import { SIZE } from '../../utils/size';
import Heading from '../ui/typography/heading';
@@ -17,8 +17,7 @@ import { Tags } from './tags';
import { Topics } from './topics';
export const Properties = ({ close = () => {}, item, buttons = [], getRef }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const alias = item
? item.type === 'tag'
diff --git a/apps/mobile/src/components/properties/items.js b/apps/mobile/src/components/properties/items.js
index cbffd4d61..c85133f9a 100644
--- a/apps/mobile/src/components/properties/items.js
+++ b/apps/mobile/src/components/properties/items.js
@@ -2,9 +2,9 @@ import React from 'react';
import { View } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
import { PressableButton } from '../ui/pressable';
@@ -12,8 +12,7 @@ import Paragraph from '../ui/typography/paragraph';
import { useActions } from '../../utils/hooks/use-actions';
export const Items = ({ item, buttons, close }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const dimensions = useSettingStore(state => state.dimensions);
const actions = useActions({ item, close });
const data = actions.filter(i => buttons.indexOf(i.name) > -1 && !i.hidden);
diff --git a/apps/mobile/src/components/properties/notebooks.js b/apps/mobile/src/components/properties/notebooks.js
index d7d3fb97f..47bdd3ceb 100644
--- a/apps/mobile/src/components/properties/notebooks.js
+++ b/apps/mobile/src/components/properties/notebooks.js
@@ -1,9 +1,9 @@
import React from 'react';
import { ScrollView, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { eSendEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { db } from '../../utils/database';
import { eOnNewTopicAdded, refreshNotesPage } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -12,8 +12,7 @@ import { PressableButton } from '../ui/pressable';
import Heading from '../ui/typography/heading';
export default function Notebooks({ note, close }) {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
function getNotebooks(item) {
if (!item.notebooks || item.notebooks.length < 1) return [];
diff --git a/apps/mobile/src/components/properties/synced.js b/apps/mobile/src/components/properties/synced.js
index 78dfd2b13..c4557a13c 100644
--- a/apps/mobile/src/components/properties/synced.js
+++ b/apps/mobile/src/components/properties/synced.js
@@ -1,8 +1,8 @@
import React from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
import { openLinkInBrowser } from '../../utils/functions';
import { SIZE } from '../../utils/size';
import { sleep } from '../../utils/time';
@@ -11,8 +11,7 @@ import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
export const Synced = ({ item, close }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const user = useUserStore(state => state.user);
const lastSynced = useUserStore(state => state.lastSynced);
diff --git a/apps/mobile/src/components/properties/tags.js b/apps/mobile/src/components/properties/tags.js
index 847769f6a..35c5a7d83 100644
--- a/apps/mobile/src/components/properties/tags.js
+++ b/apps/mobile/src/components/properties/tags.js
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSendEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { db } from '../../utils/database';
import { eOpenTagsDialog, refreshNotesPage } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -10,8 +10,7 @@ import { sleep } from '../../utils/time';
import { Button } from '../ui/button';
export const Tags = ({ item, close }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return item.id ? (
<View
diff --git a/apps/mobile/src/components/properties/topics.js b/apps/mobile/src/components/properties/topics.js
index ee079ee00..7cce9a4b4 100644
--- a/apps/mobile/src/components/properties/topics.js
+++ b/apps/mobile/src/components/properties/topics.js
@@ -1,7 +1,7 @@
import React from 'react';
import { View } from 'react-native';
-import { eSendEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { eSendEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { refreshNotesPage } from '../../utils/events';
import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
diff --git a/apps/mobile/src/components/selectionheader/index.js b/apps/mobile/src/components/selectionheader/index.js
index 9fa87792a..c2ef85d18 100644
--- a/apps/mobile/src/components/selectionheader/index.js
+++ b/apps/mobile/src/components/selectionheader/index.js
@@ -1,10 +1,10 @@
import React, { useEffect } from 'react';
import { BackHandler, Platform, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useTracked } from '../../provider';
-import { useSelectionStore } from '../../provider/stores';
-import { eSendEvent, ToastEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { useSelectionStore } from '../../stores/stores';
+import { eSendEvent, ToastEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { db } from '../../utils/database';
import { eOpenMoveNoteDialog, refreshNotesPage } from '../../utils/events';
import { deleteItems } from '../../utils/functions';
@@ -17,8 +17,7 @@ import { IconButton } from '../ui/icon-button';
import Heading from '../ui/typography/heading';
export const SelectionHeader = React.memo(({ screen, type, extras }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const selectionMode = useSelectionStore(state => state.selectionMode);
const selectedItemsList = useSelectionStore(state => state.selectedItemsList);
diff --git a/apps/mobile/src/components/sheetprovider/index.js b/apps/mobile/src/components/sheetprovider/index.js
index 5d5aa722c..a2ae95add 100644
--- a/apps/mobile/src/components/sheetprovider/index.js
+++ b/apps/mobile/src/components/sheetprovider/index.js
@@ -1,8 +1,8 @@
import React, { useEffect, useRef, useState } from 'react';
import { ActivityIndicator, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { editing } from '../../utils';
import { eCloseProgressDialog, eOpenProgressDialog } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -16,8 +16,7 @@ import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
const SheetProvider = ({ context = 'global' }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [dialogData, setDialogData] = useState(null);
const actionSheetRef = useRef();
diff --git a/apps/mobile/src/components/sheets/addnotebook/index.js b/apps/mobile/src/components/sheets/addnotebook/index.js
index a497304ae..8b6e28a08 100644
--- a/apps/mobile/src/components/sheets/addnotebook/index.js
+++ b/apps/mobile/src/components/sheets/addnotebook/index.js
@@ -2,10 +2,10 @@ import React, { createRef } from 'react';
import { Keyboard, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
import { notesnook } from '../../../../e2e/test.ids';
-import { useMenuStore } from '../../../provider/stores';
-import { DDS } from '../../../services/DeviceDetection';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useMenuStore } from '../../../stores/stores';
+import { DDS } from '../../../services/device-detection';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { db } from '../../../utils/database';
import { eCloseAddNotebookDialog, eOpenAddNotebookDialog } from '../../../utils/events';
import { ph, pv, SIZE } from '../../../utils/size';
diff --git a/apps/mobile/src/components/sheets/addto/index.js b/apps/mobile/src/components/sheets/addto/index.js
index 1d5e8150d..4a836e6d0 100644
--- a/apps/mobile/src/components/sheets/addto/index.js
+++ b/apps/mobile/src/components/sheets/addto/index.js
@@ -2,10 +2,10 @@ import React, { createRef, useEffect, useState } from 'react';
import { Keyboard, TouchableOpacity, View } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
import { notesnook } from '../../../../e2e/test.ids';
-import { useTracked } from '../../../provider';
-import { useNotebookStore, useSelectionStore } from '../../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { useNotebookStore, useSelectionStore } from '../../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { getTotalNotes } from '../../../utils';
import { db } from '../../../utils/database';
import { eOpenMoveNoteDialog } from '../../../utils/events';
@@ -72,8 +72,7 @@ const AddToNotebookSheet = () => {
export default AddToNotebookSheet;
const MoveNoteComponent = ({ close, note, setNote }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const notebooks = useNotebookStore(state => state.notebooks.filter(n => n?.type === 'notebook'));
diff --git a/apps/mobile/src/components/sheets/exportnotes/index.js b/apps/mobile/src/components/sheets/exportnotes/index.js
index 66a512b14..7a0a5624f 100644
--- a/apps/mobile/src/components/sheets/exportnotes/index.js
+++ b/apps/mobile/src/components/sheets/exportnotes/index.js
@@ -4,9 +4,9 @@ import FileViewer from 'react-native-file-viewer';
import Share from 'react-native-share';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { notesnook } from '../../../../e2e/test.ids';
-import { useTracked } from '../../../provider';
-import { ToastEvent } from '../../../services/EventManager';
-import Exporter from '../../../services/Exporter';
+import { useThemeStore } from '../../../stores/theme';
+import { ToastEvent } from '../../../services/event-manager';
+import Exporter from '../../../services/exporter';
import { getElevation } from '../../../utils';
import { ph, pv, SIZE } from '../../../utils/size';
import { sleep } from '../../../utils/time';
@@ -18,12 +18,11 @@ import Seperator from '../../ui/seperator';
import Heading from '../../ui/typography/heading';
import Paragraph from '../../ui/typography/paragraph';
-const { eSubscribeEvent, eUnSubscribeEvent } = require('../../../services/EventManager');
+const { eSubscribeEvent, eUnSubscribeEvent } = require('../../../services/eventmanager');
const { eOpenExportDialog, eCloseExportDialog } = require('../../../utils/events');
const ExportNotesSheet = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const actionSheetRef = useRef();
diff --git a/apps/mobile/src/components/sheets/exportnotes/share.js b/apps/mobile/src/components/sheets/exportnotes/share.js
index 319bd68a4..0e6d3fd30 100644
--- a/apps/mobile/src/components/sheets/exportnotes/share.js
+++ b/apps/mobile/src/components/sheets/exportnotes/share.js
@@ -2,7 +2,7 @@ import React from 'react';
import { View } from 'react-native';
import FileViewer from 'react-native-file-viewer';
import Share from 'react-native-share';
-import { ToastEvent } from '../../../services/EventManager';
+import { ToastEvent } from '../../../services/event-manager';
import { SIZE } from '../../../utils/size';
import { Button } from '../../ui/button';
diff --git a/apps/mobile/src/components/sheets/github/issue.js b/apps/mobile/src/components/sheets/github/issue.js
index d357766cc..bf90b8968 100644
--- a/apps/mobile/src/components/sheets/github/issue.js
+++ b/apps/mobile/src/components/sheets/github/issue.js
@@ -1,10 +1,10 @@
import Clipboard from '@react-native-clipboard/clipboard';
import React, { useRef, useState } from 'react';
import { Linking, Platform, Text, TextInput, View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { useUserStore } from '../../../provider/stores';
-import { eSendEvent, ToastEvent } from '../../../services/EventManager';
-import PremiumService from '../../../services/PremiumService';
+import { useThemeStore } from '../../../stores/theme';
+import { useUserStore } from '../../../stores/stores';
+import { eSendEvent, ToastEvent } from '../../../services/event-manager';
+import PremiumService from '../../../services/premium';
import { APP_VERSION } from '../../../../version';
import { db } from '../../../utils/database';
import { eCloseProgressDialog } from '../../../utils/events';
@@ -19,8 +19,7 @@ import Paragraph from '../../ui/typography/paragraph';
import deviceInfoModule from 'react-native-device-info';
export const Issue = () => {
- const [state, dispatch] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const body = useRef(null);
const title = useRef(null);
const user = useUserStore(state => state.user);
diff --git a/apps/mobile/src/components/sheets/managetags/index.js b/apps/mobile/src/components/sheets/managetags/index.js
index 951ea5900..203eb203b 100644
--- a/apps/mobile/src/components/sheets/managetags/index.js
+++ b/apps/mobile/src/components/sheets/managetags/index.js
@@ -1,10 +1,10 @@
import React, { useEffect, useRef, useState } from 'react';
import { ScrollView, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../provider';
-import { useTagStore } from '../../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { useTagStore } from '../../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { db } from '../../../utils/database';
import { eCloseTagsDialog, eOpenTagsDialog } from '../../../utils/events';
import { SIZE } from '../../../utils/size';
@@ -15,8 +15,7 @@ import SheetWrapper from '../../ui/sheet';
import Heading from '../../ui/typography/heading';
import Paragraph from '../../ui/typography/paragraph';
const ManageTagsSheet = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const [note, setNote] = useState(null);
const allTags = useTagStore(state => state.tags);
@@ -216,8 +215,7 @@ const ManageTagsSheet = () => {
export default ManageTagsSheet;
const TagItem = ({ tag, note, setNote }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const onPress = async () => {
let prevNote = { ...note };
diff --git a/apps/mobile/src/components/sheets/movenotes/movenote.tsx b/apps/mobile/src/components/sheets/movenotes/movenote.tsx
index 6cd745f9b..14e697323 100644
--- a/apps/mobile/src/components/sheets/movenotes/movenote.tsx
+++ b/apps/mobile/src/components/sheets/movenotes/movenote.tsx
@@ -2,9 +2,9 @@ import React, { RefObject, useState } from 'react';
import { View } from 'react-native';
import ActionSheet from 'react-native-actions-sheet';
import { FlatList } from 'react-native-gesture-handler';
-import { useTracked } from '../../../provider';
-import { eSendEvent, presentSheet, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { eSendEvent, presentSheet, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { db } from '../../../utils/database';
import { eCloseProgressDialog } from '../../../utils/events';
import { SIZE } from '../../../utils/size';
@@ -27,8 +27,7 @@ export const MoveNotes = ({
selectedTopic?: any;
fwdRef: RefObject<ActionSheet>;
}) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [currentNotebook, setCurrentNotebook] = useState(notebook);
let notes = db.notes?.all;
diff --git a/apps/mobile/src/components/sheets/publishnote/index.js b/apps/mobile/src/components/sheets/publishnote/index.js
index 7caa94d4b..c9ebdb311 100644
--- a/apps/mobile/src/components/sheets/publishnote/index.js
+++ b/apps/mobile/src/components/sheets/publishnote/index.js
@@ -2,10 +2,10 @@ import Clipboard from '@react-native-clipboard/clipboard';
import React, { useEffect, useRef, useState } from 'react';
import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../provider';
-import { useAttachmentStore } from '../../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { useAttachmentStore } from '../../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { db } from '../../../utils/database';
import { eClosePublishNoteDialog, eOpenPublishNoteDialog } from '../../../utils/events';
import { openLinkInBrowser } from '../../../utils/functions';
@@ -21,8 +21,7 @@ import Paragraph from '../../ui/typography/paragraph';
let passwordValue = null;
const PublishNoteSheet = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
const actionSheetRef = useRef();
const loading = useAttachmentStore(state => state.loading);
diff --git a/apps/mobile/src/components/sheets/rateapp/index.js b/apps/mobile/src/components/sheets/rateapp/index.js
index 0115cc05d..b618974f2 100644
--- a/apps/mobile/src/components/sheets/rateapp/index.js
+++ b/apps/mobile/src/components/sheets/rateapp/index.js
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { Linking, Platform, View } from 'react-native';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/EventManager';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
import { eCloseRateDialog, eOpenRateDialog } from '../../../utils/events';
import { MMKV } from '../../../utils/database/mmkv';
import { SIZE } from '../../../utils/size';
@@ -10,7 +10,7 @@ import Seperator from '../../ui/seperator';
import Heading from '../../ui/typography/heading';
import Paragraph from '../../ui/typography/paragraph';
import { STORE_LINK } from '../../../utils/constants';
-import { clearMessage } from '../../../services/Message';
+import { clearMessage } from '../../../services/message';
const RateAppSheet = () => {
const [visible, setVisible] = useState(false);
diff --git a/apps/mobile/src/components/sheets/recoverykey/index.js b/apps/mobile/src/components/sheets/recoverykey/index.js
index 594034027..f2ef5eab0 100644
--- a/apps/mobile/src/components/sheets/recoverykey/index.js
+++ b/apps/mobile/src/components/sheets/recoverykey/index.js
@@ -6,8 +6,8 @@ import QRCode from 'react-native-qrcode-svg';
import * as ScopedStorage from 'react-native-scoped-storage';
import Share from 'react-native-share';
import { LOGO_BASE64 } from '../../../assets/images/assets';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/EventManager';
-import { clearMessage } from '../../../services/Message';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
+import { clearMessage } from '../../../services/message';
import { db } from '../../../utils/database';
import { eOpenRecoveryKeyDialog } from '../../../utils/events';
import { MMKV } from '../../../utils/database/mmkv';
diff --git a/apps/mobile/src/components/sheets/restoredata/index.js b/apps/mobile/src/components/sheets/restoredata/index.js
index 59a99874f..7fe70e775 100644
--- a/apps/mobile/src/components/sheets/restoredata/index.js
+++ b/apps/mobile/src/components/sheets/restoredata/index.js
@@ -3,9 +3,9 @@ import { ActivityIndicator, Platform, View } from 'react-native';
import DocumentPicker from 'react-native-document-picker';
import { FlatList } from 'react-native-gesture-handler';
import * as ScopedStorage from 'react-native-scoped-storage';
-import { useTracked } from '../../../provider';
-import { initialize } from '../../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/EventManager';
+import { useThemeStore } from '../../../stores/theme';
+import { initialize } from '../../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
import { db } from '../../../utils/database';
import { MMKV } from '../../../utils/database/mmkv';
import storage from '../../../utils/database/storage';
@@ -77,8 +77,7 @@ const RestoreDataSheet = () => {
export default RestoreDataSheet;
const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [files, setFiles] = useState([]);
const [loading, setLoading] = useState(true);
const [backupDirectoryAndroid, setBackupDirectoryAndroid] = useState(false);
diff --git a/apps/mobile/src/components/sheets/sort/index.js b/apps/mobile/src/components/sheets/sort/index.js
index 0cec7cae1..d3154611d 100644
--- a/apps/mobile/src/components/sheets/sort/index.js
+++ b/apps/mobile/src/components/sheets/sort/index.js
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../../provider';
-import { eSendEvent } from '../../../services/EventManager';
-import Navigation from '../../../services/Navigation';
+import { useThemeStore } from '../../../stores/theme';
+import { eSendEvent } from '../../../services/event-manager';
+import Navigation from '../../../services/navigation';
import { GROUP, SORT } from '../../../utils/constants';
import { db } from '../../../utils/database';
import { refreshNotesPage } from '../../../utils/events';
@@ -13,8 +13,7 @@ import Seperator from '../../ui/seperator';
import Heading from '../../ui/typography/heading';
const Sort = ({ type, screen }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [groupOptions, setGroupOptions] = useState(db.settings.getGroupOptions(type));
const updateGroupOptions = async _groupOptions => {
diff --git a/apps/mobile/src/components/sheets/update/index.js b/apps/mobile/src/components/sheets/update/index.js
index e9ac81199..69fd651aa 100644
--- a/apps/mobile/src/components/sheets/update/index.js
+++ b/apps/mobile/src/components/sheets/update/index.js
@@ -1,7 +1,7 @@
import React from 'react';
import { Linking, View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import { STORE_LINK } from '../../../utils/constants';
import { SIZE } from '../../../utils/size';
import { Button } from '../../ui/button';
@@ -14,8 +14,7 @@ const UPDATE_SVG = color =>
`<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="774" height="669.5" viewBox="0 0 774 669.5" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M938.2145,322.3829C936.73266,207.5841,878.16775,115.25,806.13079,115.25c-43.29082,0-81.71777,33.346-105.81477,84.87331l28.33157,71.08654-39.15446-43.81576c-9.876,29.64743-15.48115,63.49569-15.48115,99.44475a324.20917,324.20917,0,0,0,9.98686,80.80891l75.92761-12.24058-67.9507,37.99628c22.13728,60.69069,62.59851,102.1414,109.23586,104.87608l-8.988,244.5184,27.81449.99338-5.94527-245.75716c66.41162-6.32443,119.60967-91.20375,123.8712-197.42794l-45.89372-25.66252Z" transform="translate(-213 -115.25)" fill="#f0f0f0"/><rect x="157.51532" y="354.40187" width="6.60151" height="49.25266" fill="${color}"/><polygon points="187.815 376.276 182.98 380.779 160.823 356.936 138.658 380.779 133.823 376.276 160.823 347.243 187.815 376.276" fill="${color}"/><path d="M371.9876,543.6602a52.8121,52.8121,0,1,1,52.8121-52.81209A52.87183,52.87183,0,0,1,371.9876,543.6602Zm0-99.02268a46.21059,46.21059,0,1,0,46.21058,46.21059A46.26275,46.26275,0,0,0,371.9876,444.63752Z" transform="translate(-213 -115.25)" fill="${color}"/><rect x="212.75248" y="253.9314" width="3.63974" height="27.15545" fill="#e4e4e4"/><polygon points="229.458 265.992 226.793 268.475 214.576 255.328 202.356 268.475 199.69 265.992 214.576 249.984 229.458 265.992" fill="#e4e4e4"/><path d="M426.56422,409.9859a29.118,29.118,0,1,1,29.118-29.118A29.15089,29.15089,0,0,1,426.56422,409.9859Zm0-54.59616A25.47821,25.47821,0,1,0,452.04243,380.868,25.507,25.507,0,0,0,426.56422,355.38974Z" transform="translate(-213 -115.25)" fill="#e4e4e4"/><rect x="99.52274" y="186.73872" width="3.63974" height="27.15545" fill="#e4e4e4"/><polygon points="116.229 198.799 113.563 201.282 101.346 188.136 89.126 201.282 86.46 198.799 101.346 182.792 116.229 198.799" fill="#e4e4e4"/><path d="M313.33448,342.79321a29.118,29.118,0,1,1,29.118-29.118A29.15088,29.15088,0,0,1,313.33448,342.79321Zm0-54.59615a25.47821,25.47821,0,1,0,25.47821,25.4782A25.507,25.507,0,0,0,313.33448,288.19706Z" transform="translate(-213 -115.25)" fill="#e4e4e4"/><path d="M518.7325,635.91942a8.22484,8.22484,0,0,1,.958-12.302,9.56322,9.56322,0,0,1,1.26081-.83521l-6.99347-30.13439,16.26512,5.84042,4.14749,27.72073a8.21849,8.21849,0,0,1-2.21462,10.58849A10.12952,10.12952,0,0,1,518.7325,635.91942Z" transform="translate(-213 -115.25)" fill="#ffb8b8"/><path d="M516.88531,612.40706l-.08727-.29605c-8.79267-29.805-17.88169-60.6154-28.97824-94.16236l-.0728-.21977.2448-.13088c6.18493-3.30762,15.48114-3.08736,21.62358.51183,5.68293,3.33,8.55569,9.77159,7.0024,15.68347l8.09328,38.67327c3.29039,12.64158,6.69574,25.72668,9.95036,38.62892l.09229.36576-.504.0295c-5.92592.34536-12.04821.70254-16.95322.89973Z" transform="translate(-213 -115.25)" fill="#ccc"/><polygon points="229.16 657.57 217.627 657.57 212.138 616.801 229.16 616.801 229.16 657.57" fill="#ffb8b8"/><path d="M445.10175,783.06559H407.9141v-.43107c0-7.31472,6.49345-13.26551,14.47493-13.26551h22.71272Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><polygon points="337.837 648.851 326.848 652.06 308.113 614.743 324.331 610.006 337.837 648.851" fill="#ffb8b8"/><path d="M521.60173,783.39141l-.14262-.41086c-2.42325-6.96953,1.79234-14.4459,9.39693-16.66692l21.64062-6.31955,4.53736,13.05Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><ellipse cx="279.46347" cy="354.21043" rx="23.10522" ry="21.17504" fill="#ffb8b8"/><path d="M502.83713,465.536c.13132-8.54065-3.76885-16.99907-9.79916-21.25171a16.77762,16.77762,0,0,0-19.87954.322c-5.937,4.44645-9.65428,13.02823-9.33974,21.56167C477.12124,466.20257,490.42379,466.23726,502.83713,465.536Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M448.74454,759.69687l-.46255-.04125c-10.03358-.90255-20.40891-1.83457-30.21419-1.9415l-.5333-.00589.07281-.48411c2.32311-15.42,3.30793-31.45044,4.26037-46.9538.9405-15.308,1.91269-31.13682,4.17769-46.17039.95818-4.0257,1.892-8.00342,2.82264-11.96682,7.70037-32.79837,14.97378-63.77816,29.98728-94.44433l.14194-.28963.34381.03789c14.08679,1.56221,27.62283,6.27241,38.11391,13.26256l.20326.13513-.00988.23027a131.25944,131.25944,0,0,0-.10174,14.17269,44.82523,44.82523,0,0,1,7.48241,42.489c4.13084,12.65215,8.40154,25.73075,12.75907,38.63212,10.5818,26.587,21.53153,54.10056,32.75594,81.99045l.1842.45717-.51791.11114c-8.07587,1.73775-16.40668,3.52938-24.62518,4.22482l-.31028.0261-.14745-.25174a587.30717,587.30717,0,0,1-50.88262-112.12662c-2.80473,7.83882-6.84508,14.91443-10.75934,21.76819a157.11556,157.11556,0,0,0-9.86087,19.31354c-1.73239,13.0365-2.192,27.16078-2.63591,40.81947-.42007,12.91442-.81671,25.11236-2.19312,36.582Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M484.57528,444.67592c10.01507-1.97751,21.093-.09617,28.95819,6.09651s11.85919,16.9058,8.62805,26.09364-14.20114,15.65236-24.12,13.27969c2.84131-7.33881-.35623-16.34918-7.302-20.57639C482.50242,464.55626,480.23475,452.58775,484.57528,444.67592Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M496.73471,571.62025l-.36633-.15281c-12.77629-5.34207-25.30408-9.441-37.04181-13.18089l-.35989-.07114-.00092-.95644.23358.07451c.04915-.09935.1045-.21217.16008-.32456.16031-.325.26963-.54642.36264-.69292l-.00252-.00126c.97862-1.82742,1.75651-3.59337,2.50868-5.30123.77628-1.76259,1.5776-3.58243,2.61295-5.50793a15.68833,15.68833,0,0,1-4.02289-17.95719c2.593-5.63211,9.20424-10.01859,16.15083-10.74644,2.54543-6.42185,8.21712-19.91552,8.21712-19.91552s11.92674-.30015,16.72316-.85793l.08062-.00926.07923.016c10.4711,2.10273,19.213,11.1834,21.25846,22.08265,1.72665,9.199-.89525,19.721-7.38227,29.62807A128.7532,128.7532,0,0,1,504.93,561.61682c-2.92186,3.34837-5.68157,6.51067-7.97367,9.69571Z" transform="translate(-213 -115.25)" fill="#ccc"/><path d="M519.3919,459.10521v0Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M519.861,457.22412c-7.01076-.95907-12.51527-7.52688-11.71835-13.982s7.76344-11.72977,14.83079-11.22907,13.06654,6.694,12.77147,13.18459S528.81221,458.44864,519.861,457.22412Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M518.76646,453.03852c-7.01067-.95906-12.51516-7.52688-11.71821-13.98194.54524-4.41578,3.9788-8.27657,8.35539-10.11667-5.65378,1.13408-10.51956,5.64916-11.17757,10.97881-.79695,6.45506,4.70754,13.02288,11.71821,13.98195a14.465,14.465,0,0,0,7.6875-.98538A14.866,14.866,0,0,1,518.76646,453.03852Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M382.77632,566.82181a9.99626,9.99626,0,0,1,12.97554-3.271,9.61149,9.61149,0,0,1,1.27935.81118l28.67233-16.08336-.58936,16.00057-27.13738,12.82a10.15042,10.15042,0,0,1-11.63139,1.61428A8.34216,8.34216,0,0,1,382.77632,566.82181Z" transform="translate(-213 -115.25)" fill="#ffb8b8"/><path d="M406.35053,557.3917l.2755-.17406c27.73394-17.52829,56.40359-35.64765,87.2197-56.41349l.20185-.13613.21621.16792c5.46363,4.24233,8.33439,12.34854,6.67808,18.85539-1.5324,6.02009-7.20243,10.64869-13.80215,11.27624L450.049,550.84631c-11.90943,7.05521-24.23685,14.35751-36.42636,21.46865l-.34555.20162-.19828-.42571c-2.32974-5.0055-4.73707-10.17674-6.57422-14.34943Z" transform="translate(-213 -115.25)" fill="#ccc"/><path d="M986,784.75H214a1,1,0,0,1,0-2H986a1,1,0,0,1,0,2Z" transform="translate(-213 -115.25)" fill="#cacaca"/></svg>`;
export const Update = ({ version, fwdRef }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
let notes = version.notes
? version.notes.replace('Thank you for using Notesnook!', '').split('- ')
: ['Bug fixes and performance improvements'];
diff --git a/apps/mobile/src/components/sidemenu/colorsection.js b/apps/mobile/src/components/sidemenu/colorsection.js
index c872fd45d..7eecaaae8 100644
--- a/apps/mobile/src/components/sidemenu/colorsection.js
+++ b/apps/mobile/src/components/sidemenu/colorsection.js
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { useMenuStore, useNoteStore } from '../../provider/stores';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { useMenuStore, useNoteStore } from '../../stores/stores';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { COLORS_NOTE } from '../../utils/color-scheme';
import { db } from '../../utils/database';
import { refreshNotesPage } from '../../utils/events';
@@ -32,8 +32,7 @@ export const ColorSection = () => {
const ColorItem = React.memo(
({ item, index, alias }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const setColorNotes = useMenuStore(state => state.setColorNotes);
const [headerTextState, setHeaderTextState] = useState(null);
alias = db.colors.alias(item.id);
diff --git a/apps/mobile/src/components/sidemenu/index.js b/apps/mobile/src/components/sidemenu/index.js
index 5c1e9a47b..34a2924dd 100644
--- a/apps/mobile/src/components/sidemenu/index.js
+++ b/apps/mobile/src/components/sidemenu/index.js
@@ -2,12 +2,12 @@ import React, { useCallback } from 'react';
import { FlatList, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { notesnook } from '../../../e2e/test.ids';
-import { useTracked } from '../../provider';
-import { Actions } from '../../provider/Actions';
-import { useSettingStore, useUserStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent } from '../../services/EventManager';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { Actions } from '../../stores/Actions';
+import { useSettingStore, useUserStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent } from '../../services/event-manager';
+import SettingsService from '../../services/settings';
import {
ACCENT,
COLOR_SCHEME,
@@ -27,8 +27,7 @@ import { UserStatus } from './user-status';
export const SideMenu = React.memo(
() => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const deviceMode = useSettingStore(state => state.deviceMode);
const insets = useSafeAreaInsets();
const user = useUserStore(state => state.user);
@@ -36,7 +35,7 @@ export const SideMenu = React.memo(
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent);
- dispatch({ type: Actions.THEME, colors: newColors });
+ useThemeStore.getState().setColors({ ...newColors });
}
const BottomItemsList = [
diff --git a/apps/mobile/src/components/sidemenu/menuitem.js b/apps/mobile/src/components/sidemenu/menuitem.js
index 78f2b8919..28f310433 100644
--- a/apps/mobile/src/components/sidemenu/menuitem.js
+++ b/apps/mobile/src/components/sidemenu/menuitem.js
@@ -2,9 +2,9 @@ import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import ToggleSwitch from 'toggle-switch-react-native';
-import { useTracked } from '../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { normalize, SIZE } from '../../utils/size';
import { Button } from '../ui/button';
import { PressableButton } from '../ui/pressable';
@@ -13,8 +13,7 @@ import Paragraph from '../ui/typography/paragraph';
export const MenuItem = React.memo(
({ item, index, testID, rightBtn }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [headerTextState, setHeaderTextState] = useState(null);
let isFocused = headerTextState?.id === item.name.toLowerCase() + '_navigation';
diff --git a/apps/mobile/src/components/sidemenu/pinnedsection.js b/apps/mobile/src/components/sidemenu/pinnedsection.js
index 7da4934fa..4c48f2879 100644
--- a/apps/mobile/src/components/sidemenu/pinnedsection.js
+++ b/apps/mobile/src/components/sidemenu/pinnedsection.js
@@ -1,10 +1,10 @@
import React, { useEffect, useRef, useState } from 'react';
import { FlatList, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { useMenuStore, useNoteStore } from '../../provider/stores';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { useMenuStore, useNoteStore } from '../../stores/stores';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { db } from '../../utils/database';
import { eOnNewTopicAdded, refreshNotesPage } from '../../utils/events';
import { normalize, SIZE } from '../../utils/size';
@@ -102,8 +102,7 @@ export const TagsSection = () => {
export const PinItem = React.memo(
({ item, index, onPress, placeholder, alias }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const setMenuPins = useMenuStore(state => state.setMenuPins);
alias = item.type === 'tag' ? db.tags.alias(item.title) : item.title;
const [visible, setVisible] = useState(false);
diff --git a/apps/mobile/src/components/sidemenu/userstatus.js b/apps/mobile/src/components/sidemenu/userstatus.js
index 6c25015f3..22846c817 100644
--- a/apps/mobile/src/components/sidemenu/userstatus.js
+++ b/apps/mobile/src/components/sidemenu/userstatus.js
@@ -2,10 +2,10 @@ import React from 'react';
import { ActivityIndicator, Platform, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { eSendEvent } from '../../services/EventManager';
-import Sync from '../../services/Sync';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { eSendEvent } from '../../services/event-manager';
+import Sync from '../../services/sync';
import { eOpenLoginDialog } from '../../utils/events';
import { SIZE } from '../../utils/size';
import { PressableButton } from '../ui/pressable';
@@ -14,8 +14,7 @@ import Paragraph from '../ui/typography/paragraph';
import { TimeSince } from '../ui/time-since';
export const UserStatus = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const user = useUserStore(state => state.user);
const syncing = useUserStore(state => state.syncing);
const lastSynced = useUserStore(state => state.lastSynced);
diff --git a/apps/mobile/src/components/tabs/index.js b/apps/mobile/src/components/tabs/index.js
index ac3c7e918..9f56b4a4a 100644
--- a/apps/mobile/src/components/tabs/index.js
+++ b/apps/mobile/src/components/tabs/index.js
@@ -2,7 +2,7 @@ import React, { Component, createRef } from 'react';
import { Platform } from 'react-native';
import { Keyboard } from 'react-native';
import { FlatList, TextInput, View } from 'react-native';
-import { DDS } from '../../services/DeviceDetection';
+import { DDS } from '../../services/device-detection';
import { editing } from '../../utils';
export default class Tabs extends Component {
diff --git a/apps/mobile/src/components/tip/index.tsx b/apps/mobile/src/components/tip/index.tsx
index c5bfb4172..baafac2db 100644
--- a/apps/mobile/src/components/tip/index.tsx
+++ b/apps/mobile/src/components/tip/index.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { Image, TextStyle, View, ViewStyle } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSendEvent, presentSheet } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, presentSheet } from '../../services/event-manager';
import { TTip } from '../../services/tip-manager';
import { eCloseProgressDialog } from '../../utils/events';
import { MMKV } from '../../utils/database/mmkv';
@@ -9,7 +9,7 @@ import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
import Seperator from '../ui/seperator';
import Paragraph from '../ui/typography/paragraph';
-import { defaultState } from '../../provider/DefaultState';
+import { defaultState } from '../../stores/DefaultState';
export const Tip = ({
tip,
@@ -26,8 +26,7 @@ export const Tip = ({
noImage?: boolean;
color?: keyof typeof defaultState['colors'];
}) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return tip ? (
<View
diff --git a/apps/mobile/src/components/toast/index.js b/apps/mobile/src/components/toast/index.js
index 712015359..9526011cc 100644
--- a/apps/mobile/src/components/toast/index.js
+++ b/apps/mobile/src/components/toast/index.js
@@ -4,9 +4,9 @@ import Animated, { Easing, useValue } from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { notesnook } from '../../../e2e/test.ids';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { DDS } from '../../services/device-detection';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { dHeight, getElevation } from '../../utils';
import { eHideToast, eShowToast } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -18,8 +18,7 @@ const { timing } = Animated;
let toastMessages = [];
export const Toast = ({ context = 'global' }) => {
- const [state, dispatch] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [keyboard, setKeyboard] = useState(false);
const [data, setData] = useState({});
const [toastStyle, setToastStyle] = useState({
diff --git a/apps/mobile/src/components/ui/button/index.tsx b/apps/mobile/src/components/ui/button/index.tsx
index d31904bdb..c33116efd 100644
--- a/apps/mobile/src/components/ui/button/index.tsx
+++ b/apps/mobile/src/components/ui/button/index.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { ActivityIndicator, ColorValue, TextStyle } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import { showTooltip, TOOLTIP_POSITIONS } from '../../../utils';
import { BUTTON_TYPES } from '../../../utils/constants';
import { SIZE } from '../../../utils/size';
@@ -53,8 +53,7 @@ export const Button = ({
fwdRef,
...restProps
}: ButtonProps) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const textColor = buttonType?.text
? buttonType.text
diff --git a/apps/mobile/src/components/ui/iconbutton/index.tsx b/apps/mobile/src/components/ui/iconbutton/index.tsx
index 8ad6c5123..e66d2836a 100644
--- a/apps/mobile/src/components/ui/iconbutton/index.tsx
+++ b/apps/mobile/src/components/ui/iconbutton/index.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { ColorValue, GestureResponderEvent, ViewStyle } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import { showTooltip, TOOLTIP_POSITIONS } from '../../../utils';
import { hexToRGBA, RGB_Linear_Shade } from '../../../utils/color-scheme/utils';
import { SIZE } from '../../../utils/size';
@@ -39,8 +39,7 @@ export const IconButton = ({
tooltipPosition = TOOLTIP_POSITIONS.TOP,
...restProps
}: IconButtonProps) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const _onLongPress = (event: GestureResponderEvent) => {
if (onLongPress) {
diff --git a/apps/mobile/src/components/ui/input/index.tsx b/apps/mobile/src/components/ui/input/index.tsx
index dd15b72f0..92b35d659 100644
--- a/apps/mobile/src/components/ui/input/index.tsx
+++ b/apps/mobile/src/components/ui/input/index.tsx
@@ -10,13 +10,13 @@ import {
} from 'react-native';
import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../provider/index';
+import { useThemeStore } from '../../../stores/theme';
import {
ERRORS_LIST,
validateEmail,
validatePass,
validateUsername
-} from '../../../services/Validation';
+} from '../../../services/validation';
import { getElevation } from '../../../utils';
import { SIZE } from '../../../utils/size';
import { IconButton } from '../icon-button';
@@ -74,8 +74,7 @@ const Input = ({
containerStyle = {},
...restProps
}: InputProps) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [error, setError] = useState(false);
const [focus, setFocus] = useState(false);
const [secureEntry, setSecureEntry] = useState(true);
diff --git a/apps/mobile/src/components/ui/notice/index.js b/apps/mobile/src/components/ui/notice/index.js
index 898f5346c..be7c0739e 100644
--- a/apps/mobile/src/components/ui/notice/index.js
+++ b/apps/mobile/src/components/ui/notice/index.js
@@ -1,13 +1,12 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import { SIZE } from '../../../utils/size';
import { IconButton } from '../icon-button';
import Paragraph from '../typography/paragraph';
export const Notice = ({ type, text, size }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const isSmall = size === 'small';
return (
diff --git a/apps/mobile/src/components/ui/pressable/index.tsx b/apps/mobile/src/components/ui/pressable/index.tsx
index 7969a84a7..eae6f3ae4 100644
--- a/apps/mobile/src/components/ui/pressable/index.tsx
+++ b/apps/mobile/src/components/ui/pressable/index.tsx
@@ -6,11 +6,11 @@ import {
PressableStateCallbackType,
ViewStyle
} from 'react-native';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import { BUTTON_TYPES } from '../../../utils/constants';
import { hexToRGBA, RGB_Linear_Shade } from '../../../utils/color-scheme/utils';
import { br } from '../../../utils/size';
-import { defaultState } from '../../../provider/DefaultState';
+import { defaultState } from '../../../stores/DefaultState';
export interface PressableButtonProps extends PressableProps {
customStyle?: ViewStyle;
@@ -43,8 +43,7 @@ export const PressableButton = ({
customOpacity,
fwdRef
}: PressableButtonProps) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const selectedColor =
customSelectedColor ||
diff --git a/apps/mobile/src/components/ui/sheet/index.js b/apps/mobile/src/components/ui/sheet/index.js
index e2eb5b77c..088282bc8 100644
--- a/apps/mobile/src/components/ui/sheet/index.js
+++ b/apps/mobile/src/components/ui/sheet/index.js
@@ -2,8 +2,8 @@ import React from 'react';
import { Platform, View } from 'react-native';
import ActionSheet from 'react-native-actions-sheet';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useTracked } from '../../../provider';
-import { useSettingStore } from '../../../provider/stores';
+import { useThemeStore } from '../../../stores/theme';
+import { useSettingStore } from '../../../stores/stores';
import layoutmanager from '../../../utils/layout-manager';
import { PremiumToast } from '../../premium/premium-toast';
import { Toast } from '../../toast';
@@ -21,8 +21,7 @@ const SheetWrapper = ({
overlay,
overlayOpacity = 0.3
}) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const deviceMode = useSettingStore(state => state.deviceMode);
const sheetKeyboardHandler = useSettingStore(state => state.sheetKeyboardHandler);
const largeTablet = deviceMode === 'tablet';
diff --git a/apps/mobile/src/components/ui/svg/index.tsx b/apps/mobile/src/components/ui/svg/index.tsx
index 6b0413e49..2eb57bebe 100644
--- a/apps/mobile/src/components/ui/svg/index.tsx
+++ b/apps/mobile/src/components/ui/svg/index.tsx
@@ -7,10 +7,11 @@ export const SvgView = ({
height = 250,
src
}: {
- width: number | string;
- height: number | number;
- src: string;
+ width?: number | string;
+ height?: number | number;
+ src?: string;
}) => {
+ if (!src) return null;
return (
<View
style={{
diff --git a/apps/mobile/src/components/ui/typography/heading.js b/apps/mobile/src/components/ui/typography/heading.js
index 7f6fcab89..2e1d09073 100644
--- a/apps/mobile/src/components/ui/typography/heading.js
+++ b/apps/mobile/src/components/ui/typography/heading.js
@@ -1,7 +1,7 @@
import React from 'react';
import { Platform } from 'react-native';
import { Text } from 'react-native';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import { SIZE } from '../../../utils/size';
/**
@@ -16,8 +16,7 @@ import { SIZE } from '../../../utils/size';
* @param {TextType | restTypes} props all props
*/
const Heading = ({ color, size = SIZE.xl, style, ...restProps }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<Text
diff --git a/apps/mobile/src/components/ui/typography/paragraph.js b/apps/mobile/src/components/ui/typography/paragraph.js
index 64ba961f8..3b641fde2 100644
--- a/apps/mobile/src/components/ui/typography/paragraph.js
+++ b/apps/mobile/src/components/ui/typography/paragraph.js
@@ -1,6 +1,6 @@
import React from 'react';
import { Text } from 'react-native';
-import { useTracked } from '../../../provider';
+import { useThemeStore } from '../../../stores/theme';
import { SIZE } from '../../../utils/size';
/**
@@ -15,8 +15,7 @@ import { SIZE } from '../../../utils/size';
* @param {TextType | restTypes} props all props
*/
const Paragraph = ({ color, size = SIZE.sm, style, ...restProps }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<Text
diff --git a/apps/mobile/src/components/walkthroughs/index.tsx b/apps/mobile/src/components/walkthroughs/index.tsx
index bd9111df8..c99f93837 100644
--- a/apps/mobile/src/components/walkthroughs/index.tsx
+++ b/apps/mobile/src/components/walkthroughs/index.tsx
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { LayoutAnimation, View } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSendEvent, presentSheet } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, presentSheet } from '../../services/event-manager';
import { eCloseProgressDialog } from '../../utils/events';
import { MMKV } from '../../utils/database/mmkv';
import { SIZE } from '../../utils/size';
@@ -12,8 +12,7 @@ import Paragraph from '../ui/typography/paragraph';
import walkthroughs, { TStep } from './walkthroughs';
export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip: boolean }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [step, setStep] = useState<TStep>(steps && steps[0]);
const next = () => {
diff --git a/apps/mobile/src/components/walkthroughs/walkthroughs.tsx b/apps/mobile/src/components/walkthroughs/walkthroughs.tsx
index 199dfe9df..186ee6a57 100644
--- a/apps/mobile/src/components/walkthroughs/walkthroughs.tsx
+++ b/apps/mobile/src/components/walkthroughs/walkthroughs.tsx
@@ -2,8 +2,8 @@ import React from 'react';
import { Linking, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { COMMUNITY_SVG, LAUNCH_ROCKET, SUPPORT_SVG, WELCOME_SVG } from '../../assets/images/assets';
-import { TrackedState, useTracked } from '../../provider';
-import { eSendEvent } from '../../services/EventManager';
+import { ThemeStore, useThemeStore } from '../../stores/theme';
+import { eSendEvent } from '../../services/event-manager';
import { getElevation } from '../../utils';
import { eOpenAddNotebookDialog } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -18,7 +18,7 @@ import Paragraph from '../ui/typography/paragraph';
export type TStep = {
text?: string;
- walkthroughItem: (colors: TrackedState['colors']) => React.ReactNode;
+ walkthroughItem: (colors: ThemeStore['colors']) => React.ReactNode;
title?: string;
button?: {
type: 'next' | 'done';
@@ -32,8 +32,7 @@ export type TStep = {
};
const NotebookWelcome = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const data = useRotator([
{
title: 'Work and office',
@@ -105,7 +104,7 @@ const notebooks: { id: string; steps: TStep[] } = {
{
title: 'Notebook > Topic > Notes',
text: 'Every Notebook has various topics which are like sections that hold all your notes.',
- walkthroughItem: (colors: TrackedState['colors']) => (
+ walkthroughItem: (colors: ThemeStore['colors']) => (
<View
style={{
width: '100%',
@@ -247,8 +246,7 @@ const notebooks: { id: string; steps: TStep[] } = {
};
const ChooseTheme = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<View
@@ -333,8 +331,7 @@ const emailconfirmed: { id: string; steps: TStep[] } = {
};
const Support = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<View
diff --git a/apps/mobile/src/navigation/navigationstack.js b/apps/mobile/src/navigation/navigationstack.js
index 76a1c6a73..4d515727b 100644
--- a/apps/mobile/src/navigation/navigationstack.js
+++ b/apps/mobile/src/navigation/navigationstack.js
@@ -2,10 +2,10 @@ import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import * as React from 'react';
import Container from '../components/container';
-import { useTracked } from '../provider';
-import { useSelectionStore } from '../provider/stores';
-import { eSendEvent } from '../services/EventManager';
-import Navigation from '../services/Navigation';
+import { useThemeStore } from '../stores/theme';
+import { useSelectionStore } from '../stores/stores';
+import { eSendEvent } from '../services/event-manager';
+import Navigation from '../services/navigation';
import { history } from '../utils';
import { hideAllTooltips } from '../utils/hooks/use-tooltip';
import { MMKV } from '../utils/database/mmkv';
@@ -23,8 +23,7 @@ import Trash from '../screens/trash';
const Stack = createNativeStackNavigator();
export const NavigationStack = React.memo(
() => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [render, setRender] = React.useState(false);
const clearSelection = useSelectionStore(state => state.clearSelection);
const homepage = React.useRef('Notes');
diff --git a/apps/mobile/src/navigation/tabsholder.js b/apps/mobile/src/navigation/tabsholder.js
index 6ec1edebe..d41a767b9 100644
--- a/apps/mobile/src/navigation/tabsholder.js
+++ b/apps/mobile/src/navigation/tabsholder.js
@@ -7,13 +7,13 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { notesnook } from '../../e2e/test.ids';
import { SideMenu } from '../components/side-menu';
import Tabs from '../components/tabs';
-import { useTracked } from '../provider';
-import { useEditorStore, useSettingStore } from '../provider/stores';
+import { useThemeStore } from '../stores/theme';
+import { useEditorStore, useSettingStore } from '../stores/stores';
import { EditorWrapper } from '../screens/editor/EditorWrapper';
import { checkStatus, EditorWebView, getNote } from '../screens/editor/Functions';
import tiny from '../screens/editor/tiny/tiny';
-import { DDS } from '../services/DeviceDetection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../services/EventManager';
+import { DDS } from '../services/device-detection';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../services/event-manager';
import { editing, setWidthHeight } from '../utils';
import { updateStatusBarColor } from '../utils/color-scheme';
import {
@@ -70,8 +70,7 @@ const onChangeTab = async obj => {
export const TabsHolder = React.memo(
() => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const deviceMode = useSettingStore(state => state.deviceMode);
const setFullscreen = useSettingStore(state => state.setFullscreen);
diff --git a/apps/mobile/src/provider/Actions.js b/apps/mobile/src/provider/Actions.js
deleted file mode 100644
index e4aeaf162..000000000
--- a/apps/mobile/src/provider/Actions.js
+++ /dev/null
@@ -1,40 +0,0 @@
-export const Actions = {
- NOTES: 'note',
- NOTEBOOKS: 'notebook',
- TRASH: 'trash',
- TAGS: 'tags',
- PINNED: 'pinned',
- FAVORITES: 'favorites',
- SELECTION_MODE: 'selectionMode',
- SELECTED_ITEMS: 'selectedItemsList',
- THEME: 'theme',
- MODAL_NAVIGATOR: 'modalNavigator',
- CLEAR_SELECTION: 'clearSelection',
- LOGIN_NAVIGATOR: 'loginNavigator',
- CURRENT_EDITING_NOTE: 'currentEditingNote',
- COLORS: 'colorNotes',
- SEARCH_RESULTS: 'searchResults',
- USER: 'getUser',
- CURRENT_SCREEN: 'currentScreen',
- SETTINGS: 'getSettings',
- SELECT_ALL: 'selectAll',
- ALL: 'all',
- CLEAR_ALL: 'allClear',
- SYNCING: 'syncing',
- HEADER_STATE: 'headerState',
- SEARCH_STATE: 'searchState',
- CONTAINER_STATE: 'containerState',
- CONTAINER_BOTTOM_BUTTON: 'containerBottomButton',
- HEADER_VERTICAL_MENU: 'verticalMenu',
- HEADER_TEXT_STATE: 'headerTextState',
- MESSAGE_BOARD_STATE: 'messageBoardState',
- LOADING: 'loading',
- FULLSCREEN: 'fullscreen',
- DEVICE_MODE: 'deviceMode',
- MENU_PINS: 'menuPins',
- LAST_SYNC: 'lastSynced',
- INTENT_MODE: 'intentMode',
- SEARCHING: 'searching',
- PREMIUM: 'premium',
- SEARCH_STATUS: 'searchStatus'
-};
diff --git a/apps/mobile/src/provider/DefaultState.js b/apps/mobile/src/provider/DefaultState.js
deleted file mode 100644
index 50ad9cacd..000000000
--- a/apps/mobile/src/provider/DefaultState.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Appearance } from 'react-native';
-import { COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from '../utils/color-scheme';
-const darkScheme = Appearance.getColorScheme() === 'dark';
-export const defaultState = {
- colors: darkScheme ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT
-};
diff --git a/apps/mobile/src/provider/Reducer.js b/apps/mobile/src/provider/Reducer.js
deleted file mode 100644
index 55f2fdad9..000000000
--- a/apps/mobile/src/provider/Reducer.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Actions } from './Actions';
-
-export const reducer = (state, action) => {
- switch (action.type) {
- case Actions.THEME: {
- return {
- ...state,
- colors: action.colors
- };
- }
- default:
- return state;
- //throw new Error('unknown action type');
- }
-};
diff --git a/apps/mobile/src/provider/index.ts b/apps/mobile/src/provider/index.ts
deleted file mode 100644
index a94ebbc90..000000000
--- a/apps/mobile/src/provider/index.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { useReducer } from 'react';
-import { createContainer } from 'react-tracked';
-import { defaultState } from './DefaultState';
-import { reducer } from './Reducer';
-
-export type TrackedState = typeof defaultState;
-
-const useValue: () => [TrackedState, React.DispatchWithoutAction] = () =>
- useReducer(reducer, defaultState);
-
-export const { Provider, useTracked, useTrackedState } = createContainer(useValue);
diff --git a/apps/mobile/src/screens/editor/EditorHeader.js b/apps/mobile/src/screens/editor/EditorHeader.js
index 61984baaa..254f4706b 100644
--- a/apps/mobile/src/screens/editor/EditorHeader.js
+++ b/apps/mobile/src/screens/editor/EditorHeader.js
@@ -5,16 +5,16 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { notesnook } from '../../../e2e/test.ids';
import { IconButton } from '../../components/ui/icon-button';
import { Properties } from '../../components/properties';
-import { useTracked } from '../../provider';
-import { useEditorStore, useSettingStore, useUserStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
+import { useThemeStore } from '../../stores/theme';
+import { useEditorStore, useSettingStore, useUserStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent
-} from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+} from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { editing } from '../../utils';
import { SUBSCRIPTION_STATUS } from '../../utils/constants';
import { db } from '../../utils/database';
@@ -39,8 +39,7 @@ import { toolbarRef } from './tiny/toolbar/constants';
import picker from './tiny/toolbar/picker';
const EditorHeader = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const deviceMode = useSettingStore(state => state.deviceMode);
const currentlyEditingNote = useEditorStore(state => state.currentEditingNote);
const fullscreen = useSettingStore(state => state.fullscreen);
diff --git a/apps/mobile/src/screens/editor/EditorOverlay.js b/apps/mobile/src/screens/editor/EditorOverlay.js
index 0d1c25592..0fad6181e 100644
--- a/apps/mobile/src/screens/editor/EditorOverlay.js
+++ b/apps/mobile/src/screens/editor/EditorOverlay.js
@@ -4,8 +4,8 @@ import Animated, { Easing, timing, useValue } from 'react-native-reanimated';
import { Button } from '../../components/ui/button';
import Heading from '../../components/ui/typography/heading';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { editing } from '../../utils';
import { eOnLoadNote } from '../../utils/events';
import { SIZE } from '../../utils/size';
@@ -15,8 +15,7 @@ let timer = null;
let timerError = null;
let timerClosing = null;
const EditorOverlay = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [loading, setLoading] = useState(null);
const [error, setError] = useState(false);
const opacity = useValue(1);
diff --git a/apps/mobile/src/screens/editor/EditorSettings.js b/apps/mobile/src/screens/editor/EditorSettings.js
index 7bd2ae7bd..0b0208b7f 100644
--- a/apps/mobile/src/screens/editor/EditorSettings.js
+++ b/apps/mobile/src/screens/editor/EditorSettings.js
@@ -12,8 +12,8 @@ import Input from '../../components/ui/input';
import { PressableButton } from '../../components/ui/pressable';
import Seperator from '../../components/ui/seperator';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { SIZE } from '../../utils/size';
import { sleep } from '../../utils/time';
import { EditorWebView, getNote } from './Functions';
@@ -21,8 +21,7 @@ import tiny from './tiny/tiny';
import ToggleSwitch from 'toggle-switch-react-native';
export const EditorSettings = () => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [settings, setSettings] = useState({
fontSize: 10,
directionality: 'ltr'
@@ -220,8 +219,7 @@ export const EditorSettings = () => {
};
const DropDownMenu = ({ items, onPress, style, title, stub }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const menuRef = useRef();
return (
diff --git a/apps/mobile/src/screens/editor/EditorTitle.js b/apps/mobile/src/screens/editor/EditorTitle.js
index 6a802f414..69c8d4a8a 100644
--- a/apps/mobile/src/screens/editor/EditorTitle.js
+++ b/apps/mobile/src/screens/editor/EditorTitle.js
@@ -1,8 +1,8 @@
import React, { useEffect, useState } from 'react';
import { TextInput } from 'react-native';
import Animated, { Easing } from 'react-native-reanimated';
-import { useTracked } from '../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { SIZE } from '../../utils/size';
import { sleep } from '../../utils/time';
import { post, _onMessage } from './Functions';
@@ -18,8 +18,8 @@ function animation(v) {
}
export const EditorTitle = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
+
const [title, setTitle] = useState(null);
const onScroll = async data => {
if (data.visible === undefined || data.visible === null) return;
diff --git a/apps/mobile/src/screens/editor/EditorWrapper.js b/apps/mobile/src/screens/editor/EditorWrapper.js
index a7ad303ec..fea274519 100644
--- a/apps/mobile/src/screens/editor/EditorWrapper.js
+++ b/apps/mobile/src/screens/editor/EditorWrapper.js
@@ -10,9 +10,9 @@ import {
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Editor from '.';
import { PremiumToast } from '../../components/premium/premium-toast';
-import { useTracked } from '../../provider';
-import { useNoteStore, useSettingStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
+import { useThemeStore } from '../../stores/theme';
+import { useNoteStore, useSettingStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
import { editing } from '../../utils';
import { editorRef } from '../../utils/global-refs';
import useIsFloatingKeyboard from '../../utils/hooks/use-is-floating-keyboard';
@@ -20,8 +20,7 @@ import EditorOverlay from './EditorOverlay';
import { checkStatus, textInput } from './Functions';
export const EditorWrapper = ({ width }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const deviceMode = useSettingStore(state => state.deviceMode);
const loading = useNoteStore(state => state.loading);
const insets = useSafeAreaInsets();
@@ -49,7 +48,7 @@ export const EditorWrapper = ({ width }) => {
style={{
width: width[deviceMode].c,
height: '100%',
- backgroundColor: state.colors.bg,
+ backgroundColor: colors.bg,
borderLeftWidth: DDS.isTab ? 1 : 0,
borderLeftColor: DDS.isTab ? colors.nav : 'transparent'
}}
diff --git a/apps/mobile/src/screens/editor/Functions.js b/apps/mobile/src/screens/editor/Functions.js
index 17d688b59..e93277823 100644
--- a/apps/mobile/src/screens/editor/Functions.js
+++ b/apps/mobile/src/screens/editor/Functions.js
@@ -1,16 +1,16 @@
import { createRef } from 'react';
import { Platform } from 'react-native';
import { presentDialog } from '../../components/dialog/functions';
-import { useEditorStore, useMenuStore, useTagStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
+import { useEditorStore, useMenuStore, useTagStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent
-} from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import PremiumService from '../../services/PremiumService';
+} from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import PremiumService from '../../services/premium';
import { TipManager } from '../../services/tip-manager';
import { editing } from '../../utils';
import { COLORS_NOTE, COLOR_SCHEME } from '../../utils/color-scheme';
diff --git a/apps/mobile/src/screens/editor/HistoryComponent.js b/apps/mobile/src/screens/editor/HistoryComponent.js
index b5ff81572..3fc217315 100644
--- a/apps/mobile/src/screens/editor/HistoryComponent.js
+++ b/apps/mobile/src/screens/editor/HistoryComponent.js
@@ -1,8 +1,8 @@
import React, { useEffect, useState } from 'react';
import { Platform, View } from 'react-native';
import { IconButton } from '../../components/ui/icon-button';
-import { useTracked } from '../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { editing } from '../../utils';
import { SIZE } from '../../utils/size';
import useKeyboard from '../../utils/hooks/use-keyboard';
@@ -10,8 +10,7 @@ import { EditorWebView } from './Functions';
import tiny, { safeKeyboardDismiss } from './tiny/tiny';
const HistoryComponent = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [historyState, setHistoryState] = useState({
undo: false,
redo: false
diff --git a/apps/mobile/src/screens/editor/ProgressCircle.js b/apps/mobile/src/screens/editor/ProgressCircle.js
index 9032604c8..6ba2c551d 100644
--- a/apps/mobile/src/screens/editor/ProgressCircle.js
+++ b/apps/mobile/src/screens/editor/ProgressCircle.js
@@ -1,13 +1,13 @@
import React, { useEffect, useRef, useState } from 'react';
import { View } from 'react-native';
import * as Progress from 'react-native-progress';
-import { useTracked } from '../../provider';
-import { useAttachmentStore } from '../../provider/stores';
+import { useThemeStore } from '../../stores/theme';
+import { useAttachmentStore } from '../../stores/stores';
import { SIZE } from '../../utils/size';
export const ProgressCircle = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
+
const loading = useAttachmentStore(state => state.loading);
const [prog, setProg] = useState(0);
const [visible, setVisible] = useState(false);
diff --git a/apps/mobile/src/screens/editor/TableCellProperties.js b/apps/mobile/src/screens/editor/TableCellProperties.js
index 6ee39041a..0fc726db9 100644
--- a/apps/mobile/src/screens/editor/TableCellProperties.js
+++ b/apps/mobile/src/screens/editor/TableCellProperties.js
@@ -5,13 +5,13 @@ import { IconButton } from '../../components/ui/icon-button';
import { Button } from '../../components/ui/button';
import Heading from '../../components/ui/typography/heading';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet
-} from '../../services/EventManager';
+} from '../../services/event-manager';
import layoutmanager from '../../utils/layout-manager';
import { SIZE } from '../../utils/size';
import { EditorWebView } from './Functions';
@@ -20,8 +20,7 @@ import ColorItem from './tiny/toolbar/coloritem';
import { editor_colors, rgbToHex } from './tiny/toolbar/constants';
export const TableCellProperties = ({ data }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [cellOptions, setCellOptions] = useState(data);
console.log(data);
diff --git a/apps/mobile/src/screens/editor/TableRowProperties.js b/apps/mobile/src/screens/editor/TableRowProperties.js
index 4805ef904..7975fad07 100644
--- a/apps/mobile/src/screens/editor/TableRowProperties.js
+++ b/apps/mobile/src/screens/editor/TableRowProperties.js
@@ -3,13 +3,13 @@ import { View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { Button } from '../../components/ui/button';
import Heading from '../../components/ui/typography/heading';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet
-} from '../../services/EventManager';
+} from '../../services/event-manager';
import layoutmanager from '../../utils/layout-manager';
import { SIZE } from '../../utils/size';
import { EditorWebView } from './Functions';
@@ -18,8 +18,7 @@ import ColorItem from './tiny/toolbar/coloritem';
import { editor_colors, rgbToHex } from './tiny/toolbar/constants';
export const TableRowProperties = ({ data }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [rowOptions, setRowOptions] = useState(data);
console.log(data);
diff --git a/apps/mobile/src/screens/editor/index.js b/apps/mobile/src/screens/editor/index.js
index b191c93e6..ea2712c6b 100755
--- a/apps/mobile/src/screens/editor/index.js
+++ b/apps/mobile/src/screens/editor/index.js
@@ -2,9 +2,9 @@ import React, { useEffect, useState } from 'react';
import { Platform, View } from 'react-native';
import WebView from 'react-native-webview';
import { notesnook } from '../../../e2e/test.ids';
-import { useEditorStore, useUserStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useEditorStore, useUserStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { getCurrentColors } from '../../utils/color-scheme';
import { eOnLoadNote } from '../../utils/events';
import { tabBarRef } from '../../utils/global-refs';
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/coloritem.js b/apps/mobile/src/screens/editor/tiny/toolbar/coloritem.js
index 56a75ceb4..98379b88f 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/coloritem.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/coloritem.js
@@ -1,16 +1,15 @@
import React, { useEffect, useState } from 'react';
import { View, TouchableOpacity } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../../../provider';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../../../services/EventManager';
+import { useThemeStore } from '../../../../stores/theme';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../../../services/event-manager';
import { normalize, SIZE } from '../../../../utils/size';
import { formatSelection, properties, rgbToHex } from './constants';
import { execCommands } from './commands';
import { MMKV } from '../../../../utils/database/mmkv';
const ColorItem = ({ value, format, onCustomPress, checked }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [selected, setSelected] = useState(false);
const isChecked = value !== '' && (selected || checked);
const isNil = value === '';
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/commands.js b/apps/mobile/src/screens/editor/tiny/toolbar/commands.js
index aeeef8003..855b2eb8d 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/commands.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/commands.js
@@ -1,5 +1,5 @@
import { Platform } from 'react-native';
-import { useEditorStore } from '../../../../provider/stores';
+import { useEditorStore } from '../../../../stores/stores';
import { EditorWebView, textInput } from '../../Functions';
import tiny from '../tiny';
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/constants.js b/apps/mobile/src/screens/editor/tiny/toolbar/constants.js
index f9a2585e7..0fac4c959 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/constants.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/constants.js
@@ -1,6 +1,6 @@
import { createRef } from 'react';
import { Platform } from 'react-native';
-import { eSendEvent } from '../../../../services/EventManager';
+import { eSendEvent } from '../../../../services/event-manager';
import { editing } from '../../../../utils';
import { sleep } from '../../../../utils/time';
import { EditorWebView, textInput } from '../../Functions';
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/group.js b/apps/mobile/src/screens/editor/tiny/toolbar/group.js
index 77a9d468a..2f8735aff 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/group.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/group.js
@@ -1,11 +1,10 @@
import React from 'react';
import { View } from 'react-native';
-import { useTracked } from '../../../../provider';
+import { useThemeStore } from '../../../../stores/theme';
import ToolbarItem from './item';
const ToolbarGroup = ({ group }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<View
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/index.js b/apps/mobile/src/screens/editor/tiny/toolbar/index.js
index 83d558347..a121a87b7 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/index.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/index.js
@@ -1,8 +1,8 @@
import React, { useEffect } from 'react';
import { Platform, View, ScrollView } from 'react-native';
import { IconButton } from '../../../../components/ui/icon-button';
-import { useTracked } from '../../../../provider';
-import { useEditorStore } from '../../../../provider/stores';
+import { useThemeStore } from '../../../../stores/theme';
+import { useEditorStore } from '../../../../stores/stores';
import { getElevation } from '../../../../utils';
import { db } from '../../../../utils/database';
import { normalize } from '../../../../utils/size';
@@ -17,8 +17,7 @@ import Tooltip from './tooltip';
const EditorToolbar = React.memo(
() => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const config = TOOLBAR_CONFIG;
const searchReplace = useEditorStore(state => state.searchReplace);
const readonly = useEditorStore(state => state.readonly);
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/item.js b/apps/mobile/src/screens/editor/tiny/toolbar/item.js
index 64157e23e..2690bdd9a 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/item.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/item.js
@@ -4,16 +4,16 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { PressableButton } from '../../../../components/ui/pressable';
import Heading from '../../../../components/ui/typography/heading';
import Paragraph from '../../../../components/ui/typography/paragraph';
-import { useTracked } from '../../../../provider';
-import { useUserStore } from '../../../../provider/stores';
+import { useThemeStore } from '../../../../stores/theme';
+import { useUserStore } from '../../../../stores/stores';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet,
ToastEvent
-} from '../../../../services/EventManager';
-import PremiumService from '../../../../services/PremiumService';
+} from '../../../../services/event-manager';
+import PremiumService from '../../../../services/premium';
import { editing, showTooltip, TOOLTIP_POSITIONS } from '../../../../utils';
import { db } from '../../../../utils/database';
import { MMKV } from '../../../../utils/database/mmkv';
@@ -48,8 +48,7 @@ const ToolbarItem = ({
formatValue,
fullname
}) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [selected, setSelected] = useState(false);
const [icon, setIcon] = useState(valueIcon);
const [color, setColor] = useState(null);
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/itempin.js b/apps/mobile/src/screens/editor/tiny/toolbar/itempin.js
index 17bedf940..2a38acb4f 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/itempin.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/itempin.js
@@ -1,12 +1,11 @@
import React, { useEffect, useState } from 'react';
import Animated, { Easing, timing, useValue } from 'react-native-reanimated';
-import { useTracked } from '../../../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../../services/EventManager';
+import { useThemeStore } from '../../../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../../../services/event-manager';
import { sleep } from '../../../../utils/time';
const ToolbarItemPin = ({ format, color }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [visible, setVisible] = useState(false);
let scale = useValue(0);
useEffect(() => {
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js b/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js
index ea2d53ecc..4bb8aca75 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js
@@ -5,8 +5,8 @@ import isMobilePhone from 'validator/lib/isMobilePhone';
import isURL from 'validator/lib/isURL';
import { Button } from '../../../../components/ui/button';
import Input from '../../../../components/ui/input';
-import { useTracked } from '../../../../provider';
-import { eSendEvent, ToastEvent } from '../../../../services/EventManager';
+import { useThemeStore } from '../../../../stores/theme';
+import { eSendEvent, ToastEvent } from '../../../../services/event-manager';
import { editing, itemSkus } from '../../../../utils';
import { SIZE } from '../../../../utils/size';
import { EditorWebView } from '../../Functions';
@@ -18,8 +18,7 @@ import LinkPreview from './linkpreview';
let inputValue = null;
const ToolbarLinkInput = ({ format, value, setVisible }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [mode, setMode] = useState(value ? INPUT_MODE.NO_EDIT : INPUT_MODE.EDITING);
const inputRef = useRef();
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/linkpreview.js b/apps/mobile/src/screens/editor/tiny/toolbar/linkpreview.js
index 244fbe95f..b0bfac413 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/linkpreview.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/linkpreview.js
@@ -5,19 +5,18 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { IconButton } from '../../../../components/ui/icon-button';
import Heading from '../../../../components/ui/typography/heading';
import Paragraph from '../../../../components/ui/typography/paragraph';
-import { useTracked } from '../../../../provider';
+import { useThemeStore } from '../../../../stores/theme';
import { openLinkInBrowser } from '../../../../utils/functions';
import { SIZE } from '../../../../utils/size';
import { INPUT_MODE, properties, reFocusEditor } from './constants';
import isEmail from 'validator/lib/isEmail';
import isURL from 'validator/lib/isURL';
import isMobilePhone from 'validator/lib/isMobilePhone';
-import { ToastEvent } from '../../../../services/EventManager';
+import { ToastEvent } from '../../../../services/event-manager';
let prevLink = {};
const LinkPreview = ({ setMode, value, onSubmit }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [link, setLink] = useState(prevLink.value === value ? prevLink : {});
useEffect(() => {
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/listformat.js b/apps/mobile/src/screens/editor/tiny/toolbar/listformat.js
index aa5e599bf..1b7bbf9c6 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/listformat.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/listformat.js
@@ -1,13 +1,12 @@
import React from 'react';
import { View } from 'react-native';
import Heading from '../../../../components/ui/typography/heading';
-import { useTracked } from '../../../../provider';
+import { useThemeStore } from '../../../../stores/theme';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import Paragraph from '../../../../components/ui/typography/paragraph';
const ToolbarListFormat = ({ selected, formatValue, format }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const ordered_lists = {
default: ['1.', '2.', '3.'],
'lower-alpha': ['a.', 'b.', 'c.'],
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/picker.js b/apps/mobile/src/screens/editor/tiny/toolbar/picker.js
index 8155834e5..d13a4f414 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/picker.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/picker.js
@@ -5,8 +5,8 @@ import { launchCamera, launchImageLibrary } from 'react-native-image-picker';
import Sodium from 'react-native-sodium';
import RNFetchBlob from 'rn-fetch-blob';
import { AttachmentItem } from '../../../../components/attachments/attachment-item';
-import { eSendEvent, presentSheet, ToastEvent } from '../../../../services/EventManager';
-import PremiumService from '../../../../services/PremiumService';
+import { eSendEvent, presentSheet, ToastEvent } from '../../../../services/event-manager';
+import PremiumService from '../../../../services/premium';
import { editing } from '../../../../utils';
import { db } from '../../../../utils/database';
import { eCloseProgressDialog } from '../../../../utils/events';
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/searchreplace.js b/apps/mobile/src/screens/editor/tiny/toolbar/searchreplace.js
index bbc0b78cd..31c27c588 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/searchreplace.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/searchreplace.js
@@ -2,8 +2,8 @@ import React, { useEffect, useRef, useState } from 'react';
import { View } from 'react-native';
import { Button } from '../../../../components/ui/button';
import Input from '../../../../components/ui/input';
-import { useTracked } from '../../../../provider';
-import { useEditorStore, useSettingStore } from '../../../../provider/stores';
+import { useThemeStore } from '../../../../stores/theme';
+import { useEditorStore, useSettingStore } from '../../../../stores/stores';
import { showTooltip, TOOLTIP_POSITIONS } from '../../../../utils';
import { hideAllTooltips } from '../../../../utils/hooks/use-tooltip';
import layoutmanager from '../../../../utils/layout-manager';
@@ -14,8 +14,7 @@ import { endSearch } from './commands';
import { properties } from './constants';
const SearcReplace = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [focusType, setFocusType] = useState(0);
const [enableReplace, setEnableReplace] = useState(false);
const [menu, setMenu] = useState(false);
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/table.js b/apps/mobile/src/screens/editor/tiny/toolbar/table.js
index cf9eb14ac..f514e3409 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/table.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/table.js
@@ -3,16 +3,15 @@ import { View } from 'react-native';
import { PressableButton } from '../../../../components/ui/pressable';
import Heading from '../../../../components/ui/typography/heading';
import Paragraph from '../../../../components/ui/typography/paragraph';
-import { useTracked } from '../../../../provider';
-import { eSendEvent } from '../../../../services/EventManager';
+import { useThemeStore } from '../../../../stores/theme';
+import { eSendEvent } from '../../../../services/event-manager';
import { eCloseProgressDialog } from '../../../../utils/events';
import { SIZE } from '../../../../utils/size';
import { execCommands } from './commands';
import { formatSelection } from './constants';
export const Table = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [width, setWidth] = useState(400);
const itemWidth = width / 5;
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/tooltip.js b/apps/mobile/src/screens/editor/tiny/toolbar/tooltip.js
index 6aec95cd6..8dd33824d 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/tooltip.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/tooltip.js
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { ScrollView, View } from 'react-native';
-import { useTracked } from '../../../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../../services/EventManager';
+import { useThemeStore } from '../../../../stores/theme';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../../../services/event-manager';
import { editing } from '../../../../utils';
import layoutmanager from '../../../../utils/layout-manager';
import { normalize } from '../../../../utils/size';
@@ -13,8 +13,7 @@ import ToolbarItem from './item';
import ToolbarLinkInput from './linkinput';
const Tooltip = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [group, setGroup] = useState(null);
const isColorGroup = /^(hilitecolor|forecolor|)$/.test(group?.type);
const isInputTooltip = /^(link|video|)$/.test(group?.type);
diff --git a/apps/mobile/src/screens/favorites/index.js b/apps/mobile/src/screens/favorites/index.js
index e5898fa4a..ef415fe6d 100644
--- a/apps/mobile/src/screens/favorites/index.js
+++ b/apps/mobile/src/screens/favorites/index.js
@@ -4,9 +4,9 @@ import { Header } from '../../components/header';
import { Placeholder } from '../../components/ui/svg';
import SelectionHeader from '../../components/selection-header';
import List from '../../components/list';
-import { useFavoriteStore, useNoteStore } from '../../provider/stores';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { useFavoriteStore, useNoteStore } from '../../stores/stores';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { InteractionManager } from '../../utils';
export const Favorites = ({ navigation }) => {
diff --git a/apps/mobile/src/screens/home/index.js b/apps/mobile/src/screens/home/index.js
index cb4f53487..c89d7295b 100755
--- a/apps/mobile/src/screens/home/index.js
+++ b/apps/mobile/src/screens/home/index.js
@@ -4,11 +4,11 @@ import { ContainerHeader } from '../../components/container/containerheader';
import { Header } from '../../components/header/index';
import SelectionHeader from '../../components/selection-header';
import List from '../../components/list';
-import { useNoteStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { useNoteStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { editing, InteractionManager } from '../../utils';
import { db } from '../../utils/database';
import { eOnLoadNote } from '../../utils/events';
diff --git a/apps/mobile/src/screens/notebook/index.js b/apps/mobile/src/screens/notebook/index.js
index f6e4e97a4..7a5cb2e5c 100644
--- a/apps/mobile/src/screens/notebook/index.js
+++ b/apps/mobile/src/screens/notebook/index.js
@@ -6,9 +6,9 @@ import { Header } from '../../components/header';
import SelectionHeader from '../../components/selection-header';
import List from '../../components/list';
import { NotebookHeader } from '../../components/list-items/headers/notebook-header';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { InteractionManager } from '../../utils';
import { db } from '../../utils/database';
import { eOnNewTopicAdded, eOpenAddNotebookDialog, eOpenAddTopicDialog } from '../../utils/events';
diff --git a/apps/mobile/src/screens/notebooks/index.js b/apps/mobile/src/screens/notebooks/index.js
index afa4982ef..f45773e10 100644
--- a/apps/mobile/src/screens/notebooks/index.js
+++ b/apps/mobile/src/screens/notebooks/index.js
@@ -6,9 +6,9 @@ import { Header } from '../../components/header';
import List from '../../components/list';
import SelectionHeader from '../../components/selection-header';
import { Walkthrough } from '../../components/walkthroughs';
-import { useNotebookStore } from '../../provider/stores';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { useNotebookStore } from '../../stores/stores';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { InteractionManager } from '../../utils';
export const Notebooks = ({ navigation }) => {
diff --git a/apps/mobile/src/screens/notes/index.js b/apps/mobile/src/screens/notes/index.js
index ff76984ba..edfdb10ee 100644
--- a/apps/mobile/src/screens/notes/index.js
+++ b/apps/mobile/src/screens/notes/index.js
@@ -6,12 +6,12 @@ import { Header } from '../../components/header';
import { MoveNotes } from '../../components/sheets/move-notes/movenote';
import SelectionHeader from '../../components/selection-header';
import List from '../../components/list';
-import { useTracked } from '../../provider';
-import { useNoteStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { useThemeStore } from '../../stores/theme';
+import { useNoteStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { editing, InteractionManager } from '../../utils';
import { db } from '../../utils/database';
import { eOnLoadNote, eOpenAddTopicDialog, refreshNotesPage } from '../../utils/events';
@@ -47,8 +47,7 @@ function getAlias(params) {
}
export const Notes = ({ route, navigation }) => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const params = useRef(route?.params);
const [notes, setNotes] = useState(getNotes(params.current) || []);
const loading = useNoteStore(state => state.loading);
diff --git a/apps/mobile/src/screens/search/index.js b/apps/mobile/src/screens/search/index.js
index a74655cea..313b079fc 100644
--- a/apps/mobile/src/screens/search/index.js
+++ b/apps/mobile/src/screens/search/index.js
@@ -2,8 +2,8 @@ import React, { useCallback, useEffect } from 'react';
import { ContainerHeader } from '../../components/container/containerheader';
import SelectionHeader from '../../components/selection-header';
import List from '../../components/list';
-import { useSearchStore } from '../../provider/stores';
-import SearchService from '../../services/SearchService';
+import { useSearchStore } from '../../stores/stores';
+import SearchService from '../../services/search';
import { inputRef } from '../../utils/global-refs';
import { sleep } from '../../utils/time';
import { SearchBar } from './search-bar';
diff --git a/apps/mobile/src/screens/search/searchbar.js b/apps/mobile/src/screens/search/searchbar.js
index 118ccb8ac..5554f0b6c 100644
--- a/apps/mobile/src/screens/search/searchbar.js
+++ b/apps/mobile/src/screens/search/searchbar.js
@@ -3,18 +3,17 @@ import { Platform, View } from 'react-native';
import { TextInput } from 'react-native-gesture-handler';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { IconButton } from '../../components/ui/icon-button';
-import { useTracked } from '../../provider';
-import { useSearchStore } from '../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { useThemeStore } from '../../stores/theme';
+import { useSearchStore } from '../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { eScrollEvent } from '../../utils/events';
import { normalize, SIZE } from '../../utils/size';
import { sleep } from '../../utils/time';
export const SearchBar = () => {
- const [state] = useTracked();
- const colors = state.colors;
+ const colors = useThemeStore(state => state.colors);
const [value, setValue] = useState(null);
const inputRef = useRef();
const setSearchResults = useSearchStore(state => state.setSearchResults);
diff --git a/apps/mobile/src/screens/settings/appearance.js b/apps/mobile/src/screens/settings/appearance.js
index deedef79b..46d7638b4 100644
--- a/apps/mobile/src/screens/settings/appearance.js
+++ b/apps/mobile/src/screens/settings/appearance.js
@@ -6,13 +6,13 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import ToggleSwitch from 'toggle-switch-react-native';
import { PressableButton } from '../../components/ui/pressable';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { Actions } from '../../provider/Actions';
-import { useSettingStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import { ToastEvent } from '../../services/EventManager';
-import PremiumService from '../../services/PremiumService';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { Actions } from '../../stores/Actions';
+import { useSettingStore } from '../../stores/stores';
+import { DDS } from '../../services/device-detection';
+import { ToastEvent } from '../../services/event-manager';
+import PremiumService from '../../services/premium';
+import SettingsService from '../../services/settings';
import { MenuItemsList } from '../../utils/constants';
import {
ACCENT,
@@ -30,14 +30,13 @@ import { CustomButton } from './button';
import SectionHeader from './section-header';
const SettingsAppearanceSection = () => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const [collapsed, setCollapsed] = useState(true);
const menuRef = useRef();
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent);
- dispatch({ type: Actions.THEME, colors: newColors });
+ useThemeStore.getState().setColors({ ...newColors });
}
function changeAccentColor(accentColor) {
@@ -269,12 +268,11 @@ const SettingsAppearanceSection = () => {
};
export const AccentColorPicker = ({ settings = true }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent);
- dispatch({ type: Actions.THEME, colors: newColors });
+ useThemeStore.getState().setColors({ ...newColors });
}
function changeAccentColor(accentColor) {
diff --git a/apps/mobile/src/screens/settings/applock.js b/apps/mobile/src/screens/settings/applock.js
index 5b1e268a7..76a020db9 100644
--- a/apps/mobile/src/screens/settings/applock.js
+++ b/apps/mobile/src/screens/settings/applock.js
@@ -1,15 +1,15 @@
import React, { useState } from 'react';
import { LayoutAnimation, Platform, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import BiometricService from '../../services/BiometricService';
+import BiometricService from '../../services/biometrics';
import { PressableButton } from '../../components/ui/pressable';
import Seperator from '../../components/ui/seperator';
import Heading from '../../components/ui/typography/heading';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
-import { presentSheet } from '../../services/EventManager';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
+import { presentSheet } from '../../services/event-manager';
+import SettingsService from '../../services/settings';
import { SIZE } from '../../utils/size';
import { db } from '../../utils/database';
import { WelcomeNotice } from '../../components/intro/welcome';
@@ -18,8 +18,7 @@ import { getElevation } from '../../utils';
import umami from '../../utils/analytics';
const AppLock = ({ welcome, s = 0 }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const [step, setStep] = useState(s);
diff --git a/apps/mobile/src/screens/settings/backuprestore.js b/apps/mobile/src/screens/settings/backuprestore.js
index 871a79454..5b87a8d59 100644
--- a/apps/mobile/src/screens/settings/backuprestore.js
+++ b/apps/mobile/src/screens/settings/backuprestore.js
@@ -3,12 +3,12 @@ import { Platform, TouchableOpacity, View } from 'react-native';
import ToggleSwitch from 'toggle-switch-react-native';
import Seperator from '../../components/ui/seperator';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { useSettingStore, useUserStore } from '../../provider/stores';
-import Backup from '../../services/Backup';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';
-import PremiumService from '../../services/PremiumService';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore, useUserStore } from '../../stores/stores';
+import Backup from '../../services/backup';
+import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
+import PremiumService from '../../services/premium';
+import SettingsService from '../../services/settings';
import { eCloseProgressDialog, eOpenLoginDialog, eOpenRestoreDialog } from '../../utils/events';
import { openLinkInBrowser } from '../../utils/functions';
import { MMKV } from '../../utils/database/mmkv';
@@ -19,8 +19,7 @@ import { verifyUser } from './functions';
import SectionHeader from './section-header';
const SettingsBackupAndRestore = ({ isSheet }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const user = useUserStore(state => state.user);
const [collapsed, setCollapsed] = useState(isSheet ? false : true);
diff --git a/apps/mobile/src/screens/settings/button.js b/apps/mobile/src/screens/settings/button.js
index 4c5648865..94776bffc 100644
--- a/apps/mobile/src/screens/settings/button.js
+++ b/apps/mobile/src/screens/settings/button.js
@@ -2,12 +2,11 @@ import React from 'react';
import { View } from 'react-native';
import { PressableButton } from '../../components/ui/pressable';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import { SIZE } from '../../utils/size';
export const CustomButton = ({ title, tagline, customComponent, onPress, color = null }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<PressableButton
onPress={onPress}
diff --git a/apps/mobile/src/screens/settings/developeroptions.js b/apps/mobile/src/screens/settings/developeroptions.js
index 7a2279d32..42f3469f9 100644
--- a/apps/mobile/src/screens/settings/developeroptions.js
+++ b/apps/mobile/src/screens/settings/developeroptions.js
@@ -1,14 +1,13 @@
import React, { useState } from 'react';
import ToggleSwitch from 'toggle-switch-react-native';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
+import SettingsService from '../../services/settings';
import { CustomButton } from './button';
import SectionHeader from './section-header';
const SettingsDeveloperOptions = ({ isSheet }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const [collapsed, setCollapsed] = useState(isSheet ? false : true);
diff --git a/apps/mobile/src/screens/settings/functions.js b/apps/mobile/src/screens/settings/functions.js
index 3fdd67b76..61d504f4c 100644
--- a/apps/mobile/src/screens/settings/functions.js
+++ b/apps/mobile/src/screens/settings/functions.js
@@ -1,5 +1,5 @@
import { presentDialog } from '../../components/dialog/functions';
-import { ToastEvent } from '../../services/EventManager';
+import { ToastEvent } from '../../services/event-manager';
import { db } from '../../utils/database';
import { sleep } from '../../utils/time';
diff --git a/apps/mobile/src/screens/settings/general.js b/apps/mobile/src/screens/settings/general.js
index fa63be317..af42182f3 100644
--- a/apps/mobile/src/screens/settings/general.js
+++ b/apps/mobile/src/screens/settings/general.js
@@ -1,15 +1,14 @@
import React, { useState } from 'react';
import ToggleSwitch from 'toggle-switch-react-native';
-import { useTracked } from '../../provider';
-import { useSettingStore } from '../../provider/stores';
-import Notifications from '../../services/Notifications';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore } from '../../stores/stores';
+import Notifications from '../../services/notifications';
+import SettingsService from '../../services/settings';
import { CustomButton } from './button';
import SectionHeader from './section-header';
export const SettingsGeneralOptions = ({ isSheet }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const [collapsed, setCollapsed] = useState(isSheet ? false : true);
const toggleNotifNotes = () => {
diff --git a/apps/mobile/src/screens/settings/index.js b/apps/mobile/src/screens/settings/index.js
index 011075329..f0c7dfdb2 100644
--- a/apps/mobile/src/screens/settings/index.js
+++ b/apps/mobile/src/screens/settings/index.js
@@ -7,9 +7,9 @@ import { Issue } from '../../components/sheets/github/issue';
import { Header as TopHeader } from '../../components/header/index';
import Seperator from '../../components/ui/seperator';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { eSendEvent, presentSheet } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, presentSheet } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
import { InteractionManager } from '../../utils';
import { STORE_LINK } from '../../utils/constants';
import { eScrollEvent, eUpdateSearchState } from '../../utils/events';
@@ -32,8 +32,7 @@ const format = ver => {
};
export const Settings = ({ navigation }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const [collapsed, setCollapsed] = useState(false);
let pageIsLoaded = false;
diff --git a/apps/mobile/src/screens/settings/logout.js b/apps/mobile/src/screens/settings/logout.js
index 5d43d404a..7d96984a5 100644
--- a/apps/mobile/src/screens/settings/logout.js
+++ b/apps/mobile/src/screens/settings/logout.js
@@ -6,18 +6,17 @@ import { presentDialog } from '../../components/dialog/functions';
import { PressableButton } from '../../components/ui/pressable';
import Heading from '../../components/ui/typography/heading';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import BiometricService from '../../services/BiometricService';
-import { ToastEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import BiometricService from '../../services/biometrics';
+import { ToastEvent } from '../../services/event-manager';
import { db } from '../../utils/database';
import { SIZE } from '../../utils/size';
import Storage from '../../utils/database/storage';
import { sleep } from '../../utils/time';
const AccoutLogoutSection = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const user = useUserStore(state => state.user);
const [loading, setLoading] = useState(false);
diff --git a/apps/mobile/src/screens/settings/privacy.js b/apps/mobile/src/screens/settings/privacy.js
index 1619545fe..3525bb200 100644
--- a/apps/mobile/src/screens/settings/privacy.js
+++ b/apps/mobile/src/screens/settings/privacy.js
@@ -2,12 +2,12 @@ import React, { useCallback, useEffect, useState } from 'react';
import { Platform } from 'react-native';
import { enabled } from 'react-native-privacy-snapshot';
import ToggleSwitch from 'toggle-switch-react-native';
-import { useTracked } from '../../provider';
-import { useSettingStore, useUserStore } from '../../provider/stores';
-import BiometricService from '../../services/BiometricService';
-import { eSubscribeEvent, eUnSubscribeEvent, openVault } from '../../services/EventManager';
-import PremiumService from '../../services/PremiumService';
-import SettingsService from '../../services/SettingsService';
+import { useThemeStore } from '../../stores/theme';
+import { useSettingStore, useUserStore } from '../../stores/stores';
+import BiometricService from '../../services/biometrics';
+import { eSubscribeEvent, eUnSubscribeEvent, openVault } from '../../services/event-manager';
+import PremiumService from '../../services/premium';
+import SettingsService from '../../services/settings';
import { AndroidModule, InteractionManager } from '../../utils';
import { db } from '../../utils/database';
import AppLock from './app-lock';
@@ -15,8 +15,7 @@ import { CustomButton } from './button';
import SectionHeader from './section-header';
const SettingsPrivacyAndSecurity = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const settings = useSettingStore(state => state.settings);
const [collapsed, setCollapsed] = useState(true);
const user = useUserStore(state => state.user);
diff --git a/apps/mobile/src/screens/settings/sectionheader.js b/apps/mobile/src/screens/settings/sectionheader.js
index b15eaf487..d887f99e0 100644
--- a/apps/mobile/src/screens/settings/sectionheader.js
+++ b/apps/mobile/src/screens/settings/sectionheader.js
@@ -3,13 +3,12 @@ import { TouchableOpacity } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import Heading from '../../components/ui/typography/heading';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
+import { useThemeStore } from '../../stores/theme';
import layoutmanager from '../../utils/layout-manager';
import { SIZE } from '../../utils/size';
const SectionHeader = ({ title, collapsed, setCollapsed }) => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
return (
<TouchableOpacity
diff --git a/apps/mobile/src/screens/settings/usersection.js b/apps/mobile/src/screens/settings/usersection.js
index 49dc297d6..6ed88967e 100644
--- a/apps/mobile/src/screens/settings/usersection.js
+++ b/apps/mobile/src/screens/settings/usersection.js
@@ -8,11 +8,11 @@ import { Button } from '../../components/ui/button';
import Seperator from '../../components/ui/seperator';
import Heading from '../../components/ui/typography/heading';
import Paragraph from '../../components/ui/typography/paragraph';
-import { useTracked } from '../../provider';
-import { useUserStore } from '../../provider/stores';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';
-import PremiumService from '../../services/PremiumService';
-import Sync from '../../services/Sync';
+import { useThemeStore } from '../../stores/theme';
+import { useUserStore } from '../../stores/stores';
+import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
+import PremiumService from '../../services/premium';
+import Sync from '../../services/sync';
import {
SUBSCRIPTION_PROVIDER,
SUBSCRIPTION_STATUS,
@@ -38,8 +38,7 @@ const getTimeLeft = t2 => {
};
const SettingsUserSection = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const user = useUserStore(state => state.user);
const subscriptionDaysLeft = user && getTimeLeft(parseInt(user.subscription?.expiry));
diff --git a/apps/mobile/src/screens/tags/index.js b/apps/mobile/src/screens/tags/index.js
index e693a91b0..89d5aad72 100644
--- a/apps/mobile/src/screens/tags/index.js
+++ b/apps/mobile/src/screens/tags/index.js
@@ -4,9 +4,9 @@ import { Header } from '../../components/header';
import { Placeholder } from '../../components/ui/svg';
import SelectionHeader from '../../components/selection-header';
import List from '../../components/list';
-import { useTagStore } from '../../provider/stores';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { useTagStore } from '../../stores/stores';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { InteractionManager } from '../../utils';
export const Tags = ({ navigation }) => {
diff --git a/apps/mobile/src/screens/trash/index.js b/apps/mobile/src/screens/trash/index.js
index 3d1794890..706516f17 100644
--- a/apps/mobile/src/screens/trash/index.js
+++ b/apps/mobile/src/screens/trash/index.js
@@ -6,10 +6,10 @@ import { Header } from '../../components/header';
import { Placeholder } from '../../components/ui/svg';
import SelectionHeader from '../../components/selection-header';
import List from '../../components/list';
-import { useSelectionStore, useTrashStore } from '../../provider/stores';
-import { ToastEvent } from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import SearchService from '../../services/SearchService';
+import { useSelectionStore, useTrashStore } from '../../stores/stores';
+import { ToastEvent } from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import SearchService from '../../services/search';
import { InteractionManager } from '../../utils';
import { db } from '../../utils/database';
diff --git a/apps/mobile/src/services/EventManager.js b/apps/mobile/src/services/EventManager.js
deleted file mode 100644
index ab2a24c97..000000000
--- a/apps/mobile/src/services/EventManager.js
+++ /dev/null
@@ -1,91 +0,0 @@
-import EventManager from 'notes-core/utils/event-manager';
-import {
- eHideToast,
- eOnNoteEdited,
- eOpenProgressDialog,
- eOpenVaultDialog,
- eShowToast
-} from '../utils/events';
-const eventManager = new EventManager();
-
-export const eSubscribeEvent = (eventName, action) => {
- eventManager.subscribe(eventName, action);
-};
-
-export const eUnSubscribeEvent = (eventName, action) => {
- eventManager.unsubscribe(eventName, action);
-};
-
-export const eSendEvent = (eventName, data) => {
- eventManager.publish(eventName, data);
-};
-
-/**
- * @typedef {Object} vaultType
- * @property {Object} item
- * @property {boolean} novault
- * @property {string} title
- * @property {string} description
- * @property {boolean} locked
- * @property {boolean} permanant
- * @property {boolean} goToEditor
- * @property {boolean} share
- * @property {boolean} deleteNote
- * @property {boolean} fingerprintAccess
- * @property {boolean} revokeFingerprintAccess
- * @property {boolean} changePassword
- * @property {boolean} clearVault
- * @property {boolean} deleteVault
- * @property {boolean} copyNote
- * @param {vaultType} data
- */
-
-export const openVault = data => {
- eSendEvent(eOpenVaultDialog, data);
-};
-
-/**
- * @typedef {Object} noteEdit
- * @property {string} id
- * @property {boolean} closed
- * @property {boolean} noEdit
- * @property {boolean} forced
- * @param {noteEdit} data
- */
-export function sendNoteEditedEvent(data) {
- eSendEvent(eOnNoteEdited, data);
-}
-
-export function presentSheet(data) {
- eSendEvent(eOpenProgressDialog, data);
-}
-
-export const ToastEvent = {
- /**
- * @typedef {Object} event
- * @property {string} heading
- * @property {string} message
- * @property {"global" | "local"} context
- * @property {"error" | "success"} type
- * @property {number} duration
- * @property {function} func
- * @property {string} actionText
- *
- * @param {event} data
- */
- show: data =>
- eSendEvent(eShowToast, {
- heading: data.heading,
- message: data.message,
- type: data.type || 'error',
- context: data.context || 'global',
- duration: data.duration || 3000,
- func: data.func || null,
- actionText: data.actionText || null
- }),
- hide: () => eSendEvent(eHideToast)
-};
-
-/*
-
-*/
diff --git a/apps/mobile/src/services/IntentService.js b/apps/mobile/src/services/IntentService.js
deleted file mode 100644
index 8f7091801..000000000
--- a/apps/mobile/src/services/IntentService.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/* import {Linking, NativeModules, Platform} from 'react-native';
-const {ReceiveSharingIntent} = NativeModules;
-let currentIntent = null;
-const isIos = Platform.OS === 'ios';
-
-function getIntent() {
- return new Promise(async (resolve, reject) => {
- let initialUrlIOS;
- let _data = null;
- try {
- if (isIos) {
- initialUrlIOS = await Linking.getInitialURL();
- if (initialUrlIOS && initialUrlIOS.startsWith('ShareMedia://dataUrl')) {
- _data = await ReceiveSharingIntent.getFileNames(initialUrlIOS);
- _data = iosSortedData(_data);
- } else {
- reject('unsupported url');
- }
- } else {
- _data = await ReceiveSharingIntent.getFileNames();
- }
- } catch (e) {
- reject(e);
- }
- ReceiveSharingIntent.clearFileNames();
- if (!_data) {
- return;
- }
- setIntent(_data, resolve, reject);
- });
-}
-
-function setIntent(d, resolve, reject) {
- let data = d[0];
- if (data.text || data.weblink) {
- let text = data.text;
- let weblink = data.weblink;
- let delta = null;
-
- if (weblink && text) {
- delta = [{insert: text}, {insert: weblink, attributes: {link: weblink}}];
- } else if (text && !weblink) {
- delta = [{insert: text}];
- } else if (weblink) {
- delta = [{insert: weblink, attributes: {link: weblink}}];
- }
- currentIntent = {
- type: 'intent',
- data: delta,
- };
- if (resolve) {
- resolve(true);
- }
- } else {
- if (reject) {
- reject('nothing found');
- }
- }
-}
-
-function check(callback) {
- callback(currentIntent);
- currentIntent = null;
-}
-
-const iosSortedData = (data) => {
- let objects = {
- filePath: null,
- text: null,
- weblink: null,
- mimeType: null,
- contentUri: null,
- fileName: null,
- extension: null,
- };
- let file = data;
- if (file.startsWith('text:')) {
- let text = file.replace('text:', '');
- if (text.startsWith('http')) {
- let object = [{...objects, weblink: text}];
- return object;
- }
- let object = [{...objects, text: text}];
- return object;
- } else if (file.startsWith('webUrl:')) {
- let weblink = file.replace('webUrl:', '');
- let object = [{...objects, weblink: weblink}];
- return object;
- } else {
- try {
- let files = JSON.parse(file);
- let object = [];
- for (let i = 0; i < files.length; i++) {
- let path = files[i].path;
- let obj = {
- ...objects,
- fileName: getFileName(path),
- extension: getExtension(path),
- mimeType: getMimeType(path),
- filePath: path,
- };
- object.push(obj);
- }
- return object;
- } catch (error) {
- return [{...objects}];
- }
- }
-};
-
-const getFileName = (file) => {
- return file.replace(/^.*(\\|\/|\:)/, '');
-};
-
-const getExtension = (fileName) => {
- return fileName.substr(fileName.lastIndexOf('.') + 1);
-};
-
-const getMimeType = (file) => {
- let ext = getExtension(file);
- let extension = '.' + ext.toLowerCase();
- if (MimeTypes[extension]) {
- return MimeTypes[extension];
- }
- return null;
-};
-
-export default {
- getIntent,
- check,
- setIntent,
- iosSortedData,
-};
- */
diff --git a/apps/mobile/src/services/SettingsService.js b/apps/mobile/src/services/SettingsService.js
deleted file mode 100644
index 1fd940b5b..000000000
--- a/apps/mobile/src/services/SettingsService.js
+++ /dev/null
@@ -1,121 +0,0 @@
-import { Platform } from 'react-native';
-import { enabled } from 'react-native-privacy-snapshot';
-import { updateEvent } from '../components/dialog-provider/recievers';
-import { Actions } from '../provider/Actions';
-import { useSettingStore } from '../provider/stores';
-import { AndroidModule } from '../utils';
-import { getColorScheme } from '../utils/color-scheme/utils';
-import { MMKV } from '../utils/database/mmkv';
-import { scale, updateSize } from '../utils/size';
-import Notifications from './Notifications';
-
-export const defaultSettings = {
- showToolbarOnTop: false,
- showKeyboardOnOpen: false,
- fontScale: 1,
- forcePortraitOnTablet: false,
- useSystemTheme: false,
- reminder: 'off',
- encryptedBackup: false,
- homepage: 'Notes',
- sort: 'default',
- sortOrder: 'desc',
- screenshotMode: true,
- privacyScreen: false,
- appLockMode: 'none',
- telemetry: true,
- notebooksListMode: 'normal',
- notesListMode: 'normal',
- devMode: false,
- notifNotes: false,
- pitchBlack: false,
- reduceAnimations: false
-};
-
-let settings = { ...defaultSettings };
-
-let appLoaded = false;
-
-function setAppLoaded() {
- appLoaded = true;
-}
-
-function getApploaded() {
- return appLoaded;
-}
-
-async function init() {
- scale.fontScale = 1;
- settings = await MMKV.getItem('appSettings');
- if (!settings) {
- settings = defaultSettings;
- await MMKV.setItem('appSettings', JSON.stringify(settings));
- } else {
- settings = JSON.parse(settings);
- if (!settings.appLockMode) {
- settings.appLockMode = 'none';
- }
- // eslint-disable-next-line no-prototype-builtins
- if (!settings.hasOwnProperty('telemetry')) {
- settings.telemetry = true;
- }
- if (!settings.notesListMode) {
- settings.notesListMode = 'normal';
- }
- if (!settings.notebooksListMode) {
- settings.notebooksListMode = 'normal';
- }
- }
- if (settings.notifNotes) {
- Notifications.pinQuickNote(true);
- }
-
- if (settings.fontScale) {
- scale.fontScale = settings.fontScale;
- }
- if (settings.privacyScreen || settings.appLockMode === 'background') {
- if (Platform.OS === 'android') {
- AndroidModule.setSecureMode(true);
- } else {
- enabled(true);
- }
- } else {
- if (Platform.OS === 'android') {
- AndroidModule.setSecureMode(false);
- } else {
- enabled(false);
- }
- }
-
- updateSize();
- useSettingStore.getState().setSettings({ ...settings });
- setTheme();
- return;
-}
-
-const setTheme = async () => {
- if (settings) {
- let newColors = await getColorScheme(settings.useSystemTheme);
- updateEvent({ type: Actions.THEME, colors: { ...newColors } });
- }
-};
-
-async function set(name, value) {
- settings[name] = value;
- settings = { ...settings };
- await MMKV.setItem('appSettings', JSON.stringify(settings));
- useSettingStore.getState().setSettings({ ...settings });
-}
-
-function get() {
- return { ...settings };
-}
-
-export default {
- init,
- setTheme,
- set,
- get,
- setAppLoaded,
- getApploaded
-};
diff --git a/apps/mobile/src/services/Backup.js b/apps/mobile/src/services/backup.js
similarity index 51%
rename from apps/mobile/src/services/Backup.js
rename to apps/mobile/src/services/backup.js
index c4ab49d03..4d9a8dc34 100644
--- a/apps/mobile/src/services/Backup.js
+++ b/apps/mobile/src/services/backup.js
@@ -1,17 +1,17 @@
-const { MMKV } = require('../utils/database/MMKV');
-import Clipboard from '@react-native-clipboard/clipboard';
import { Platform } from 'react-native';
import FileViewer from 'react-native-file-viewer';
import * as ScopedStorage from 'react-native-scoped-storage';
import Share from 'react-native-share';
+import RNFetchBlob from 'rn-fetch-blob';
import { presentDialog } from '../components/dialog/functions';
import { db } from '../utils/database';
+import { MMKV } from '../utils/database/mmkv';
+import storage from '../utils/database/storage';
import { eCloseProgressDialog } from '../utils/events';
import { sanitizeFilename } from '../utils/sanitizer';
-import storage from '../utils/database/storage';
import { sleep } from '../utils/time';
-import { eSendEvent, presentSheet, ToastEvent } from './EventManager';
-import SettingsService from './SettingsService';
+import { eSendEvent, presentSheet, ToastEvent } from './event-manager';
+import SettingsService from './settings';
const MS_DAY = 86400000;
const MS_WEEK = MS_DAY * 7;
@@ -74,147 +74,121 @@ async function checkBackupDirExists(reset = false) {
return dir;
}
-let RNFetchBlob;
+async function presentBackupCompleteSheet(backupFilePath) {
+ presentSheet({
+ title: 'Backup complete',
+ icon: 'cloud-upload',
+ paragraph: `${
+ Platform.OS === 'android'
+ ? 'Backup file saved in "Notesnook backups" folder on your phone'
+ : 'Backup file is saved in File Manager/Notesnook folder'
+ }. Share your backup to your cloud so you do not lose it.`,
+ actionText: 'Share backup',
+ actionsArray: [
+ {
+ action: () => {
+ if (Platform.OS === 'ios') {
+ console.log(backupFilePath);
+ Share.open({
+ url: 'file:/' + backupFilePath,
+ failOnCancel: false
+ }).catch(console.log);
+ } else {
+ FileViewer.open(backupFilePath, {
+ showOpenWithDialog: true,
+ showAppsSuggestions: true,
+ shareFile: true
+ }).catch(console.log);
+ }
+ },
+ actionText: 'Share'
+ },
+ {
+ action: async () => {
+ eSendEvent(eCloseProgressDialog);
+ await MMKV.setItem('dontShowCompleteSheet', 'yes');
+ },
+ actionText: 'Never ask again',
+ type: 'grayBg'
+ }
+ ]
+ });
+}
+
+async function updateNextBackupTime() {
+ await MMKV.setItem('backupDate', JSON.stringify(Date.now()));
+ await MMKV.setItem(
+ 'askForBackup',
+ JSON.stringify({
+ timestamp: Date.now() + 86400000 * 3
+ })
+ );
+}
+
async function run() {
let androidBackupDirectory = await checkBackupDirExists();
if (!androidBackupDirectory) return;
- RNFetchBlob = require('rn-fetch-blob').default;
presentSheet({
title: 'Backing up your data',
paragraph: "All your backups are stored in 'Phone Storage/Notesnook/backups/' folder",
progress: true
});
let backup;
- let error;
+
try {
backup = await db.backup.export('mobile', SettingsService.get().encryptedBackup);
if (!backup) throw new Error(`Backup returned empty.`);
} catch (e) {
- error = e;
+ await sleep(300);
+ eSendEvent(eCloseProgressDialog);
+ ToastEvent.error(e, 'Backup failed!');
+ return null;
}
- if (!error) {
- try {
- let backupName = 'notesnook_backup_' + Date.now();
- backupName = sanitizeFilename(backupName, { replacement: '_' });
- backupName = backupName + '.nnbackup';
- let path;
- let backupFilePath;
- if (Platform.OS === 'ios') {
- path = await storage.checkAndCreateDir('/backups/');
- await RNFetchBlob.fs.writeFile(path + backupName, backup, 'utf8');
- backupFilePath = path + backupName;
- } else {
- backupFilePath = await ScopedStorage.writeFile(
- androidBackupDirectory.uri,
- backupName,
- 'nnbackup/json',
- backup,
- 'utf8',
- false
- );
- }
- await MMKV.setItem('backupDate', JSON.stringify(Date.now()));
- await MMKV.setItem(
- 'askForBackup',
- JSON.stringify({
- timestamp: Date.now() + 86400000 * 3
- })
+ try {
+ let backupName = 'notesnook_backup_' + Date.now();
+ backupName = sanitizeFilename(backupName, { replacement: '_' }) + '.nnbackup';
+ let path;
+ let backupFilePath;
+
+ if (Platform.OS === 'ios') {
+ path = await storage.checkAndCreateDir('/backups/');
+ await RNFetchBlob.fs.writeFile(path + backupName, backup, 'utf8');
+ backupFilePath = path + backupName;
+ } else {
+ backupFilePath = await ScopedStorage.writeFile(
+ androidBackupDirectory.uri,
+ backupName,
+ 'nnbackup/json',
+ backup,
+ 'utf8',
+ false
);
+ }
- ToastEvent.show({
- heading: 'Backup successful',
- message: 'Your backup is stored in Notesnook folder on your phone.',
- type: 'success',
- context: 'global'
- });
- let dontShowCompleteSheet = await MMKV.getItem('dontShowCompleteSheet');
- console.log(backupFilePath);
- await sleep(300);
- if (!dontShowCompleteSheet) {
- presentSheet({
- title: 'Backup complete',
- icon: 'cloud-upload',
- paragraph: `${
- Platform.OS === 'android'
- ? 'Backup file saved in "Notesnook backups" folder on your phone'
- : 'Backup file is saved in File Manager/Notesnook folder'
- }. Share your backup to your cloud so you do not lose it.`,
- actionText: 'Share backup',
- actionsArray: [
- {
- action: () => {
- if (Platform.OS === 'ios') {
- console.log(backupFilePath);
- Share.open({
- url: 'file:/' + backupFilePath,
- failOnCancel: false
- }).catch(console.log);
- } else {
- FileViewer.open(backupFilePath, {
- showOpenWithDialog: true,
- showAppsSuggestions: true,
- shareFile: true
- }).catch(console.log);
- }
- },
- actionText: 'Share'
- },
- {
- action: async () => {
- eSendEvent(eCloseProgressDialog);
- await MMKV.setItem('dontShowCompleteSheet', 'yes');
- },
- actionText: 'Never ask again',
- type: 'grayBg'
- }
- ]
- });
- } else {
- eSendEvent(eCloseProgressDialog);
- }
- return backupFilePath;
- } catch (e) {
- console.log('backup error: ', e);
- await sleep(300);
+ updateNextBackupTime();
+
+ ToastEvent.show({
+ heading: 'Backup successful',
+ message: 'Your backup is stored in Notesnook folder on your phone.',
+ type: 'success',
+ context: 'global'
+ });
+
+ let dontShowCompleteSheet = await MMKV.getItem('dontShowCompleteSheet');
+ console.log(backupFilePath);
+ await sleep(300);
+ if (!dontShowCompleteSheet) {
+ presentBackupCompleteSheet(backupFilePath);
+ } else {
eSendEvent(eCloseProgressDialog);
- ToastEvent.show({
- heading: 'Backup failed',
- message: e.message,
- type: 'error',
- context: 'global',
- actionText: 'Copy logs',
- func: () => {
- Clipboard.setString(e.stack);
- ToastEvent.show({
- heading: 'Logs copied!',
- type: 'success',
- context: 'global'
- });
- }
- });
}
- } else {
+ return backupFilePath;
+ } catch (e) {
await sleep(300);
eSendEvent(eCloseProgressDialog);
- ToastEvent.show({
- heading: 'Backup failed',
- message: error?.message || '',
- type: 'error',
- context: 'global',
- actionText: 'Copy logs',
- func: () => {
- Clipboard.setString(error.stack);
- ToastEvent.show({
- heading: 'Logs copied!',
- type: 'success',
- context: 'global'
- });
- }
- });
-
- return null;
+ ToastEvent.error(e, 'Backup failed!');
}
}
@@ -257,10 +231,12 @@ const checkAndRun = async () => {
}
};
-export default {
+const BackupService = {
checkBackupRequired,
run,
checkAndRun,
getDirectoryAndroid,
checkBackupDirExists
};
+
+export default BackupService;
diff --git a/apps/mobile/src/services/BiometricService.js b/apps/mobile/src/services/biometrics.ts
similarity index 76%
rename from apps/mobile/src/services/BiometricService.js
rename to apps/mobile/src/services/biometrics.ts
index 106a38c83..d3d5b1305 100644
--- a/apps/mobile/src/services/BiometricService.js
+++ b/apps/mobile/src/services/biometrics.ts
@@ -1,10 +1,10 @@
+import { Platform } from 'react-native';
import FingerprintScanner from 'react-native-fingerprint-scanner';
-import Storage from '../utils/database/storage';
-import { ToastEvent } from './EventManager';
import * as Keychain from 'react-native-keychain';
-import { Platform } from 'react-native';
+import { useSettingStore } from '../stores/stores';
import { MMKV } from '../utils/database/mmkv';
-import { useSettingStore } from '../provider/stores';
+import Storage from '../utils/database/storage';
+import { ShowToastEvent, ToastEvent } from './event-manager';
const CRYPT_CONFIG = Platform.select({
ios: {
@@ -29,10 +29,10 @@ async function enableFingerprintAuth() {
}
async function isFingerprintAuthEnabled() {
- return await MMKV.getStringAsync('fingerprintAuthEnabled', 'enabled');
+ return await MMKV.getStringAsync('fingerprintAuthEnabled');
}
-async function storeCredentials(password) {
+async function storeCredentials(password: string) {
await Keychain.setInternetCredentials('nn_vault', 'notesnookvault', password, CRYPT_CONFIG);
}
@@ -44,33 +44,35 @@ async function hasInternetCredentials() {
return await Keychain.hasInternetCredentials('nn_vault');
}
-async function getCredentials(title, description) {
+async function getCredentials(title?: string, description?: string) {
try {
useSettingStore.getState().setRequestBiometrics(true);
- await FingerprintScanner.authenticate(
- Platform.select({
- ios: {
- fallbackEnabled: true,
- description: description
- },
- android: {
- title: title,
- description: description,
- deviceCredentialAllowed: true
- }
- })
- );
+
+ let options = Platform.select({
+ ios: {
+ fallbackEnabled: true,
+ description: description
+ },
+ android: {
+ title: title,
+ description: description,
+ deviceCredentialAllowed: true
+ }
+ });
+ //@ts-ignore
+ await FingerprintScanner.authenticate(options);
FingerprintScanner.release();
- return await Keychain.getInternetCredentials('nn_vault', CRYPT_CONFIG);
+ return await Keychain.getInternetCredentials('nn_vault');
} catch (e) {
useSettingStore.getState().setRequestBiometrics(false);
FingerprintScanner.release();
- let message = {
+ let message: ShowToastEvent = {
heading: 'Authentication with biometrics failed.',
message: 'Tap "Biometric Unlock" to try again.',
type: 'error',
context: 'local'
};
+ //@ts-ignore
if (e.name === 'DeviceLocked') {
message = {
heading: 'Biometrics authentication failed.',
@@ -78,6 +80,7 @@ async function getCredentials(title, description) {
type: 'error',
context: 'local'
};
+ //@ts-ignore
} else if (e.name === 'UserFallback') {
message = {
heading: 'Authentication cancelled by user.',
@@ -92,9 +95,10 @@ async function getCredentials(title, description) {
}
}
-async function validateUser(title, description) {
+async function validateUser(title: string, description?: string) {
try {
await FingerprintScanner.authenticate(
+ //@ts-ignore
Platform.select({
ios: {
fallbackEnabled: true,
@@ -111,6 +115,7 @@ async function validateUser(title, description) {
return true;
} catch (e) {
FingerprintScanner.release();
+ //@ts-ignore
if (e.name === 'DeviceLocked') {
ToastEvent.show({
heading: 'Biometrics authentication failed.',
@@ -130,7 +135,7 @@ async function validateUser(title, description) {
}
}
-export default {
+const BiometicService = {
isBiometryAvailable,
enableFingerprintAuth,
isFingerprintAuthEnabled,
@@ -140,3 +145,5 @@ export default {
hasInternetCredentials,
validateUser
};
+
+export default BiometicService;
diff --git a/apps/mobile/src/services/DeviceDetection.js b/apps/mobile/src/services/devicedetection.js
similarity index 79%
rename from apps/mobile/src/services/DeviceDetection.js
rename to apps/mobile/src/services/devicedetection.js
index 3c88890f3..c13735b97 100644
--- a/apps/mobile/src/services/DeviceDetection.js
+++ b/apps/mobile/src/services/devicedetection.js
@@ -30,7 +30,6 @@ export class DeviceDetectionService {
this.isPhoneOrTablet();
this.isIosOrAndroid();
this.detectIphoneX();
- //console.log(size.width > size.height,"CALC")
this.checkSmallTab(size.width > size.height ? 'LANDSCAPE' : 'PORTRAIT');
}
@@ -49,18 +48,14 @@ export class DeviceDetectionService {
this.height = Dimensions.get('screen').height;
let deviceSize = this.getDeviceSize();
- //console.log(deviceSize, orientation, DeviceInfo.isTablet(), 'DATA');
if (
(!DeviceInfo.isTablet() && orientation === 'LANDSCAPE') ||
(DeviceInfo.isTablet() && (orientation === 'PORTRAIT' || deviceSize < 9))
) {
- //console.log('small tab')
this.isTab = true;
this.isPhone = false;
this.isSmallTab = true;
} else if (DeviceInfo.isTablet() && orientation === 'LANDSCAPE' && deviceSize > 9) {
- //console.log('large tab tab')
- //console.log('setting large tablet');
this.isTab = true;
this.isPhone = false;
this.isSmallTab = false;
@@ -78,26 +73,6 @@ export class DeviceDetectionService {
}
isPhoneOrTablet() {
- /* if (Platform.isPad) {
- this.isTab = true;
- this.isPhone = false;
- }
- if (
- this.pixelDensity < 2 &&
- (this.adjustedWidth >= 1000 || this.adjustedHeight >= 1000)
- ) {
- this.isTab = true;
- this.isPhone = false;
- } else if (
- this.pixelDensity === 2 &&
- (this.adjustedWidth >= 1920 || this.adjustedHeight >= 1920)
- ) {
- this.isTab = true;
- this.isPhone = false;
- } else {
- this.isTab = false;
- this.isPhone = true;
- } */
if (DeviceInfo.isTablet()) {
this.isTab = true;
this.isPhone = false;
diff --git a/apps/mobile/src/services/eventmanager.ts b/apps/mobile/src/services/eventmanager.ts
new file mode 100644
index 000000000..97da5c83f
--- /dev/null
+++ b/apps/mobile/src/services/eventmanager.ts
@@ -0,0 +1,116 @@
+import Clipboard from '@react-native-clipboard/clipboard';
+import EventManager from 'notes-core/utils/event-manager';
+import {
+ eHideToast,
+ eOnNoteEdited,
+ eOpenProgressDialog,
+ eOpenVaultDialog,
+ eShowToast
+} from '../utils/events';
+const eventManager = new EventManager();
+
+export const eSubscribeEvent = (eventName: string, action?: () => void) => {
+ eventManager.subscribe(eventName, action);
+};
+
+export const eUnSubscribeEvent = (eventName: string, action?: () => void) => {
+ eventManager.unsubscribe(eventName, action);
+};
+
+export const eSendEvent = (eventName: string, data?: any) => {
+ eventManager.publish(eventName, data);
+};
+
+/**
+ * @typedef {Object} vaultType
+ * @property {Object} item
+ * @property {boolean} novault
+ * @property {string} title
+ * @property {string} description
+ * @property {boolean} locked
+ * @property {boolean} permanant
+ * @property {boolean} goToEditor
+ * @property {boolean} share
+ * @property {boolean} deleteNote
+ * @property {boolean} fingerprintAccess
+ * @property {boolean} revokeFingerprintAccess
+ * @property {boolean} changePassword
+ * @property {boolean} clearVault
+ * @property {boolean} deleteVault
+ * @property {boolean} copyNote
+ * @param {vaultType} data
+ */
+export const openVault = (data: any) => {
+ eSendEvent(eOpenVaultDialog, data);
+};
+
+/**
+ * @typedef {Object} noteEdit
+ * @property {string} id
+ * @property {boolean} closed
+ * @property {boolean} noEdit
+ * @property {boolean} forced
+ * @param {noteEdit} data
+ */
+export function sendNoteEditedEvent(data: any) {
+ eSendEvent(eOnNoteEdited, data);
+}
+
+export function presentSheet(data: any) {
+ eSendEvent(eOpenProgressDialog, data);
+}
+
+export type ShowToastEvent = {
+ heading?: string;
+ message?: string;
+ context?: 'global' | 'local';
+ type?: 'error' | 'success';
+ duration?: number;
+ func?: () => void;
+ actionText?: string;
+};
+
+export const ToastEvent = {
+ show: ({
+ heading,
+ message,
+ type = 'error',
+ context,
+ duration,
+ func,
+ actionText
+ }: ShowToastEvent) =>
+ eSendEvent(eShowToast, {
+ heading: heading,
+ message: message,
+ type: type,
+ context: context,
+ duration: duration,
+ func: func,
+ actionText: actionText
+ }),
+ hide: () => eSendEvent(eHideToast),
+ error: (e: Error, title?: string, context?: 'global' | 'local') => {
+ ToastEvent.show({
+ heading: title,
+ message: e?.message || '',
+ type: 'error',
+ context: context || 'global',
+ actionText: 'Copy logs',
+ duration: 6000,
+ func: () => {
+ Clipboard.setString(e?.stack || '');
+ ToastEvent.show({
+ heading: 'Logs copied!',
+ type: 'success',
+ context: 'global',
+ duration: 5000
+ });
+ }
+ });
+ }
+};
+
+/*
+
+*/
diff --git a/apps/mobile/src/services/Exporter.js b/apps/mobile/src/services/exporter.js
similarity index 99%
rename from apps/mobile/src/services/Exporter.js
rename to apps/mobile/src/services/exporter.js
index b0feede8c..a961bb2b1 100644
--- a/apps/mobile/src/services/Exporter.js
+++ b/apps/mobile/src/services/exporter.js
@@ -483,9 +483,11 @@ async function saveToHTML(note) {
};
}
-export default {
+const Exporter = {
saveToHTML,
saveToText,
saveToMarkdown,
saveToPDF
};
+
+export default Exporter;
diff --git a/apps/mobile/src/services/Message.js b/apps/mobile/src/services/message.js
similarity index 93%
rename from apps/mobile/src/services/Message.js
rename to apps/mobile/src/services/message.js
index f2d89ae08..1f0fc80c0 100644
--- a/apps/mobile/src/services/Message.js
+++ b/apps/mobile/src/services/message.js
@@ -1,7 +1,7 @@
-import { useMessageStore } from '../provider/stores';
+import { useMessageStore } from '../stores/stores';
import { eOpenLoginDialog, eOpenRateDialog, eOpenRecoveryKeyDialog } from '../utils/events';
-import { eSendEvent } from './EventManager';
-import PremiumService from './PremiumService';
+import { eSendEvent } from './event-manager';
+import PremiumService from './premium';
import { verifyUser } from '../screens/settings/functions';
import { MMKV } from '../utils/database/mmkv';
import { Platform } from 'react-native';
diff --git a/apps/mobile/src/services/Navigation.js b/apps/mobile/src/services/navigation.js
similarity index 96%
rename from apps/mobile/src/services/Navigation.js
rename to apps/mobile/src/services/navigation.js
index 0434858db..8fa8bde29 100755
--- a/apps/mobile/src/services/Navigation.js
+++ b/apps/mobile/src/services/navigation.js
@@ -5,11 +5,11 @@ import {
useNoteStore,
useTagStore,
useTrashStore
-} from '../provider/stores';
+} from '../stores/stores';
import { eOnNewTopicAdded, refreshNotesPage } from '../utils/events';
import { rootNavigatorRef, tabBarRef } from '../utils/global-refs';
-import { eSendEvent } from './EventManager';
-import SettingsService from './SettingsService';
+import { eSendEvent } from './event-manager';
+import SettingsService from './settings';
let currentScreen = 'Notes';
let homeLoaded = false;
@@ -167,7 +167,7 @@ function closeDrawer() {
tabBarRef.current?.closeDrawer();
}
-export default {
+const Navigation = {
navigate,
goBack,
push,
@@ -184,3 +184,5 @@ export default {
getHomeLoaded,
setHomeLoaded
};
+
+export default Navigation;
diff --git a/apps/mobile/src/services/Notifications.ts b/apps/mobile/src/services/notifications.ts
similarity index 95%
rename from apps/mobile/src/services/Notifications.ts
rename to apps/mobile/src/services/notifications.ts
index 4a114d028..41bf333e7 100644
--- a/apps/mobile/src/services/Notifications.ts
+++ b/apps/mobile/src/services/notifications.ts
@@ -8,10 +8,10 @@ import { db } from '../utils/database';
import { MMKV } from '../utils/database/mmkv';
import { eOnLoadNote } from '../utils/events';
import { tabBarRef } from '../utils/global-refs';
-import { useNoteStore } from './../provider/stores';
-import { DDS } from './DeviceDetection';
-import { eSendEvent } from './EventManager';
-import SettingsService from './SettingsService';
+import { useNoteStore } from '../stores/stores';
+import { DDS } from './device-detection';
+import { eSendEvent } from './event-manager';
+import SettingsService from './settings';
const NOTIFICATION_TAG = 'notesnook';
const CHANNEL_ID = 'com.streetwriters.notesnook';
@@ -209,7 +209,7 @@ function get(): Promise<PushNotificationDeliveredObject[]> {
});
}
-export default {
+const Notifications = {
init,
present,
clearAll,
@@ -219,3 +219,5 @@ export default {
pinQuickNote,
unpinQuickNote
};
+
+export default Notifications;
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/premium.js
similarity index 98%
rename from apps/mobile/src/services/PremiumService.js
rename to apps/mobile/src/services/premium.js
index 1a32ba0f1..9fcb0b68f 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/premium.js
@@ -6,12 +6,12 @@ import DialogHeader from '../components/dialog/dialog-header';
import { CompactFeatures } from '../components/premium/compact-features';
import { PricingPlans } from '../components/premium/pricing-plans';
import Seperator from '../components/ui/seperator';
-import { useUserStore } from '../provider/stores';
+import { useUserStore } from '../stores/stores';
import { itemSkus, SUBSCRIPTION_STATUS } from '../utils/constants';
import { db } from '../utils/database';
import { eOpenPremiumDialog, eOpenTrialEndingDialog, eShowGetPremium } from '../utils/events';
import { MMKV } from '../utils/database/mmkv';
-import { eSendEvent, presentSheet, ToastEvent } from './EventManager';
+import { eSendEvent, presentSheet, ToastEvent } from './event-manager';
let premiumStatus = 0;
let products = [];
@@ -338,7 +338,7 @@ const sheet = (context, promo, trial) => {
});
};
-export default {
+const PremiumService = {
verify,
setPremiumStatus,
get,
@@ -351,3 +351,5 @@ export default {
getRemainingTrialDaysStatus,
sheet
};
+
+export default PremiumService;
diff --git a/apps/mobile/src/services/SearchService.js b/apps/mobile/src/services/search.js
similarity index 91%
rename from apps/mobile/src/services/SearchService.js
rename to apps/mobile/src/services/search.js
index 607731eea..ccf833303 100644
--- a/apps/mobile/src/services/SearchService.js
+++ b/apps/mobile/src/services/search.js
@@ -1,4 +1,4 @@
-import { useSearchStore } from '../provider/stores';
+import { useSearchStore } from '../stores/stores';
import { db } from '../utils/database';
let searchInformation = {
@@ -48,9 +48,11 @@ function getSearchInformation() {
return searchInformation;
}
-export default {
+const SearchService = {
update,
getSearchInformation,
search,
setTerm
};
+
+export default SearchService;
diff --git a/apps/mobile/src/services/settings.ts b/apps/mobile/src/services/settings.ts
new file mode 100644
index 000000000..2d0ee4bce
--- /dev/null
+++ b/apps/mobile/src/services/settings.ts
@@ -0,0 +1,84 @@
+import { Platform, Settings } from 'react-native';
+import { enabled } from 'react-native-privacy-snapshot';
+import { SettingStore } from '../stores/interfaces';
+import { useSettingStore } from '../stores/stores';
+import { useThemeStore } from '../stores/theme';
+import { AndroidModule } from '../utils';
+import { getColorScheme } from '../utils/color-scheme/utils';
+import { MMKV } from '../utils/database/mmkv';
+import { scale, updateSize } from '../utils/size';
+import Notifications from './notifications';
+
+async function init() {
+ scale.fontScale = 1;
+ let settingsJson = await MMKV.getItem('appSettings');
+ let settings = get();
+ if (!settingsJson) {
+ await MMKV.setItem('appSettings', JSON.stringify(settingsJson));
+ } else {
+ settings = JSON.parse(settingsJson);
+ if (!settings.appLockMode) {
+ settings.appLockMode = 'none';
+ }
+ // eslint-disable-next-line no-prototype-builtins
+ if (!settings.hasOwnProperty('telemetry')) {
+ settings.telemetry = true;
+ }
+ if (!settings.notesListMode) {
+ settings.notesListMode = 'normal';
+ }
+ if (!settings.notebooksListMode) {
+ settings.notebooksListMode = 'normal';
+ }
+ }
+ if (settings.notifNotes) {
+ Notifications.pinQuickNote(true);
+ }
+
+ if (settings.fontScale) {
+ scale.fontScale = settings.fontScale;
+ }
+ if (settings.privacyScreen || settings.appLockMode === 'background') {
+ if (Platform.OS === 'android') {
+ AndroidModule.setSecureMode(true);
+ } else {
+ enabled(true);
+ }
+ } else {
+ if (Platform.OS === 'android') {
+ AndroidModule.setSecureMode(false);
+ } else {
+ enabled(false);
+ }
+ }
+ updateSize();
+ useSettingStore.getState().setSettings({ ...settings });
+ setTheme();
+ return;
+}
+
+const setTheme = async () => {
+ let settings = get();
+ let newColors = await getColorScheme(settings.useSystemTheme);
+ useThemeStore.getState().setColors({ ...newColors });
+};
+
+async function set(name: keyof SettingStore['settings'], value: any) {
+ let settings = get();
+ settings[name] = value;
+ useSettingStore.getState().setSettings(settings);
+ await MMKV.setItem('appSettings', JSON.stringify(settings));
+}
+
+function get() {
+ return { ...useSettingStore.getState().settings };
+}
+
+const SettingsService = {
+ init,
+ setTheme,
+ set,
+ get
+};
+
+export default SettingsService;
diff --git a/apps/mobile/src/services/Sync.js b/apps/mobile/src/services/sync.js
similarity index 92%
rename from apps/mobile/src/services/Sync.js
rename to apps/mobile/src/services/sync.js
index 23430d5ad..bf20f2638 100644
--- a/apps/mobile/src/services/Sync.js
+++ b/apps/mobile/src/services/sync.js
@@ -1,10 +1,10 @@
import Clipboard from '@react-native-clipboard/clipboard';
import NetInfo from '@react-native-community/netinfo';
-import { initialize, useUserStore } from '../provider/stores';
+import { initialize, useUserStore } from '../stores/stores';
import { doInBackground } from '../utils';
import { db } from '../utils/database';
import { getNote, updateNoteInEditor } from '../screens/editor/Functions';
-import { ToastEvent } from './EventManager';
+import { ToastEvent } from './event-manager';
let retryCount = 0;
const run = async (context = 'global', forced) => {
@@ -68,6 +68,8 @@ const run = async (context = 'global', forced) => {
return result;
};
-export default {
+const Sync = {
run
};
+
+export default Sync;
diff --git a/apps/mobile/src/services/Validation.js b/apps/mobile/src/services/validation.js
similarity index 55%
rename from apps/mobile/src/services/Validation.js
rename to apps/mobile/src/services/validation.js
index b7ab2cd99..06fec7e5e 100644
--- a/apps/mobile/src/services/Validation.js
+++ b/apps/mobile/src/services/validation.js
@@ -10,10 +10,6 @@ export function validateEmail(email) {
export const ERRORS_LIST = {
SHORT_PASS: 'Atleast 8 characters'
- // NO_ABC: 'Atleast 1 lowercase letter.',
- // NO_CAPS_ABC: 'Atleast 1 capital letter.',
- // NO_NUM: 'Atleast 1 number',
- // SPECIAL: 'Atleast 1 special character',
};
export function validatePass(password) {
@@ -28,19 +24,6 @@ export function validatePass(password) {
if (password.length >= 8) {
errors.SHORT_PASS = false;
}
-
- /* if (password.match(/[a-z]+/)) {
- errors.NO_ABC = false;
- }
- if (password.match(/[A-Z]+/)) {
- errors.NO_CAPS_ABC = false;
- }
- if (password.match(/[0-9]+/)) {
- errors.NO_NUM = false;
- }
- if (password.match(/[$@#&!_]+/)) {
- errors.SPECIAL = false;
- } */
return errors;
}
@@ -52,8 +35,3 @@ export function validateUsername(username) {
return false;
}
}
-
-export async function checkPremiumUser() {
- //let user = await db.user.get();
- return false;
-}
diff --git a/apps/mobile/src/provider/interfaces.ts b/apps/mobile/src/stores/interfaces.ts
similarity index 100%
rename from apps/mobile/src/provider/interfaces.ts
rename to apps/mobile/src/stores/interfaces.ts
diff --git a/apps/mobile/src/provider/stores.ts b/apps/mobile/src/stores/stores.ts
similarity index 99%
rename from apps/mobile/src/provider/stores.ts
rename to apps/mobile/src/stores/stores.ts
index 220eb11a9..6f89c2605 100644
--- a/apps/mobile/src/provider/stores.ts
+++ b/apps/mobile/src/stores/stores.ts
@@ -3,8 +3,8 @@ import { groupArray } from 'notes-core/utils/grouping';
import { Dimensions, Platform } from 'react-native';
import create from 'zustand';
import { APP_VERSION } from '../../version';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../services/EventManager';
-import PremiumService from '../services/PremiumService';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../services/event-manager';
+import PremiumService from '../services/premium';
import { history } from '../utils';
import { SUBSCRIPTION_STATUS } from '../utils/constants';
import { db } from '../utils/database';
diff --git a/apps/mobile/src/stores/theme.ts b/apps/mobile/src/stores/theme.ts
new file mode 100644
index 000000000..3dd5f8185
--- /dev/null
+++ b/apps/mobile/src/stores/theme.ts
@@ -0,0 +1,16 @@
+import { Appearance } from 'react-native';
+import create, { State } from 'zustand';
+import { COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from '../utils/color-scheme';
+
+const darkScheme = Appearance.getColorScheme() === 'dark';
+export interface ThemeStore extends State {
+ colors: typeof COLOR_SCHEME_LIGHT;
+ setColors: (colors: typeof COLOR_SCHEME_LIGHT) => void;
+}
+
+export const useThemeStore = create<ThemeStore>((set, get) => ({
+ colors: darkScheme ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT,
+ setColors: colors => {
+ set({ colors });
+ }
+}));
diff --git a/apps/mobile/src/utils/analytics/index.js b/apps/mobile/src/utils/analytics/index.js
index 43e8461f5..96adaad8d 100644
--- a/apps/mobile/src/utils/analytics/index.js
+++ b/apps/mobile/src/utils/analytics/index.js
@@ -1,6 +1,6 @@
import { Platform } from 'react-native';
import { MMKV } from '../database/mmkv';
-import { useSettingStore } from '../../provider/stores';
+import { useSettingStore } from '../../stores/stores';
const WEBSITE_ID = `3c6890ce-8410-49d5-8831-15fb2eb28a21`;
const baseUrl = `https://analytics.streetwriters.co/api/collect`;
diff --git a/apps/mobile/src/utils/colorscheme/index.js b/apps/mobile/src/utils/colorscheme/index.js
index 0f2125831..28e34bb43 100644
--- a/apps/mobile/src/utils/colorscheme/index.js
+++ b/apps/mobile/src/utils/colorscheme/index.js
@@ -1,6 +1,6 @@
import { Platform, StatusBar } from 'react-native';
import { AndroidModule } from '..';
-import { eSendEvent } from '../../services/EventManager';
+import { eSendEvent } from '../../services/event-manager';
import { eThemeUpdated } from '../events';
export const ACCENT = {
@@ -46,9 +46,14 @@ export var COLOR_SCHEME = {
bg: '#ffffff',
navbg: '#f7f7f7',
nav: '#f7f7f7',
- pri: '#424242',
- sec: 'white',
- light: '#ffffff'
+ input: 'transparent',
+ heading: '#212121',
+ pri: '#505050',
+ sec: '#ffffff',
+ light: '#ffffff',
+ transGray: '#00000010',
+ border: '#E8E8E8',
+ placeholder: '#a9a9a9'
};
export const COLOR_SCHEME_LIGHT = {
diff --git a/apps/mobile/src/utils/colorscheme/utils.js b/apps/mobile/src/utils/colorscheme/utils.js
index 03225feb5..9e74db46b 100644
--- a/apps/mobile/src/utils/colorscheme/utils.js
+++ b/apps/mobile/src/utils/colorscheme/utils.js
@@ -1,6 +1,6 @@
import { Appearance } from 'react-native';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import SettingsService from '../../services/SettingsService';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
+import SettingsService from '../../services/settings';
import {
ACCENT,
COLOR_SCHEME,
diff --git a/apps/mobile/src/utils/constants.js b/apps/mobile/src/utils/constants.js
index 6de39c16e..221332605 100644
--- a/apps/mobile/src/utils/constants.js
+++ b/apps/mobile/src/utils/constants.js
@@ -1,6 +1,6 @@
import { Platform } from 'react-native';
-import { eSendEvent } from '../services/EventManager';
-import Navigation from '../services/Navigation';
+import { eSendEvent } from '../services/event-manager';
+import Navigation from '../services/navigation';
import { refreshNotesPage } from './events';
export const STORE_LINK =
diff --git a/apps/mobile/src/utils/events.js b/apps/mobile/src/utils/events.js
index a6025c672..52959daf2 100644
--- a/apps/mobile/src/utils/events.js
+++ b/apps/mobile/src/utils/events.js
@@ -24,8 +24,6 @@ export const eOpenLoginDialog = '511';
export const eCloseLoginDialog = '512';
-export const eDispatchAction = '513';
-
export const eLoginDialogNavigateBack = '514';
export const eOpenSideMenu = '515';
diff --git a/apps/mobile/src/utils/filesystem/download.js b/apps/mobile/src/utils/filesystem/download.js
index 15bfa1730..4d4b4445b 100644
--- a/apps/mobile/src/utils/filesystem/download.js
+++ b/apps/mobile/src/utils/filesystem/download.js
@@ -4,8 +4,8 @@ import * as ScopedStorage from 'react-native-scoped-storage';
import Sodium from 'react-native-sodium';
import RNFetchBlob from 'rn-fetch-blob';
import { ShareComponent } from '../../components/sheets/export-notes/share';
-import { useAttachmentStore } from '../../provider/stores';
-import { presentSheet, ToastEvent } from '../../services/EventManager';
+import { useAttachmentStore } from '../../stores/stores';
+import { presentSheet, ToastEvent } from '../../services/event-manager';
import { db } from '../database';
import Storage from '../database/storage';
import { cacheDir, fileCheck } from './utils';
diff --git a/apps/mobile/src/utils/filesystem/upload.js b/apps/mobile/src/utils/filesystem/upload.js
index 15dfd6582..19a988b24 100644
--- a/apps/mobile/src/utils/filesystem/upload.js
+++ b/apps/mobile/src/utils/filesystem/upload.js
@@ -1,5 +1,5 @@
import RNFetchBlob from 'rn-fetch-blob';
-import { useAttachmentStore } from '../../provider/stores';
+import { useAttachmentStore } from '../../stores/stores';
import { db } from '../database';
import { cacheDir } from './utils';
diff --git a/apps/mobile/src/utils/functions.js b/apps/mobile/src/utils/functions.js
index 51065e2ea..bf52585d2 100644
--- a/apps/mobile/src/utils/functions.js
+++ b/apps/mobile/src/utils/functions.js
@@ -1,9 +1,9 @@
import { Linking } from 'react-native';
import { InAppBrowser } from 'react-native-inappbrowser-reborn';
import { history } from '.';
-import { useMenuStore, useSelectionStore } from '../provider/stores';
-import { eSendEvent, ToastEvent } from '../services/EventManager';
-import Navigation from '../services/Navigation';
+import { useMenuStore, useSelectionStore } from '../stores/stores';
+import { eSendEvent, ToastEvent } from '../services/event-manager';
+import Navigation from '../services/navigation';
import { db } from './database';
import { eClearEditor } from './events';
diff --git a/apps/mobile/src/utils/hooks/useActions.js b/apps/mobile/src/utils/hooks/useActions.js
index 0d1edd764..c4bc2fe6d 100644
--- a/apps/mobile/src/utils/hooks/useActions.js
+++ b/apps/mobile/src/utils/hooks/useActions.js
@@ -3,15 +3,15 @@ import React, { useEffect, useState } from 'react';
import { Platform } from 'react-native';
import Share from 'react-native-share';
import { notesnook } from '../../../e2e/test.ids';
-import { useTracked } from '../../provider';
-import { Actions } from '../../provider/Actions';
+import { useThemeStore } from '../../stores/theme';
+import { Actions } from '../../stores/Actions';
import {
useEditorStore,
useMenuStore,
useSelectionStore,
useTagStore,
useUserStore
-} from '../../provider/stores';
+} from '../../stores/stores';
import {
eSendEvent,
eSubscribeEvent,
@@ -19,10 +19,10 @@ import {
openVault,
presentSheet,
ToastEvent
-} from '../../services/EventManager';
-import Navigation from '../../services/Navigation';
-import Notifications from '../../services/Notifications';
-import SettingsService from '../../services/SettingsService';
+} from '../../services/event-manager';
+import Navigation from '../../services/navigation';
+import Notifications from '../../services/notifications';
+import SettingsService from '../../services/settings';
import { editing, toTXT } from '..';
import {
ACCENT,
@@ -52,8 +52,7 @@ import tiny from '../../screens/editor/tiny/tiny.js';
import { EditorWebView } from '../../screens/editor/Functions';
export const useActions = ({ close = () => {}, item }) => {
- const [state, dispatch] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const clearSelection = useSelectionStore(state => state.clearSelection);
const setSelectedItem = useSelectionStore(state => state.setSelectedItem);
const setMenuPins = useMenuStore(state => state.setMenuPins);
@@ -118,7 +117,7 @@ export const useActions = ({ close = () => {}, item }) => {
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent);
- dispatch({ type: Actions.THEME, colors: newColors });
+ useThemeStore.getState().setColors({ ...newColors });
}
function switchTheme() {
diff --git a/apps/mobile/src/utils/hooks/useAppEvents.js b/apps/mobile/src/utils/hooks/useAppEvents.js
index 6af29c506..afaf6a87b 100644
--- a/apps/mobile/src/utils/hooks/useAppEvents.js
+++ b/apps/mobile/src/utils/hooks/useAppEvents.js
@@ -20,25 +20,25 @@ import {
useNoteStore,
useSettingStore,
useUserStore
-} from '../../provider/stores';
-import Backup from '../../services/Backup';
-import BiometricService from '../../services/BiometricService';
+} from '../../stores/stores';
+import Backup from '../../services/backup';
+import BiometricService from '../../services/biometrics';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet,
ToastEvent
-} from '../../services/EventManager';
+} from '../../services/event-manager';
import {
clearMessage,
setEmailVerifyMessage,
setLoginMessage,
setRecoveryKeyMessage
-} from '../../services/Message';
-import PremiumService from '../../services/PremiumService';
-import SettingsService from '../../services/SettingsService';
-import Sync from '../../services/Sync';
+} from '../../services/message';
+import PremiumService from '../../services/premium';
+import SettingsService from '../../services/settings';
+import Sync from '../../services/sync';
import {
EditorWebView,
getNote,
diff --git a/apps/mobile/src/utils/hooks/useEditorTags.ts b/apps/mobile/src/utils/hooks/useEditorTags.ts
index a23a289df..85b82c4b2 100644
--- a/apps/mobile/src/utils/hooks/useEditorTags.ts
+++ b/apps/mobile/src/utils/hooks/useEditorTags.ts
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
-import { useEditorStore, useTagStore } from '../../provider/stores';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useEditorStore, useTagStore } from '../../stores/stores';
+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { db } from '../database';
import { EditorWebView } from '../../screens/editor/Functions';
import tiny from '../../screens/editor/tiny/tiny';
diff --git a/apps/mobile/src/utils/hooks/useTooltip.ts b/apps/mobile/src/utils/hooks/useTooltip.ts
index 723bda803..06350a2f5 100644
--- a/apps/mobile/src/utils/hooks/useTooltip.ts
+++ b/apps/mobile/src/utils/hooks/useTooltip.ts
@@ -2,8 +2,8 @@ import { RefObject, useEffect, useRef } from 'react';
import { Platform } from 'react-native';
//@ts-ignore
import RNTooltips from 'react-native-tooltips';
-import { useTracked } from '../../provider';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
+import { useThemeStore } from '../../stores/theme';
+import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
import { Popup } from '../../services/tip-manager';
import useKeyboard from './use-keyboard';
@@ -30,8 +30,7 @@ export const hideAllTooltips = async () => {
* @returns
*/
const useTooltip = () => {
- const [state] = useTracked();
- const { colors } = state;
+ const colors = useThemeStore(state => state.colors);
const parent = useRef();
let keyboard = useKeyboard();
diff --git a/apps/mobile/src/utils/size/index.js b/apps/mobile/src/utils/size/index.js
index da0f22db5..4cab23deb 100644
--- a/apps/mobile/src/utils/size/index.js
+++ b/apps/mobile/src/utils/size/index.js
@@ -1,5 +1,5 @@
import { Dimensions, PixelRatio, Platform } from 'react-native';
-import { DDS } from '../../services/DeviceDetection';
+import { DDS } from '../../services/device-detection';
export const scale = {
fontScale: 1