Skip to content

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

show price correctly

ammarahm-ed8bca4e7a351a
diff --git a/apps/mobile/src/components/Premium/PremiumDialog.js b/apps/mobile/src/components/Premium/PremiumDialog.js
index c39cf13a2..8be43db03 100644
--- a/apps/mobile/src/components/Premium/PremiumDialog.js
+++ b/apps/mobile/src/components/Premium/PremiumDialog.js
@@ -1,36 +1,90 @@
-import React, {createRef} from 'react';
-import {Platform, ScrollView, TouchableOpacity, View} from 'react-native';
+import React, {createRef, useEffect, useRef, useState} from 'react';
+import {View} from 'react-native';
import * as RNIap from 'react-native-iap';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import Carousel from 'react-native-snap-carousel';
+import {SvgXml} from 'react-native-svg';
+import {
+ ACCENT_SVG,
+ BACKUP_SVG,
+ COMMUNITY_SVG,
+ EXPORT_SVG,
+ ORGANIZE_SVG,
+ RICH_TEXT_SVG,
+ SYNC_SVG,
+ VAULT_SVG,
+} from '../../assets/images/assets';
+import {useTracked} from '../../provider';
import {DDS} from '../../services/DeviceDetection';
import {eSendEvent} from '../../services/EventManager';
-import {dHeight, dWidth, itemSkus} from '../../utils';
+import PremiumService from '../../services/PremiumService';
+import {dWidth, itemSkus} from '../../utils';
import {db} from '../../utils/DB';
import {eOpenLoginDialog} from '../../utils/Events';
+import {openLinkInBrowser} from '../../utils/functions';
import {SIZE} from '../../utils/SizeUtils';
import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';
import {Button} from '../Button';
-import Seperator from '../Seperator';
import {Toast} from '../Toast';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
-import Carousel from 'react-native-snap-carousel';
-import {SvgXml} from 'react-native-svg';
-import {ACCENT_SVG, BACKUP_SVG, COMMUNITY_SVG, EXPORT_SVG, NOTE_SVG, ORGANIZE_SVG, RICH_TEXT_SVG, SYNC_SVG, VAULT_SVG} from '../../assets/images/assets';
+
+const features = [
+ {
+ title: 'Automatic sync',
+ description:
+ 'Your notes will be automatically encrypted and synced to all your devices.',
+ icon: SYNC_SVG,
+ },
+ {
+ title: 'Unlimited organization',
+ description:
+ 'Make unlimited notebooks and tags. Assign colors to your notes for quick access.',
+ icon: ORGANIZE_SVG,
+ },
+ {
+ title: 'Secure vault',
+ description:
+ 'Lock any note with a password and keep sensitive data under lock and key.',
+ icon: VAULT_SVG,
+ },
+ {
+ title: 'Full rich text editor',
+ description:
+ ' Add images, links, tables, lists and embed videos. Use markdown for fast editing.',
+ icon: RICH_TEXT_SVG,
+ },
+ {
+ title: 'Export notes',
+ description: 'You can export your notes in PDF, Markdown and HTML formats.',
+ icon: EXPORT_SVG,
+ },
+ {
+ title: 'Automatic and encrypted backups',
+ description:
+ 'Enable daily or weekly backups of your data with automatic encryption.',
+ icon: BACKUP_SVG,
+ },
+ {
+ title: 'Customize Notesnook',
+ description:
+ 'Change app colors, turn on automatic theme switching and change default home page.',
+ icon: ACCENT_SVG,
+ },
+ {
+ title: 'Get a Pro badge on Discord',
+ description:
+ 'Pro users get access to special channels and priority support on our Discord server ',
+ icon: COMMUNITY_SVG,
+ },
+];
+
class PremiumDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
- user: null,
- products: null,
- scrollEnabled: false,
- product: null,
visible: false,
};
- this.routeIndex = 0;
- this.count = 0;
this.actionSheetRef = createRef();
- this.prevScroll = 0;
}
open() {
@@ -44,278 +98,134 @@ class PremiumDialog extends React.Component {
);
}
- close() {
+ close = () => {
this.actionSheetRef.current?.setModalVisible(false);
- }
-
- async getSkus() {
- try {
- let u = await db.user.getUser();
- this.setState({
- user: u,
- });
- await RNIap.initConnection();
- let prod = await RNIap.getSubscriptions(itemSkus);
- console.log(prod);
- this.setState({
- products: prod,
- product: prod[0],
- });
- } catch (e) {}
- }
+ };
-
- features = [
- {
- title: 'Automatic sync',
- description:
- 'Your notes will be automatically encrypted and synced to all your devices.',
- icon: SYNC_SVG,
- },
- {
- title: 'Unlimited organization',
- description:
- 'Make unlimited notebooks and tags. Assign colors to your notes for quick access.',
- icon: ORGANIZE_SVG,
- },
- {
- title: 'Secure vault',
- description:
- 'Lock any note with a password and keep sensitive data under lock and key.',
- icon: VAULT_SVG,
- },
- {
- title: 'Full rich text editor',
- description:
- ' Add images, links, tables, lists and embed videos. Use markdown for fast editing.',
- icon: RICH_TEXT_SVG,
- },
- {
- title: 'Export notes',
- description:
- 'You can export your notes in PDF, Markdown and HTML formats.',
- icon: EXPORT_SVG,
- },
- {
- title: 'Automatic and encrypted backups',
- description:
- 'Enable daily or weekly backups of your data with automatic encryption.',
- icon: BACKUP_SVG,
- },
- {
- title: 'Customize Notesnook',
- description:
- 'Change app colors, turn on automatic theme switching and change default home page.',
- icon: ACCENT_SVG,
- },
- {
- title: 'Get a Pro badge on Discord',
- description:
- 'Pro users get access to special channels and priority support on our Discord server ',
- icon: COMMUNITY_SVG,
- },
- ];
+ onClose = () => {
+ this.setState({
+ visible: false,
+ });
+ };
render() {
- const {colors} = this.props;
return !this.state.visible ? null : (
- <ActionSheetWrapper
- onOpen={async () => {
- try {
- await this.getSkus();
- } catch (e) {}
- }}
- onClose={() => {
- this.setState({
- visible: false,
- });
- }}
- fwdRef={this.actionSheetRef}>
- <View
- style={{
- width: '100%',
- backgroundColor: colors.bg,
- justifyContent: 'space-between',
- paddingHorizontal: 12,
- borderRadius: 10,
- paddingTop: 10,
- }}>
- <Heading
- size={SIZE.xxxl}
- style={{
- paddingBottom: 20,
- paddingTop: 10,
- alignSelf: 'center',
- }}>
- Notesnook{' '}
- <Heading size={SIZE.xxxl} color={colors.accent}>
- Pro
- </Heading>
- </Heading>
+ <ActionSheetWrapper onClose={this.onClose} fwdRef={this.actionSheetRef}>
+ <InnerComponent close={this.close} />
+ </ActionSheetWrapper>
+ );
+ }
+}
- <ScrollView
- nestedScrollEnabled={true}
- onScrollEndDrag={this.actionSheetRef.current?.handleChildScrollEnd}
- onScrollAnimationEnd={
- this.actionSheetRef.current?.handleChildScrollEnd
- }
- onMomentumScrollEnd={
- this.actionSheetRef.current?.handleChildScrollEnd
- }
- style={{
- width: '100%',
- maxHeight: DDS.isLargeTablet() ? dHeight * 0.45 : dHeight * 0.55,
- }}>
- <Carousel
- data={this.features}
- itemWidth={DDS.isTab ? 475 : dWidth}
- sliderWidth={DDS.isTab ? 475 : dWidth}
- autoplay
- loop
- autoplayInterval={5000}
- autoplayDelay={3000}
- renderItem={({item, index}) => (
- <View
- key={item.description}
- style={{
- paddingVertical: 5,
- marginBottom: 10,
- width:"100%",
- }}>
- <View
- style={{
- width: '95%',
- alignItems: 'center',
- alignSelf:'center'
- }}>
- <SvgXml
- xml={item.icon(colors.accent)}
- width={170}
- height={170}
- />
+export default PremiumDialog;
- <Heading
- size={SIZE.lg}
- style={{
- textAlign: 'center',
- alignSelf: 'center',
- marginTop:10
- }}>
- {item.title}
- </Heading>
+const InnerComponent = React.memo(
+ ({close}) => {
+ const [state, dispatch] = useTracked();
+ const colors = state.colors;
+ const [user, setUser] = useState(null);
+ const [product, setProduct] = useState(null);
+ const [products, setProducts] = useState([]);
+ const scrollViewRef = useRef();
- <Paragraph
- size={SIZE.md}
- color={colors.icon}
- textBreakStrategy="balanced"
- style={{
- fontWeight: 'normal',
- textAlign: 'center',
- alignSelf: 'center',
- maxWidth: "80%"
- }}>
- {item.description}
- </Paragraph>
- </View>
- </View>
- )}
- />
- </ScrollView>
+ const getSkus = async () => {
+ try {
+ let _user = await db.user.getUser();
+ setUser(_user);
+ if (PremiumService.getProducts().length > 0) {
+ setProduct(PremiumService.getProducts()[0]);
+ setProducts(PremiumService.getProducts());
+ } else {
+ let prod = await RNIap.getSubscriptions(itemSkus);
+ setProduct(prod[0]);
+ setProducts(prod);
+ }
+ } catch (e) {}
+ };
- <Seperator />
+ useEffect(() => {
+ getSkus();
+ }, []);
- <View
- style={{
- padding: 5,
- borderRadius: 10,
- paddingHorizontal: 12,
- }}>
- {/* <Heading size={SIZE.xl} color={colors.accent}>
- {!this.state.user ? 'Try it Now' : 'Upgrade Now'}
- {'\n'}
- <Paragraph
- size={SIZE.sm}
- style={{
- fontWeight: '400',
- lineHeight: 17,
- }}>
- {this.state.user
- ? `You can cancel anytime from subscriptions on${
- Platform.OS === 'android' ? ' Google Play' : ' App Store'
- }`
- : 'Start your 14 Day Trial Today (no credit card required.)'}
- </Paragraph>
- </Heading>
- */}
- {/* <View
- style={{
- flexDirection: 'row',
- paddingVertical: 5,
- marginTop: 10,
- }}>
- {this.state.products?.map((item) => (
- <TouchableOpacity
- onPress={() => {
- this.setState({
- product: item,
- });
- }}
- style={{
- borderWidth: 1,
- borderColor: this.state.product?.productId
- ? colors.accent
- : 'transparent',
- borderRadius: 5,
- padding: 5,
- paddingVertical: 10,
- marginRight: 10,
- }}>
+ return (
+ <View
+ style={{
+ width: '100%',
+ backgroundColor: colors.bg,
+ justifyContent: 'space-between',
+ borderRadius: 10,
+ paddingTop: 10,
+ }}>
+ <Heading
+ size={SIZE.xxxl}
+ style={{
+ paddingBottom: 20,
+ paddingTop: 0,
+ alignSelf: 'center',
+ }}>
+ Notesnook{' '}
+ <Heading size={SIZE.xxxl} color={colors.accent}>
+ Pro
+ </Heading>
+ </Heading>
- <Paragraph size={SIZE.lg}>
- {!item.localizedPrice && item.currency + ' '}
- {item.localizedPrice || item.price}
- <Paragraph color={colors.accent} size={SIZE.sm}>
- /mo
- </Paragraph>
- </Paragraph>
- </TouchableOpacity>
- ))}
- </View> */}
+ <Carousel
+ ref={scrollViewRef}
+ data={features}
+ layout="stack"
+ itemWidth={DDS.isTab ? 475 : dWidth}
+ sliderWidth={DDS.isTab ? 475 : dWidth}
+ autoplay
+ loop
+ autoplayInterval={3000}
+ autoplayDelay={1000}
+ renderItem={({item, index}) => (
+ <RenderItem item={item} index={index} />
+ )}
+ />
- <Seperator half />
- <Button
- onPress={async () => {
- if (!this.state.user) {
- this.close();
- setTimeout(() => {
- eSendEvent(eOpenLoginDialog);
- }, 400);
- } else {
- RNIap.requestSubscription(
- this.state.product?.productId,
- false,
- null,
- null,
- null,
- this.state.user.id,
- )
- .then((r) => {
- this.close();
- })
- .catch((e) => {
- console.log(e);
- });
- }
- }}
- fontSize={SIZE.md}
- title={
- this.state.user ? 'Subscribe' : 'Start Your Free 14 Day Trial'
+ <View
+ style={{
+ padding: 5,
+ borderRadius: 10,
+ paddingHorizontal: 12,
+ }}>
+ <Button
+ onPress={async () => {
+ if (!user) {
+ close();
+ setTimeout(() => {
+ eSendEvent(eOpenLoginDialog);
+ }, 400);
+ } else {
+ RNIap.requestSubscription(
+ product?.productId,
+ false,
+ null,
+ null,
+ null,
+ user.id,
+ )
+ .then((r) => {
+ close();
+ })
+ .catch((e) => {
+ console.log(e);
+ });
}
- type="accent"
- height={50}
- width="100%"
- />
+ }}
+ fontSize={SIZE.md}
+ title={
+ !user
+ ? `Subscribe for ${product?.localizedPrice || '$4.49'} / Month`
+ : 'Start Your Free 14 Day Trial'
+ }
+ type="accent"
+ height={50}
+ width="100%"
+ />
+ {user ? (
<Paragraph
style={{
alignSelf: 'center',
@@ -323,12 +233,122 @@ class PremiumDialog extends React.Component {
}}>
(No credit card required.)
</Paragraph>
- </View>
- <Toast context="local" />
+ ) : null}
+
+ {user ? (
+ <>
+ <Paragraph
+ textBreakStrategy="balanced"
+ style={{
+ alignSelf: 'center',
+ marginTop: 5,
+ textAlign: 'center',
+ }}>
+ By tapping Subscribe, {product?.localizedPrice || '$4.49'} will
+ be charged to your iTunes Account for 1-month subscription of
+ Notesnook Pro.{'\n\n'}
+ Subscriptions will automatically renew unless cancelled within
+ 24-hours before the end of the current period. You can cancel
+ anytime with your iTunes Account settings.
+ </Paragraph>
+
+ <View
+ style={{
+ backgroundColor: colors.nav,
+ width: '100%',
+ paddingVertical: 10,
+ marginTop: 10,
+ borderRadius: 5,
+ paddingHorizontal: 12,
+ }}>
+ <Paragraph
+ style={{
+ maxWidth: '100%',
+ textAlign: 'center',
+ }}>
+ By tapping Subscribe, you agree to our{' '}
+ <Paragraph
+ onPress={() => {
+ openLinkInBrowser('https://notesnook.com/tos', colors)
+ .catch((e) => {})
+ .then((r) => {
+ console.log('closed');
+ });
+ }}
+ color={colors.accent}>
+ Terms of Service{' '}
+ </Paragraph>
+ and{' '}
+ <Paragraph
+ onPress={() => {
+ openLinkInBrowser('https://notesnook.com/privacy', colors)
+ .catch((e) => {})
+ .then((r) => {
+ console.log('closed');
+ });
+ }}
+ color={colors.accent}>
+ Privacy Policy.
+ </Paragraph>
+ </Paragraph>
+ </View>
+ </>
+ ) : null}
</View>
- </ActionSheetWrapper>
+ <Toast context="local" />
+ </View>
);
- }
-}
+ },
+ () => true,
+);
-export default PremiumDialog;
+const RenderItem = React.memo(
+ ({item, index}) => {
+ const [state, dispatch] = useTracked();
+ const colors = state.colors;
+
+ return (
+ <View
+ key={item.description}
+ style={{
+ paddingVertical: 5,
+ marginBottom: 10,
+ width: '100%',
+ backgroundColor: colors.bg,
+ }}>
+ <View
+ style={{
+ width: '95%',
+ alignItems: 'center',
+ alignSelf: 'center',
+ }}>
+ <SvgXml xml={item.icon(colors.accent)} width={170} height={170} />
+
+ <Heading
+ size={SIZE.lg}
+ style={{
+ textAlign: 'center',
+ alignSelf: 'center',
+ marginTop: 10,
+ }}>
+ {item.title}
+ </Heading>
+
+ <Paragraph
+ size={SIZE.md}
+ color={colors.icon}
+ textBreakStrategy="balanced"
+ style={{
+ fontWeight: 'normal',
+ textAlign: 'center',
+ alignSelf: 'center',
+ maxWidth: '80%',
+ }}>
+ {item.description}
+ </Paragraph>
+ </View>
+ </View>
+ );
+ },
+ () => true,
+);
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index d7c4cd53d..96f33b2b8 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -708,7 +708,12 @@ const SettingsUserSection = () => {
title={
user.subscription.type === 6
? 'Resubscribe to Notesnook Pro'
- : 'Subscribe to Notesnook Pro'
+ : `Subscribe to Notesnook Pro (${
+ PremiumService.getProducts().length > 0
+ ? PremiumService.getProducts()[0]
+ .localizedPrice
+ : '$4.49'
+ } / Month)`
}
height={50}
type="transparent"