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
update premium component
ammarahm-edecce1467c63b
diff --git a/apps/mobile/src/components/Premium/PremiumComponent.js b/apps/mobile/src/components/Premium/PremiumComponent.jsindex 7e2ddf5e4..2f955e0db 100644--- a/apps/mobile/src/components/Premium/PremiumComponent.js+++ b/apps/mobile/src/components/Premium/PremiumComponent.js@@ -1,24 +1,11 @@import React, {useEffect, useRef, useState} from 'react';import {Platform, View} from 'react-native';+import {FlatList} from 'react-native-gesture-handler';import * as RNIap from 'react-native-iap';-import {color} from 'react-native-reanimated';-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, ToastEvent} from '../../services/EventManager';import PremiumService from '../../services/PremiumService';-import {dWidth, itemSkus} from '../../utils';import {db} from '../../utils/DB';import {eCloseProgressDialog,@@ -31,66 +18,42 @@ import {sleep} from '../../utils/TimeUtils';import {Button} from '../Button';import {Dialog} from '../Dialog';import {presentDialog} from '../Dialog/functions';-import {SvgToPngView} from '../ListPlaceholders';import {Toast} from '../Toast';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';+import {useUserStore} from '../../provider/stores';const features = [{- title: 'Automatic sync',- description:- 'Your notes will be automatically encrypted and synced to all your devices.',- icon: SYNC_SVG,- img: 'sync'+ title: 'Unlimited attachments'+ },+ {+ title: 'Unlimited storage'+ },+ {+ title: 'Unlimited notebooks and tags'},{- title: 'Unlimited organization',- description:- 'Make unlimited notebooks and tags. Assign colors to your notes for quick access.',- icon: ORGANIZE_SVG,- img: 'organize'+ title: 'Automatic syncing'},{- title: 'Secure vault',- description:- 'Lock any note with a password and keep sensitive data under lock and key.',- icon: VAULT_SVG,- img: 'vault'+ title: 'Secure private vault for notes'},{- title: 'Full rich text editor',- description:- ' Add images, links, tables, lists and embed videos. Use markdown for fast editing.',- icon: RICH_TEXT_SVG,- img: 'richtext'+ title: 'Full rich text editor with markdown support'},{- title: 'Export notes',- description: 'You can export your notes in PDF, Markdown and HTML formats.',- icon: EXPORT_SVG,- img: 'export'+ title: 'Export notes in PDF, Markdown and HTML'},{- title: 'Automatic and encrypted backups',- description:- 'Enable daily or weekly backups of your data with automatic encryption.',- icon: BACKUP_SVG,- img: 'backup'+ title: 'Automatic encrypted backups'},{- title: 'Customize Notesnook',- description:- 'Change app colors, turn on automatic theme switching and change default home page.',- icon: ACCENT_SVG,- img: 'accent'+ title: 'Change app theme & accent colors'},{- 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,- img: 'community'+ title: 'Special Pro badge on our Discord server'}];@@ -106,10 +69,10 @@ const promoCyclesYearly = {3: 'first 3 years'};-export const PremiumComponent = ({close, promo}) => {+export const PremiumComponent = ({close, promo, getRef}) => {const [state, dispatch] = useTracked();const colors = state.colors;- const [user, setUser] = useState(null);+ const user = useUserStore(state => state.user);const [product, setProduct] = useState(null);const [products, setProducts] = useState([]);const [buying, setBuying] = useState(false);@@ -118,8 +81,6 @@ export const PremiumComponent = ({close, promo}) => {const getSkus = async () => {try {- let _user = await db.user.getUser();- setUser(_user);let products = PremiumService.getProducts();if (products.length > 0) {@@ -131,7 +92,6 @@ export const PremiumComponent = ({close, promo}) => {p => p.productId === 'com.streetwriters.notesnook.sub.yr')};- console.log(products.map(p => p.productId));setOffers(offers);if (promo?.promoCode) {@@ -223,14 +183,12 @@ export const PremiumComponent = ({close, promo}) => {backgroundColor: colors.bg,justifyContent: 'space-between',borderRadius: 10,- paddingTop: 10+ maxHeight: DDS.isTab ? '90%' : '100%'}}><Dialog context="local" /><Headingsize={SIZE.xxxl}style={{- paddingBottom: 20,- paddingTop: 0,alignSelf: 'center'}}>Notesnook{' '}@@ -238,17 +196,29 @@ export const PremiumComponent = ({close, promo}) => {Pro</Heading></Heading>+ <Paragraph+ size={SIZE.md}+ style={{+ paddingHorizontal: 12,+ textAlign: 'center',+ alignSelf: 'center',+ paddingBottom: 20,+ width: '90%'+ }}>+ Ready to take the next step on your private note taking journey?+ </Paragraph>- <Carousel- ref={scrollViewRef}+ <FlatList+ keyExtractor={item => item.title}data={features}- layout="stack"- itemWidth={DDS.isTab ? 475 : dWidth}- sliderWidth={DDS.isTab ? 475 : dWidth}- autoplay- loop- autoplayInterval={3000}- autoplayDelay={1000}+ ref={scrollViewRef}+ nestedScrollEnabled+ style={{+ marginBottom: 10+ }}+ onMomentumScrollEnd={() => {+ getRef().current?.handleChildScrollEnd();+ }}renderItem={({item, index}) => <RenderItem item={item} index={index} />}/>@@ -259,49 +229,52 @@ export const PremiumComponent = ({close, promo}) => {paddingHorizontal: 12}}>{product?.type !== 'promo' ? (- <View- style={{- flexDirection: 'row',- alignItems: 'center',- justifyContent: 'center',- marginBottom: 10- }}>- <Paragraph- onPress={() => {- setProduct({- type: 'monthly',- data: offers?.monthly- });- }}- style={{- color: product?.type == 'monthly' ? colors.accent : colors.pri,- fontWeight: product?.type == 'monthly' ? 'bold' : 'normal',- paddingVertical: 15,- minWidth: 100,- textAlign: 'right'- }}>- Monthly- </Paragraph>- <Paragraph size={20} style={{paddingHorizontal: 12}}>- {' | '}- </Paragraph>- <Paragraph- onPress={() => {- setProduct({- type: 'yearly',- data: offers?.yearly- });- }}+ user ? (+ <Viewstyle={{- color: product?.type == 'yearly' ? colors.accent : colors.pri,- fontWeight: product?.type == 'yearly' ? 'bold' : 'normal',- paddingVertical: 15,- minWidth: 100,- textAlign: 'left'+ flexDirection: 'row',+ alignItems: 'center',+ justifyContent: 'center',+ marginBottom: 10}}>- Yearly- </Paragraph>- </View>+ <Paragraph+ onPress={() => {+ setProduct({+ type: 'monthly',+ data: offers?.monthly+ });+ }}+ style={{+ color:+ product?.type == 'monthly' ? colors.accent : colors.pri,+ fontWeight: product?.type == 'monthly' ? 'bold' : 'normal',+ paddingVertical: 15,+ minWidth: 100,+ textAlign: 'right'+ }}>+ Monthly+ </Paragraph>+ <Paragraph size={20} style={{paddingHorizontal: 12}}>+ {' | '}+ </Paragraph>+ <Paragraph+ onPress={() => {+ setProduct({+ type: 'yearly',+ data: offers?.yearly+ });+ }}+ style={{+ color: product?.type == 'yearly' ? colors.accent : colors.pri,+ fontWeight: product?.type == 'yearly' ? 'bold' : 'normal',+ paddingVertical: 15,+ minWidth: 100,+ textAlign: 'left'+ }}>+ Yearly+ </Paragraph>+ </View>+ ) : null) : (<Headingstyle={{@@ -336,58 +309,61 @@ export const PremiumComponent = ({close, promo}) => {? `Subscribe for ${product?.data?.localizedPrice} / ${product.type === 'yearly' ? 'yr' : 'mo'}`- : 'Start Your 14 Day Free Trial'+ : 'Try free for 14 days'}type="accent"height={60}width="100%"/>- <Button- height={35}- style={{- marginTop: 10- }}- onPress={() => {- presentDialog({- context: 'local',- input: true,- inputPlaceholder: 'Enter code',- positiveText: 'Apply',- positivePress: async value => {- if (!value) return;- try {- let productId = await db.offers.getCode(- value,- Platform.OS- );- if (productId) {- ToastEvent.show({- heading: 'Discount applied!',- type: 'success',- context: 'local'- });- } else {+ {user && (+ <Button+ height={35}+ style={{+ marginTop: 10+ }}+ onPress={() => {+ presentDialog({+ context: 'local',+ input: true,+ inputPlaceholder: 'Enter code',+ positiveText: 'Apply',+ positivePress: async value => {+ if (!value) return;+ try {+ let productId = await db.offers.getCode(+ value,+ Platform.OS+ );+ if (productId) {+ ToastEvent.show({+ heading: 'Discount applied!',+ type: 'success',+ context: 'local'+ });+ } else {+ ToastEvent.show({+ heading: 'Promo code invalid or expired',+ type: 'error',+ context: 'local'+ });+ }+ } catch (e) {ToastEvent.show({heading: 'Promo code invalid or expired',+ message: e.message,type: 'error',context: 'local'});}- } catch (e) {- ToastEvent.show({- heading: 'Promo code invalid or expired',- message: e.message,- type: 'error',- context: 'local'- });- }- },- title: 'Have a promo code?',- paragraph: 'Enter your promo code to get a special discount.'- });- }}- title="I have a promo code"- />+ },+ title: 'Have a promo code?',+ paragraph:+ 'Enter your promo code to get a special discount.'+ });+ }}+ title="I have a promo code"+ />+ )}</>) : (<Paragraph@@ -407,7 +383,8 @@ export const PremiumComponent = ({close, promo}) => {style={{alignSelf: 'center',marginTop: 5,- textAlign: 'center'+ textAlign: 'center',+ marginTop: 10}}>Upon signing up, your 14 day free trial of Notesnook Pro will beactivated automatically.{' '}@@ -426,7 +403,7 @@ export const PremiumComponent = ({close, promo}) => {});}}color={colors.accent}- style={{fontWeight: 'bold'}}>+ style={{fontWeight: 'bold', textDecorationLine: 'underline'}}>Visit our website to learn what is included in the basic freeaccount.</Paragraph>@@ -522,61 +499,36 @@ export const PremiumComponent = ({close, promo}) => {) : null}</View><Toast context="local" />+ <View+ style={{+ paddingBottom: 10+ }}+ /></View>);};const RenderItem = React.memo(({item, index}) => {- const [state, dispatch] = useTracked();+ const [state] = useTracked();const colors = state.colors;return (<View- key={item.description}style={{- paddingVertical: 5,- marginBottom: 10,- width: '100%',- backgroundColor: colors.bg+ paddingHorizontal: 12,+ paddingVertical: 8,+ flexDirection: 'row',+ alignItems: 'center'}}>- <View+ <Icon size={SIZE.lg} color={colors.accent} name="check" />+ <Paragraphstyle={{- width: '95%',- alignItems: 'center',- alignSelf: 'center'- }}>- <SvgToPngView- src={item.icon(colors.accent)}- color={colors.accent}- img={item.img}- 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>+ marginLeft: 10+ }}+ size={SIZE.md + 2}>+ {item.title}+ </Paragraph></View>);},diff --git a/apps/mobile/src/components/Premium/PremiumDialog.js b/apps/mobile/src/components/Premium/PremiumDialog.jsindex 34b85a634..4e73c6f11 100644--- a/apps/mobile/src/components/Premium/PremiumDialog.js+++ b/apps/mobile/src/components/Premium/PremiumDialog.js@@ -38,7 +38,7 @@ class PremiumDialog extends React.Component {render() {return !this.state.visible ? null : (<ActionSheetWrapper onClose={this.onClose} fwdRef={this.actionSheetRef}>- <PremiumComponent promo={this.state.promo} close={this.close} />+ <PremiumComponent getRef={() => this.actionSheetRef} promo={this.state.promo} close={this.close} /></ActionSheetWrapper>);}