A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
refactor
ammarahm-ed69a110e2eb5a
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex 39a51cfd8..d77335863 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -1,12 +1,10 @@-import React, {useEffect, useState} from 'react';-import {View} from 'react-native';+import React, {useEffect} from 'react';import Orientation from 'react-native-orientation';-import Animated, {Easing} from 'react-native-reanimated';-import AnimatedProgress from 'react-native-reanimated-progress-bar';import {SafeAreaProvider} from 'react-native-safe-area-context';import SplashScreen from 'react-native-splash-screen';import {AppRootEvents} from './AppRootEvents';import {RootView} from './initializer.root';+import AppLoader from './src/components/AppLoader';import {useTracked} from './src/provider';import {Actions} from './src/provider/Actions';import {DDS} from './src/services/DeviceDetection';@@ -15,19 +13,11 @@ import {eSubscribeEvent,eUnSubscribeEvent,} from './src/services/EventManager';-import Navigation from './src/services/Navigation';import SettingsService from './src/services/SettingsService';-import {- changeAppScale,- changeContainerScale,- ContainerScale,-} from './src/utils/Animations';import {db} from './src/utils/DB';import {eDispatchAction, eOpenSideMenu} from './src/utils/Events';-import {sleep} from './src/utils/TimeUtils';import EditorRoot from './src/views/Editor/EditorRoot';-let initStatus = false;const App = () => {const [, dispatch] = useTracked();@@ -35,8 +25,6 @@ const App = () => {useEffect(() => {(async () => {try {- scaleV.setValue(0.95);- opacityV.setValue(1);Orientation.getOrientation((e, r) => {DDS.checkSmallTab(r);dispatch({@@ -84,95 +72,9 @@ const App = () => {<RootView /><EditorRoot /><AppRootEvents />- <Overlay onLoad={loadMainApp} />+ <AppLoader onLoad={loadMainApp} /></SafeAreaProvider>);};export default App;--const scaleV = new Animated.Value(0.95);-const opacityV = new Animated.Value(1);-const Overlay = ({onLoad}) => {- const [state, dispatch] = useTracked();- const colors = state.colors;- const [loading, setLoading] = useState(true);- const [progress, setProgress] = useState(4);- const [opacity, setOpacity] = useState(true);-- const load = async () => {- db.notes.init().then(() => {- init = true;- dispatch({type: Actions.NOTES});- dispatch({type: Actions.FAVORITES});- dispatch({type: Actions.LOADING, loading: false});- eSendEvent(eOpenSideMenu);- });- setOpacity(false);- await sleep(150);- eSendEvent(eOpenSideMenu);- Animated.timing(opacityV, {- toValue: 0,- duration: 150,- easing: Easing.out(Easing.ease),- }).start();- Animated.timing(scaleV, {- toValue: 1,- duration: 150,- easing: Easing.out(Easing.ease),- }).start();- changeContainerScale(ContainerScale, 1, 500);- await sleep(150);- setLoading(false);- animation = false;- };-- useEffect(() => {- eSubscribeEvent('load_overlay', load);- onLoad();- return () => {- eUnSubscribeEvent('load_overlay', load);- };- }, []);-- return (- loading && (- <Animated.View- style={{- backgroundColor: opacity ? colors.bg : 'rgba(0,0,0,0)',- width: '100%',- height: '100%',- position: 'absolute',- zIndex: 999,- borderRadius: 10,- }}>- <Animated.View- onTouchStart={() => {- setLoading(false);- }}- style={{- backgroundColor: colors.bg,- width: '100%',- height: '100%',- justifyContent: 'center',- alignItems: 'center',- borderRadius: 10,- opacity: opacityV,- }}>- <View- style={{- height: 10,- flexDirection: 'row',- width: 100,- }}>- <AnimatedProgress- fill={colors.accent}- current={progress}- total={4}- />- </View>- </Animated.View>- </Animated.View>- )- );-};diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.jsnew file mode 100644index 000000000..666b912bc--- /dev/null+++ b/apps/mobile/src/components/AppLoader/index.js@@ -0,0 +1,101 @@+import React, {useEffect, useState} from 'react';+import {View} from 'react-native';+import Animated, {Easing} from 'react-native-reanimated';+import AnimatedProgress from 'react-native-reanimated-progress-bar';+import {useTracked} from '../../provider';+import {Actions} from '../../provider/Actions';+import {+ eSendEvent,+ eSubscribeEvent,+ eUnSubscribeEvent,+} from '../../services/EventManager';+import {changeContainerScale, ContainerScale} from '../../utils/Animations';+import { db } from '../../utils/DB';+import {eOpenSideMenu} from '../../utils/Events';+import { sleep } from '../../utils/TimeUtils';++const scaleV = new Animated.Value(0.95);+const opacityV = new Animated.Value(1);+const AppLoader = ({onLoad}) => {+ const [state, dispatch] = useTracked();+ const colors = state.colors;+ const [loading, setLoading] = useState(true);+ const [opacity, setOpacity] = useState(true);++ const load = async () => {+ db.notes.init().then(() => {+ dispatch({type: Actions.NOTES});+ dispatch({type: Actions.FAVORITES});+ dispatch({type: Actions.LOADING, loading: false});+ eSendEvent(eOpenSideMenu);+ });+ eSendEvent(eOpenSideMenu);+ setOpacity(false);+ await sleep(50);+ Animated.timing(opacityV, {+ toValue: 0,+ duration: 150,+ easing: Easing.out(Easing.ease),+ }).start();+ Animated.timing(scaleV, {+ toValue: 1,+ duration: 150,+ easing: Easing.out(Easing.ease),+ }).start();+ changeContainerScale(ContainerScale, 1, 500);+ await sleep(150);+ setLoading(false);+ animation = false;+ };++ useEffect(() => {+ eSubscribeEvent('load_overlay', load);+ onLoad();+ return () => {+ eUnSubscribeEvent('load_overlay', load);+ };+ }, []);++ return (+ loading && (+ <Animated.View+ style={{+ backgroundColor: opacity ? colors.bg : 'rgba(0,0,0,0)',+ width: '100%',+ height: '100%',+ position: 'absolute',+ zIndex: 999,+ borderRadius: 10,+ }}>+ <Animated.View+ onTouchStart={() => {+ setLoading(false);+ }}+ style={{+ backgroundColor: colors.bg,+ width: '100%',+ height: '100%',+ justifyContent: 'center',+ alignItems: 'center',+ borderRadius: 10,+ opacity: opacityV,+ }}>+ <View+ style={{+ height: 10,+ flexDirection: 'row',+ width: 100,+ }}>+ <AnimatedProgress+ fill={colors.accent}+ current={4}+ total={4}+ />+ </View>+ </Animated.View>+ </Animated.View>+ )+ );+};++export default AppLoader;