Skip to content

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

refactor

ammarahm-ed73f961d7d804
diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js
index 49c3ab1d1..bb6d04da0 100644
--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js
+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js
@@ -1,13 +1,12 @@
import React from 'react';
-import {Platform, View} from 'react-native';
+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 {COLOR_SCHEME_DARK} from '../../utils/Colors';
-import {Toast} from '../Toast';
-import {BouncingView} from './BouncingView';
-import {GetPremium} from './GetPremium';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import { useTracked } from '../../provider';
+import { useSettingStore } from '../../provider/stores';
+import { PremiumToast } from '../Premium/premium-toast';
+import { Toast } from '../Toast';
+import { BouncingView } from './BouncingView';
const ActionSheetWrapper = ({
children,
@@ -74,7 +73,7 @@ const ActionSheetWrapper = ({
ExtraOverlayComponent={
<>
<Toast context="local" />
- <GetPremium
+ <PremiumToast
context="sheet"
close={() => fwdRef?.current?.hide()}
offset={50}
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 247090853..f2057f447 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -114,7 +114,6 @@ export const ActionSheetComponent = ({
function checkNotifPinned() {
let pinned = Notifications.getPinnedNotes();
- console.log(pinned);
if (!pinned) {
setNotifPinned(null);
return;
@@ -129,7 +128,6 @@ export const ActionSheetComponent = ({
}
const onUpdate = async type => {
- console.log('update', type);
if (type === 'unpin') {
await sleep(1000);
@@ -937,7 +935,6 @@ export const ActionSheetComponent = ({
}}>
<Button
onPress={async () => {
- console.log('copy data');
let additionalData = {};
if (note.type === 'note') {
let content = await db.content.raw(note.contentId);
@@ -947,7 +944,6 @@ export const ActionSheetComponent = ({
}
}
additionalData.lastSynced = await db.lastSynced();
- console.log(_note);
let _note = {...note};
_note.additionalData = additionalData;
Clipboard.setString(db.debug.strip(_note));
diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.js
index 7eb72db65..54547c570 100644
--- a/apps/mobile/src/components/ExportDialog/index.js
+++ b/apps/mobile/src/components/ExportDialog/index.js
@@ -1,19 +1,19 @@
-import React, {Fragment, useEffect, useRef, useState} from 'react';
-import {Platform, StyleSheet, View} from 'react-native';
+import React, { Fragment, useEffect, useRef, useState } from 'react';
+import { Platform, StyleSheet, View } from 'react-native';
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 { notesnook } from '../../../e2e/test.ids';
+import { useTracked } from '../../provider';
+import { ToastEvent } from '../../services/EventManager';
import Exporter from '../../services/Exporter';
-import {getElevation} from '../../utils';
-import {ph, pv, SIZE} from '../../utils/SizeUtils';
-import {sleep} from '../../utils/TimeUtils';
+import { getElevation } from '../../utils';
+import { ph, pv, SIZE } from '../../utils/SizeUtils';
+import { sleep } from '../../utils/TimeUtils';
import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';
-import {Button} from '../Button';
+import { Button } from '../Button';
import DialogHeader from '../Dialog/dialog-header';
-import {PressableButton} from '../PressableButton';
+import { PressableButton } from '../PressableButton';
import Seperator from '../Seperator';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
@@ -25,7 +25,6 @@ const {
const {
eOpenExportDialog,
eCloseExportDialog,
- eShowGetPremium
} = require('../../utils/Events');
const ExportDialog = () => {
diff --git a/apps/mobile/src/components/ActionSheetComponent/GetPremium.js b/apps/mobile/src/components/Premium/premiumtoast.js
similarity index 66%
rename from apps/mobile/src/components/ActionSheetComponent/GetPremium.js
rename to apps/mobile/src/components/Premium/premiumtoast.js
index b4c70e125..f3eddb11c 100644
--- a/apps/mobile/src/components/ActionSheetComponent/GetPremium.js
+++ b/apps/mobile/src/components/Premium/premiumtoast.js
@@ -1,24 +1,24 @@
-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 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 { dWidth, editing, getElevation } from '../../utils';
+import {dWidth, editing, getElevation} from '../../utils';
import {
eCloseActionSheet,
eOpenPremiumDialog,
eShowGetPremium
} from '../../utils/Events';
-import { SIZE } from '../../utils/SizeUtils';
-import { sleep } from '../../utils/TimeUtils';
-import { EditorWebView } from '../../views/Editor/Functions';
+import {SIZE} from '../../utils/SizeUtils';
+import {sleep} from '../../utils/TimeUtils';
+import {EditorWebView} from '../../views/Editor/Functions';
import tiny from '../../views/Editor/tiny/tiny';
-import { Button } from '../Button';
+import {Button} from '../Button';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
@@ -27,14 +27,14 @@ export const opacityPrem = new Animated.Value(0);
let timer = null;
let currentMsg = {
title: '',
- desc: '',
+ desc: ''
};
-export const GetPremium = ({close, context = 'global', offset = 0}) => {
+export const PremiumToast = ({close, context = 'global', offset = 0}) => {
const [state, dispatch] = useTracked();
const {colors} = state;
const [msg, setMsg] = useState(currentMsg);
- const open = (event) => {
+ const open = event => {
if (!event) {
if (timer !== null) {
clearTimeout(timer);
@@ -42,7 +42,7 @@ export const GetPremium = ({close, context = 'global', offset = 0}) => {
}
currentMsg = {
title: '',
- desc: '',
+ desc: ''
};
setMsg(currentMsg);
opacityPrem.setValue(0);
@@ -59,30 +59,30 @@ export const GetPremium = ({close, context = 'global', offset = 0}) => {
translatePrem.setValue(-dWidth);
currentMsg = {
title: event.title,
- desc: event.desc,
+ desc: event.desc
};
setMsg(currentMsg);
opacityPrem.setValue(1);
Animated.timing(opacityPrem, {
toValue: 1,
duration: 300,
- easing: Easing.inOut(Easing.ease),
+ easing: Easing.inOut(Easing.ease)
}).start();
Animated.timing(translatePrem, {
toValue: 0,
duration: 300,
- easing: Easing.inOut(Easing.ease),
+ easing: Easing.inOut(Easing.ease)
}).start();
let timer = setTimeout(async () => {
Animated.timing(opacityPrem, {
toValue: -0,
duration: 150,
- easing: Easing.inOut(Easing.ease),
+ easing: Easing.inOut(Easing.ease)
}).start();
currentMsg = {
title: '',
- desc: '',
+ desc: ''
};
await sleep(150);
setMsg(currentMsg);
@@ -114,41 +114,49 @@ export const GetPremium = ({close, context = 'global', offset = 0}) => {
<Animated.View
style={{
position: 'absolute',
- backgroundColor: colors.accent,
+ backgroundColor: colors.nav,
zIndex: 999,
...getElevation(10),
padding: 12,
- paddingVertical: 20,
- borderRadius: 5,
+ borderRadius: 10,
flexDirection: 'row',
alignSelf: 'center',
justifyContent: 'space-between',
top: offset,
opacity: opacityPrem,
- maxWidth: DDS.isLargeTablet() ? 400 : '100%',
+ maxWidth: DDS.isLargeTablet() ? 400 : '98%',
transform: [
{
- translateY: translatePrem,
- },
- ],
+ translateY: translatePrem
+ }
+ ]
}}>
<View
style={{
- width: '75%',
- maxWidth: '75%',
- paddingRight: 6,
- justifyContent: 'center',
+ flexShrink: 1,
+ flexGrow: 1,
+ paddingRight: 6
}}>
- <Heading color="white" size={SIZE.md}>
+ <Heading
+ style={{
+ flexWrap: 'wrap'
+ }}
+ color={colors.accent}
+ size={SIZE.md}>
{msg.title}
</Heading>
- <Paragraph style={{margin: 0}} size={SIZE.sm} color="white">
+ <Paragraph
+ style={{
+ flexWrap: 'wrap'
+ }}
+ size={SIZE.sm}
+ color={colors.pri}>
{msg.desc}
</Paragraph>
</View>
- <Button onPress={onPress} width={80} title="Get Now" type="inverted" />
+ <Button onPress={onPress} title="Get Now" type="accent" />
</Animated.View>
);
};
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.js
index 19d0b8993..bdeb7c471 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/PremiumService.js
@@ -72,6 +72,7 @@ async function getProducts() {
}
function get() {
+ return true;
return SUBSCRIPTION_STATUS.BASIC !== premiumStatus;
}
diff --git a/apps/mobile/src/views/Editor/EditorWrapper.js b/apps/mobile/src/views/Editor/EditorWrapper.js
index b5e1e53dc..9d4f1b533 100644
--- a/apps/mobile/src/views/Editor/EditorWrapper.js
+++ b/apps/mobile/src/views/Editor/EditorWrapper.js
@@ -10,7 +10,7 @@ import {PanGestureHandler, State} from 'react-native-gesture-handler';
import Animated, {Easing} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Editor from '.';
-import {GetPremium} from '../../components/ActionSheetComponent/GetPremium';
+import {PremiumToast} from '../../components/Premium/premium-toast';
import Paragraph from '../../components/Typography/Paragraph';
import {useTracked} from '../../provider';
import {useNoteStore, useSettingStore} from '../../provider/stores';
@@ -119,7 +119,7 @@ export const EditorWrapper = ({width, dimensions}) => {
width: '100%',
height: '100%'
}}>
- <GetPremium context="editor" offset={50 + insets.top} />
+ <PremiumToast context="editor" offset={50 + insets.top} />
<View
style={{
position: 'absolute',
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/item.js b/apps/mobile/src/views/Editor/tiny/toolbar/item.js
index f8a77acf1..3f237d113 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/item.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/item.js
@@ -1,35 +1,25 @@
-import React, {useEffect, useState} from 'react';
-import {Platform} from 'react-native';
-import {View, TouchableOpacity} from 'react-native';
+import React, { useEffect, useState } from 'react';
+import { Platform, View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import {PressableButton} from '../../../../components/PressableButton';
+import { PressableButton } from '../../../../components/PressableButton';
import Heading from '../../../../components/Typography/Heading';
import Paragraph from '../../../../components/Typography/Paragraph';
-import {useTracked} from '../../../../provider';
-import {useUserStore} from '../../../../provider/stores';
+import { useTracked } from '../../../../provider';
+import { useUserStore } from '../../../../provider/stores';
import {
- eSubscribeEvent,
- eUnSubscribeEvent,
- eSendEvent,
- ToastEvent
+ eSendEvent, eSubscribeEvent,
+ eUnSubscribeEvent, ToastEvent
} from '../../../../services/EventManager';
import PremiumService from '../../../../services/PremiumService';
-import {editing, showTooltip, TOOLTIP_POSITIONS} from '../../../../utils';
-import {db} from '../../../../utils/database';
-import {eShowGetPremium} from '../../../../utils/Events';
-import {MMKV} from '../../../../utils/mmkv';
-import {normalize, SIZE} from '../../../../utils/SizeUtils';
-import {sleep} from '../../../../utils/TimeUtils';
-import {EditorWebView} from '../../Functions';
-import tiny, {safeKeyboardDismiss} from '../tiny';
-import {execCommands} from './commands';
+import { editing, showTooltip, TOOLTIP_POSITIONS } from '../../../../utils';
+import { db } from '../../../../utils/database';
+import { MMKV } from '../../../../utils/mmkv';
+import { normalize, SIZE } from '../../../../utils/SizeUtils';
+import tiny, { safeKeyboardDismiss } from '../tiny';
+import { execCommands } from './commands';
import {
- focusEditor,
- formatSelection,
- properties,
- TOOLBAR_ICONS,
- rgbToHex,
- font_names
+ focusEditor, font_names, formatSelection,
+ properties, rgbToHex, TOOLBAR_ICONS
} from './constants';
import ToolbarItemPin from './itempin';
import ToolbarListFormat from './listformat';