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
add ResultDialog
ammarahm-edc0d76de46f7a
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex 10f93fa36..66e7e6f93 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -28,7 +28,7 @@ import {db} from './src/utils/DB';import {DDS} from './src/services/DeviceDetection';import {MMKV} from './src/utils/mmkv';import Backup from './src/services/Backup';-import { setLoginMessage } from './src/services/Message';+import {setLoginMessage} from './src/services/Message';let firstLoad = true;let note = null;@@ -66,32 +66,28 @@ const App = () => {const updateTheme = async () => {let settings;- settings = await MMKV.getStringAsync('settings');- if (settings) {- settings = JSON.parse(settings);- if (settings.useSystemTheme) {- let newColors = await getColorScheme(settings.useSystemTheme);- dispatch({type: Actions.THEME, colors: newColors});- }+ settings = await MMKV.getStringAsync('settings');+ if (settings) {+ settings = JSON.parse(settings);+ if (settings.useSystemTheme) {+ let newColors = await getColorScheme(settings.useSystemTheme);+ dispatch({type: Actions.THEME, colors: newColors});}+ }};useEffect(() => {+ let message = 'Internet connection restored';+ let type = 'success';if (!netInfo.isConnected || !netInfo.isInternetReachable) {- db.user?.get().then((user) => {- if (user) {- ToastEvent.show('No internet connection', 'error');- } else {- }- });- } else {- db.user?.get().then((user) => {- if (user) {- ToastEvent.show('Internet connection restored', 'success');- } else {- }- });+ message = 'No internet connection';+ type = 'error';}+ db.user?.get().then((user) => {+ if (user) {+ ToastEvent.show(message, type);+ }+ });}, [netInfo]);const syncChanges = async () => {@@ -153,38 +149,37 @@ const App = () => {if (user) {dispatch({type: Actions.USER, user: user});await startSyncer();- }+ }} catch (e) {error = e;- console.log(e)- }- if (!user || !user.id) {- setLoginMessage(dispatch);- }- dispatch({type: Actions.ALL});- setInit(true);- backupData();+ console.log(e);+ }+ if (!user || !user.id) {+ setLoginMessage(dispatch);+ }+ dispatch({type: Actions.ALL});+ setInit(true);+ backupData();- if (error) {- setTimeout(() => {- ToastEvent.show(error.message);- }, 500);- }-+ if (error) {+ setTimeout(() => {+ ToastEvent.show(error.message);+ }, 500);+ }});}, []);async function backupData() {- await sleep(1000)- settings = await MMKV.getStringAsync('settings');- settings = JSON.parse(settings);- if (await Backup.checkBackupRequired(settings.reminder) ) {- try {- await Backup.run();- } catch(e) {- console.log(e);- }+ await sleep(1000);+ settings = await MMKV.getStringAsync('settings');+ settings = JSON.parse(settings);+ if (await Backup.checkBackupRequired(settings.reminder)) {+ try {+ await Backup.run();+ } catch (e) {+ console.log(e);}+ }}async function Initialize() {@@ -200,21 +195,20 @@ const App = () => {}firstLoad = false;}- settings = await MMKV.getStringAsync('settings');- console.log('settings',settings)- if (!settings) {- settings = defaultState.settings;- await MMKV.setStringAsync('settings', JSON.stringify(settings));- } else {- settings = JSON.parse(settings);- }- if (settings.fontScale) {- scale.fontScale = settings.fontScale;- }- dispatch({type: Actions.SETTINGS, settings: {...settings}});- updateSize();- await updateTheme();-+ settings = await MMKV.getStringAsync('settings');+ console.log('settings', settings);+ if (!settings) {+ settings = defaultState.settings;+ await MMKV.setStringAsync('settings', JSON.stringify(settings));+ } else {+ settings = JSON.parse(settings);+ }+ if (settings.fontScale) {+ scale.fontScale = settings.fontScale;+ }+ dispatch({type: Actions.SETTINGS, settings: {...settings}});+ updateSize();+ await updateTheme();}if (!init) {diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.jsindex 6d7139569..9fc9174f2 100644--- a/apps/mobile/src/components/DialogManager/index.js+++ b/apps/mobile/src/components/DialogManager/index.js@@ -43,6 +43,7 @@ import {VaultDialog} from '../VaultDialog';import {TEMPLATE_DELETE, TEMPLATE_PERMANANT_DELETE} from './Templates';import {hexToRGBA} from "../../utils/ColorUtils";import {DDS} from "../../services/DeviceDetection";+import ResultDialog from '../ResultDialog';export class DialogManager extends Component {constructor(props) {@@ -376,6 +377,8 @@ export class DialogManager extends Component {<ProgressDialog /><RestoreDialog/>++ <ResultDialog/></>);}diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/ProgressDialog/index.jsindex c49989fb7..1c7d70733 100644--- a/apps/mobile/src/components/ProgressDialog/index.js+++ b/apps/mobile/src/components/ProgressDialog/index.js@@ -11,7 +11,7 @@ import {DDS} from "../../services/DeviceDetection";const ProgressDialog = () => {const [state, dispatch] = useTracked();- const {colors, tags, premiumUser} = state;+ const {colors,} = state;const [visible, setVisible] = useState(false);const [dialogData, setDialogData] = useState({title: 'Loading',diff --git a/apps/mobile/src/components/RecoveryKeyDialog/index.js b/apps/mobile/src/components/RecoveryKeyDialog/index.jsindex 269698d4b..92163edd7 100644--- a/apps/mobile/src/components/RecoveryKeyDialog/index.js+++ b/apps/mobile/src/components/RecoveryKeyDialog/index.js@@ -5,11 +5,12 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import RNFetchBlob from 'rn-fetch-blob';import {LOGO_BASE64} from '../../assets/images/assets';import {+ eSendEvent,eSubscribeEvent,eUnSubscribeEvent,ToastEvent,} from '../../services/EventManager';-import {eOpenRecoveryKeyDialog} from '../../utils/Events';+import {eOpenRecoveryKeyDialog, eOpenResultDialog} from '../../utils/Events';import {dWidth} from '../../utils';import ActionSheet from '../ActionSheet';import {Button} from '../Button';@@ -27,14 +28,28 @@ class RecoveryKeyDialog extends React.Component {this.actionSheetRef = createRef();this.svg = createRef();this.user;+ this.signup = false;}- open = () => {+ open = (signup) => {+ if (signup) {+ this.signup = true;+ }this.actionSheetRef.current?._setModalVisible(true);};close = () => {this.actionSheetRef.current?._setModalVisible(false);+ if (!this.signup) {+ setTimeout(() => {+ eSendEvent(eOpenResultDialog, {+ title: 'Welcome!',+ paragraph: 'Your 14 day trial for Notesnook Pro is activated',+ icon: 'checkbox-marked-circle',+ button: 'Thank You!',+ });+ }, 500);+ }};async componentDidMount() {eSubscribeEvent(eOpenRecoveryKeyDialog, this.open);@@ -113,6 +128,7 @@ class RecoveryKeyDialog extends React.Component {alignSelf: 'center',borderRadius: 10,}}+ closeOnTouchBackdrop={false}onOpen={this.onOpen}ref={this.actionSheetRef}initialOffsetFromBottom={1}>@@ -233,7 +249,13 @@ class RecoveryKeyDialog extends React.Component {data or reset your password using this recovery key.</Text></View>-+ <Seperator />+ <Button+ title="I have saved the key."+ width="100%"+ height={50}+ onPress={this.close}+ /><Toast context="local" /></View></ActionSheet>diff --git a/apps/mobile/src/components/ResultDialog/index.js b/apps/mobile/src/components/ResultDialog/index.jsnew file mode 100644index 000000000..13832b313--- /dev/null+++ b/apps/mobile/src/components/ResultDialog/index.js@@ -0,0 +1,85 @@+import React, {useEffect, useState} from 'react';+import {Text, View} from 'react-native';+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';+import {useTracked} from '../../provider';+import {DDS} from '../../services/DeviceDetection';+import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';+import {getElevation} from '../../utils';+import {eCloseResultDialog, eOpenResultDialog} from '../../utils/Events';+import {ph, SIZE, WEIGHT} from '../../utils/SizeUtils';+import {Button} from '../Button';+import BaseDialog from '../Dialog/base-dialog';+import Seperator from '../Seperator';++const ResultDialog = () => {+ const [state, dispatch] = useTracked();+ const {colors} = state;+ const [visible, setVisible] = useState(false);+ const [dialogData, setDialogData] = useState({+ title: '',+ paragraph: '',+ icon: null,+ button: null,+ });+ useEffect(() => {+ eSubscribeEvent(eOpenResultDialog, open);+ eSubscribeEvent(eCloseResultDialog, close);+ return () => {+ eUnSubscribeEvent(eOpenResultDialog, open);+ eUnSubscribeEvent(eCloseResultDialog, close);+ };+ }, []);++ const open = (data) => {+ setDialogData(data);+ setVisible(true);+ };++ const close = () => {+ setVisible(false);+ };++ return (+ <BaseDialog visible={visible} onRequestClose={close}>+ <View+ style={{+ ...getElevation(5),+ width: DDS.isTab ? 350 : '80%',+ maxHeight: 350,+ borderRadius: 5,+ backgroundColor: colors.bg,+ paddingHorizontal: ph,+ paddingVertical: 20,+ justifyContent: 'center',+ alignItems: 'center',+ }}>+ <Icon name={dialogData.icon} color={colors.accent} size={80} />+ <Text+ style={{+ fontFamily: WEIGHT.bold,+ alignSelf: 'center',+ textAlign: 'center',+ color: colors.heading,+ fontSize: SIZE.lg,+ marginTop: 10,+ }}>+ {dialogData.title}+ </Text>+ <Text+ style={{+ fontFamily: WEIGHT.regular,+ alignSelf: 'center',+ textAlign: 'center',+ color: colors.icon,+ fontSize: SIZE.sm,+ }}>+ {dialogData.paragraph}+ </Text>+ <Seperator />+ <Button title={dialogData.button} width="100%" onPress={close} />+ </View>+ </BaseDialog>+ );+};++export default ResultDialog;diff --git a/apps/mobile/src/utils/Events.js b/apps/mobile/src/utils/Events.jsindex 01d4278d1..3c4993c60 100644--- a/apps/mobile/src/utils/Events.js+++ b/apps/mobile/src/utils/Events.js@@ -110,4 +110,7 @@ export const eCloseRestoreDialog = '554';export const eOnNoteEdited = '555';-export const eUpdateSearchState = '556';\ No newline at end of file+export const eUpdateSearchState = '556';++export const eOpenResultDialog = '557';+export const eCloseResultDialog = '558';\ No newline at end of filediff --git a/apps/mobile/src/utils/Storage.js b/apps/mobile/src/utils/Storage.jsindex 241d30d9e..9ed40cd7e 100644--- a/apps/mobile/src/utils/Storage.js+++ b/apps/mobile/src/utils/Storage.js@@ -96,9 +96,6 @@ async function requestPermission() {}return granted;}---async function checkAndCreateDir(path) {let dir = Platform.OS === "ios"? IOS_PATH + path : ANDROID_PATH + path;try {diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.jsindex ab7d31efc..77d06f90b 100755--- a/apps/mobile/src/views/Home/index.js+++ b/apps/mobile/src/views/Home/index.js@@ -6,9 +6,14 @@ import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';import {eSendEvent} from '../../services/EventManager';-import {eOnLoadNote, eScrollEvent, eUpdateSearchState} from '../../utils/Events';+import {+ eOnLoadNote,+ eScrollEvent,+ eUpdateSearchState,+} from '../../utils/Events';import {openEditorAnimation} from '../../utils/Animations';-import {DDS} from "../../services/DeviceDetection";+import {DDS} from '../../services/DeviceDetection';+import ResultDialog from '../../components/ResultDialog';export const Home = ({navigation}) => {const [state, dispatch] = useTracked();@@ -16,13 +21,14 @@ export const Home = ({navigation}) => {const onFocus = useCallback(() => {dispatch({- type: Actions.HEADER_VERTICAL_MENU,- state: true,+ type: Actions.HEADER_VERTICAL_MENU,+ state: notes.length > 0,});+dispatch({type: Actions.HEADER_TEXT_STATE,state: {- heading: "Home",+ heading: 'Home',},});dispatch({@@ -33,20 +39,19 @@ export const Home = ({navigation}) => {type: Actions.HEADER_STATE,state: true,});- eSendEvent(eUpdateSearchState,{+ eSendEvent(eUpdateSearchState, {placeholder: 'Search all notes',data: notes,noSearch: false,type: 'notes',color: null,- })+ });eSendEvent(eScrollEvent, 0);dispatch({type: Actions.COLORS});dispatch({type: Actions.NOTES});}, [notes]);- const onBlur = useCallback(() => {- }, []);+ const onBlur = useCallback(() => {}, []);useEffect(() => {navigation.addListener('focus', onFocus);@@ -59,18 +64,22 @@ export const Home = ({navigation}) => {useEffect(() => {if (navigation.isFocused()) {- eSendEvent(eUpdateSearchState,{+ dispatch({+ type: Actions.HEADER_VERTICAL_MENU,+ state: notes.length > 0,+ });++ eSendEvent(eUpdateSearchState, {placeholder: 'Search all notes',data: notes,noSearch: false,type: 'notes',color: null,- })+ });}}, [notes]);const _onPressBottomButton = async () => {-eSendEvent(eOnLoadNote, {type: 'new'});if (DDS.isPhone || DDS.isSmallTab) {@@ -98,7 +107,6 @@ export const Home = ({navigation}) => {title="Create a new note"onPress={_onPressBottomButton}/>-</>);};diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.jsindex bf7b1ad03..44c7cc86c 100644--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@ -45,8 +45,6 @@ import {DDS} from '../../services/DeviceDetection';import {MMKV} from '../../utils/mmkv';import Backup from '../../services/Backup';--export const Settings = ({navigation}) => {const [state, dispatch] = useTracked();const {colors, user, settings} = state;@@ -127,9 +125,10 @@ export const Settings = ({navigation}) => {paragraph:"All your backups are stored in 'Phone Storage/Notesnook/backups/' folder",});- await Backup.run();- await sleep(2000);- eSendEvent(eCloseProgressDialog);+ await Backup.run();+ await sleep(1000);+ eSendEvent(eCloseProgressDialog);+},desc: 'Backup all your data to phone storage',},@@ -305,9 +304,6 @@ export const Settings = ({navigation}) => {height={40}/></View>- {- // Ad code here- }</View></View>{[@@ -317,7 +313,7 @@ export const Settings = ({navigation}) => {eSendEvent(eOpenRecoveryKeyDialog);},desc:- 'We recommend you to get your data recovery key and store it safely. If you lose your password, you can recover your data using your recovery key.',+ 'Save your recovery key. If you lose your password, you can recover your data using your recovery key.',},{name: 'Logout',