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
added rate app dialog
ammarahm-ed54024a563dc7
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex 7a328e18e..221afeb8d 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -47,8 +47,13 @@ const App = () => {await db.init();let requireIntro = await MMKV.getItem('introCompleted');if (!requireIntro) {- console.log('loading default notes')await loadDefaultNotes();+ await MMKV.setItem(+ 'askForRating',+ JSON.stringify({+ timestamp: Date.now() + 86400000 * 2,+ }),+ );}};diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.jsindex 843cee4de..62e1d475f 100644--- a/apps/mobile/src/components/AppLoader/index.js+++ b/apps/mobile/src/components/AppLoader/index.js@@ -11,7 +11,7 @@ import {} from '../../services/EventManager';import {changeContainerScale, ContainerScale} from '../../utils/Animations';import {db} from '../../utils/DB';-import {eOpenSideMenu} from '../../utils/Events';+import {eOpenRateDialog, eOpenSideMenu} from '../../utils/Events';import {MMKV} from '../../utils/mmkv';import {tabBarRef} from '../../utils/Refs';import {sleep} from '../../utils/TimeUtils';@@ -63,6 +63,13 @@ const AppLoader = ({onLoad}) => {await sleep(150);setLoading(false);animation = false;+ let askForRating = await MMKV.getItem('askForRating');+ if (askForRating !== 'never' || askForRating !== 'completed') {+ askForRating = JSON.parse(askForRating);+ if (askForRating.timestamp < Date.now()) {+ eSendEvent(eOpenRateDialog);+ }+ }};useEffect(() => {diff --git a/apps/mobile/src/components/Dialog/BaseDialog.js b/apps/mobile/src/components/Dialog/BaseDialog.jsindex 5f1358510..a294f3c94 100644--- a/apps/mobile/src/components/Dialog/BaseDialog.js+++ b/apps/mobile/src/components/Dialog/BaseDialog.js@@ -20,6 +20,7 @@ const BaseDialog = ({premium,statusBarTranslucent = true,transparent,+ centered=true}) => {const [state, dispatch] = useTracked();const scaleValue = new Animated.Value(1);@@ -49,6 +50,9 @@ const BaseDialog = ({: 'rgba(0,0,0,0.3)',},styles.backdrop,+ {+ justifyContent:centered? "center" : "flex-start"+ }]}><TouchableOpacityonPress={onRequestClose}diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.jsindex e98e09ba2..a28dcedd1 100644--- a/apps/mobile/src/components/DialogManager/index.js+++ b/apps/mobile/src/components/DialogManager/index.js@@ -40,6 +40,7 @@ import PendingDialog from '../Premium/PendingDialog';import PremiumDialog from '../Premium/PremiumDialog';import PremiumStatusDialog from '../Premium/PremiumStatusDialog';import ProgressDialog from '../ProgressDialog';+import RateDialog from '../RateDialog';import RecoveryKeyDialog from '../RecoveryKeyDialog';import RestoreDialog from '../RestoreDialog';import ResultDialog from '../ResultDialog';@@ -380,6 +381,7 @@ export class DialogManager extends Component {<SortDialog colors={colors} /><JumpToDialog /><UpdateDialog />+ <RateDialog/></>);}diff --git a/apps/mobile/src/components/RateDialog/index.js b/apps/mobile/src/components/RateDialog/index.jsnew file mode 100644index 000000000..563efa776--- /dev/null+++ b/apps/mobile/src/components/RateDialog/index.js@@ -0,0 +1,125 @@+import React, {useEffect, useState} from 'react';+import {Linking} from 'react-native';+import {Platform} from 'react-native';+import {View} from 'react-native';+import {useSafeAreaInsets} from 'react-native-safe-area-context';+import BaseDialog from '../../components/Dialog/base-dialog';+import {useTracked} from '../../provider';+import {DDS} from '../../services/DeviceDetection';+import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';+import {getElevation} from '../../utils';+import {eCloseRateDialog, eOpenRateDialog} from '../../utils/Events';+import {MMKV} from '../../utils/mmkv';+import {SIZE} from '../../utils/SizeUtils';+import {Button} from '../Button';+import DialogButtons from '../Dialog/dialog-buttons';+import DialogHeader from '../Dialog/dialog-header';+import Heading from '../Typography/Heading';+import Paragraph from '../Typography/Paragraph';++const RateDialog = () => {+ const [state] = useTracked();+ const {notes, colors, settings} = state;+ const [visible, setVisible] = useState(false);+ const insets = useSafeAreaInsets();++ useEffect(() => {+ eSubscribeEvent(eOpenRateDialog, open);+ eSubscribeEvent(eCloseRateDialog, close);++ return () => {+ eUnSubscribeEvent(eOpenRateDialog, open);+ eUnSubscribeEvent(eCloseRateDialog, close);+ };+ }, []);++ const open = () => {+ setVisible(true);+ };++ const close = () => {+ setVisible(false);+ };++ return !visible ? null : (+ <BaseDialog+ centered={false}+ onRequestClose={async () => {+ await MMKV.setItem(+ 'askForRating',+ JSON.stringify({+ timestamp: Date.now() + (86400000 * 2)+ }),+ );+ setVisible(false);+ }}+ visible={true}>+ <View+ style={{+ ...getElevation(5),+ width: '100%',+ backgroundColor: colors.accent,+ zIndex: 100,+ bottom: 20,+ alignSelf: 'center',+ padding: 12,+ paddingTop: insets.top + 25,+ }}>+ <Heading color={colors.light}>Rate Notesnook</Heading>+ <Paragraph size={SIZE.md} color={colors.light}>+ If you find Notesnook useful, please take a moment to rate it. It+ won't take more than a minute. Thanks for your support.+ </Paragraph>++ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ justifyContent: 'flex-end',+ paddingTop: 20,+ }}>+ <Button+ onPress={async () => {+ await MMKV.setItem('askForRating', 'never');+ setVisible(false);+ }}+ fontSize={SIZE.md}+ type="white"+ title="Never"+ />+ <Button+ onPress={async () => {+ await MMKV.setItem(+ 'askForRating',+ JSON.stringify({+ timestamp: Date.now() + (86400000 * 2)+ }),+ );+ setVisible(false);+ }}+ fontSize={SIZE.md}+ type="white"+ title="Later"+ />+ <Button+ onPress={async () => {+ await Linking.openURL(+ Platform.OS === 'ios'+ ? 'https://bit.ly/notesnook-ios'+ : 'https://bit.ly/notesnook-and',+ );++ await MMKV.setItem('askForRating', 'completed');+ setVisible(false);+ }}+ fontSize={SIZE.md}+ type="white"+ title="Rate now"+ />+ </View>+ </View>+ </BaseDialog>+ );+};++export default RateDialog;diff --git a/apps/mobile/src/utils/Events.js b/apps/mobile/src/utils/Events.jsindex 573fb1688..294ec9c8e 100644--- a/apps/mobile/src/utils/Events.js+++ b/apps/mobile/src/utils/Events.js@@ -121,4 +121,6 @@ export const eCloseSortDialog = '560';export const eOpenJumpToDialog = '561';export const eCloseJumpToDialog = '562';-export const eShowGetPremium = '563';\ No newline at end of file+export const eShowGetPremium = '563';+export const eOpenRateDialog = '564';+export const eCloseRateDialog = '565';\ No newline at end of filediff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.jsindex eb76b91c5..3b4779dd0 100755--- a/apps/mobile/src/utils/index.js+++ b/apps/mobile/src/utils/index.js@@ -172,7 +172,8 @@ export const SUBSCRIPTION_PROVIDER = {1: {type: 'iOS',title: 'Subscribed on iOS',- desc: 'You subscribed to Notesnook Pro on iOS using Apple In App Purchase. You can cancel anytime with your iTunes Account settings.',+ desc:+ 'You subscribed to Notesnook Pro on iOS using Apple In App Purchase. You can cancel anytime with your iTunes Account settings.',icon: 'ios',},2: {@@ -216,6 +217,11 @@ export const BUTTON_TYPES = {text: 'accent',selected: 'bg',},+ white: {+ primary: 'transparent',+ text: 'light',+ selected: 'transGray',+ },shade: {primary: 'shade',text: 'accent',