2022-01-22 12:57:05 +05:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { ScrollView, View } from 'react-native';
|
|
|
|
|
import { LAUNCH_ROCKET } from '../../assets/images/assets';
|
2022-02-28 23:25:18 +05:00
|
|
|
import { useThemeStore } from '../../stores/theme';
|
|
|
|
|
import { useUserStore } from '../../stores/stores';
|
|
|
|
|
import { DDS } from '../../services/device-detection';
|
|
|
|
|
import { eSendEvent, presentSheet } from '../../services/event-manager';
|
|
|
|
|
import PremiumService from '../../services/premium';
|
2022-01-22 12:57:05 +05:00
|
|
|
import { getElevation } from '../../utils';
|
2022-02-18 14:45:38 +05:00
|
|
|
import { db } from '../../utils/database';
|
|
|
|
|
import {
|
|
|
|
|
eClosePremiumDialog,
|
|
|
|
|
eCloseProgressDialog,
|
|
|
|
|
eOpenLoginDialog,
|
|
|
|
|
eOpenResultDialog
|
2022-02-28 13:48:59 +05:00
|
|
|
} from '../../utils/events';
|
|
|
|
|
import { SIZE } from '../../utils/size';
|
|
|
|
|
import { sleep } from '../../utils/time';
|
|
|
|
|
import umami from '../../utils/analytics';
|
|
|
|
|
import { IconButton } from '../ui/icon-button';
|
|
|
|
|
import { AuthMode } from '../auth';
|
|
|
|
|
import { Button } from '../ui/button';
|
|
|
|
|
import SheetProvider from '../sheet-provider';
|
|
|
|
|
import { SvgView } from '../ui/svg';
|
|
|
|
|
import Seperator from '../ui/seperator';
|
|
|
|
|
import { Toast } from '../toast';
|
|
|
|
|
import Heading from '../ui/typography/heading';
|
|
|
|
|
import Paragraph from '../ui/typography/paragraph';
|
|
|
|
|
import { Walkthrough } from '../walkthroughs';
|
2022-01-22 12:57:05 +05:00
|
|
|
import { features } from './features';
|
|
|
|
|
import { Group } from './group';
|
|
|
|
|
import { PricingPlans } from './pricing-plans';
|
2021-11-11 13:08:28 +05:00
|
|
|
|
2022-01-22 12:57:05 +05:00
|
|
|
export const Component = ({ close, promo, getRef }) => {
|
2022-02-28 23:25:18 +05:00
|
|
|
const colors = useThemeStore(state => state.colors);
|
2021-11-15 11:13:53 +05:00
|
|
|
const user = useUserStore(state => state.user);
|
2022-02-17 00:02:41 +05:00
|
|
|
const userCanRequestTrial =
|
|
|
|
|
user && (!user.subscription || !user.subscription.expiry) ? true : false;
|
2021-11-11 13:08:28 +05:00
|
|
|
const [floatingButton, setFloatingButton] = useState(false);
|
|
|
|
|
|
|
|
|
|
const onPress = async () => {
|
|
|
|
|
if (user) {
|
2022-01-20 00:13:33 +05:00
|
|
|
umami.pageView('/pro-plans', `/pro-screen`);
|
2021-11-11 13:08:28 +05:00
|
|
|
presentSheet({
|
|
|
|
|
context: 'pricing_plans',
|
2022-02-17 00:02:41 +05:00
|
|
|
component: <PricingPlans showTrialOption={false} marginTop={1} promo={promo} />
|
2021-11-11 13:08:28 +05:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
close();
|
2022-01-20 00:13:33 +05:00
|
|
|
umami.pageView('/signup', `/pro-screen`);
|
2021-11-11 13:08:28 +05:00
|
|
|
setTimeout(() => {
|
2022-02-17 00:02:41 +05:00
|
|
|
eSendEvent(eOpenLoginDialog, AuthMode.trialSignup);
|
2021-11-11 13:08:28 +05:00
|
|
|
}, 400);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onScroll = event => {
|
|
|
|
|
let contentSize = event.nativeEvent.contentSize.height;
|
|
|
|
|
contentSize = contentSize - event.nativeEvent.layoutMeasurement.height;
|
|
|
|
|
let yOffset = event.nativeEvent.contentOffset.y;
|
|
|
|
|
|
|
|
|
|
if (yOffset > 600 && yOffset < contentSize - 400) {
|
|
|
|
|
setFloatingButton(true);
|
|
|
|
|
} else {
|
|
|
|
|
setFloatingButton(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
backgroundColor: colors.bg,
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
borderRadius: 10,
|
2021-11-20 10:45:11 +05:00
|
|
|
maxHeight: '100%'
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-02-28 13:48:59 +05:00
|
|
|
<SheetProvider context="pricing_plans" />
|
|
|
|
|
<IconButton
|
2021-11-11 13:08:28 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
close();
|
|
|
|
|
}}
|
|
|
|
|
customStyle={{
|
|
|
|
|
position: 'absolute',
|
2021-11-20 10:45:11 +05:00
|
|
|
right: DDS.isTab ? 30 : 15,
|
2021-11-11 13:08:28 +05:00
|
|
|
top: 30,
|
|
|
|
|
zIndex: 10,
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 50
|
|
|
|
|
}}
|
|
|
|
|
color={colors.pri}
|
|
|
|
|
name="close"
|
|
|
|
|
/>
|
|
|
|
|
|
2021-11-18 14:52:29 +05:00
|
|
|
<ScrollView
|
2021-11-20 10:45:11 +05:00
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: DDS.isTab ? DDS.width / 5 : 0
|
|
|
|
|
}}
|
2021-12-02 21:21:00 +05:00
|
|
|
keyboardDismissMode="none"
|
|
|
|
|
keyboardShouldPersistTaps="always"
|
2022-01-22 12:57:05 +05:00
|
|
|
onScroll={onScroll}
|
|
|
|
|
>
|
2021-11-16 12:16:33 +05:00
|
|
|
<View
|
2022-01-07 23:50:19 +05:00
|
|
|
key="top-banner"
|
2021-11-11 13:08:28 +05:00
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
2021-11-16 12:16:33 +05:00
|
|
|
alignItems: 'center',
|
2021-11-20 10:45:11 +05:00
|
|
|
height: 400,
|
|
|
|
|
justifyContent: 'center'
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-02-28 13:48:59 +05:00
|
|
|
<SvgView width={350} height={350} src={LAUNCH_ROCKET(colors.accent)} />
|
2021-11-16 12:16:33 +05:00
|
|
|
</View>
|
|
|
|
|
|
2021-11-11 13:08:28 +05:00
|
|
|
<Heading
|
2022-01-07 23:50:19 +05:00
|
|
|
key="heading"
|
2021-11-11 13:08:28 +05:00
|
|
|
size={SIZE.lg}
|
|
|
|
|
style={{
|
|
|
|
|
alignSelf: 'center',
|
|
|
|
|
paddingTop: 20
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-11 13:08:28 +05:00
|
|
|
Notesnook{' '}
|
|
|
|
|
<Heading size={SIZE.lg} color={colors.accent}>
|
|
|
|
|
Pro
|
|
|
|
|
</Heading>
|
|
|
|
|
</Heading>
|
2022-02-01 15:17:12 +05:00
|
|
|
|
|
|
|
|
<Paragraph
|
|
|
|
|
style={{
|
|
|
|
|
alignSelf: 'center',
|
|
|
|
|
marginBottom: 20
|
|
|
|
|
}}
|
|
|
|
|
size={SIZE.md}
|
|
|
|
|
>
|
|
|
|
|
({PremiumService.getMontlySub().localizedPrice} / mo)
|
|
|
|
|
</Paragraph>
|
2021-11-11 13:08:28 +05:00
|
|
|
<Paragraph
|
2022-01-07 23:50:19 +05:00
|
|
|
key="description"
|
2021-11-11 13:08:28 +05:00
|
|
|
size={SIZE.md}
|
|
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
alignSelf: 'center',
|
|
|
|
|
paddingBottom: 20,
|
|
|
|
|
width: '90%'
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-11 13:08:28 +05:00
|
|
|
Ready to take the next step on your private note taking journey?
|
|
|
|
|
</Paragraph>
|
|
|
|
|
|
2022-02-17 00:02:41 +05:00
|
|
|
{userCanRequestTrial ? (
|
|
|
|
|
<Button
|
|
|
|
|
key="calltoaction"
|
2022-02-18 14:45:38 +05:00
|
|
|
onPress={async () => {
|
|
|
|
|
try {
|
|
|
|
|
await db.user.activateTrial();
|
|
|
|
|
eSendEvent(eClosePremiumDialog);
|
|
|
|
|
eSendEvent(eCloseProgressDialog);
|
|
|
|
|
await sleep(300);
|
|
|
|
|
Walkthrough.present('trialstarted', false, true);
|
|
|
|
|
} catch (e) {}
|
2022-02-17 00:02:41 +05:00
|
|
|
}}
|
|
|
|
|
title="Try free for 14 days"
|
|
|
|
|
type="accent"
|
|
|
|
|
width={250}
|
|
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
marginBottom: 15,
|
|
|
|
|
borderRadius: 100
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
|
|
|
|
|
2021-11-11 13:08:28 +05:00
|
|
|
<Button
|
2022-01-07 23:50:19 +05:00
|
|
|
key="calltoaction"
|
2021-11-11 13:08:28 +05:00
|
|
|
onPress={onPress}
|
2022-02-01 15:17:12 +05:00
|
|
|
title={promo ? promo.text : user ? `See all plans` : `Sign up for free`}
|
2022-02-17 00:02:41 +05:00
|
|
|
type={userCanRequestTrial ? 'grayAccent' : 'accent'}
|
|
|
|
|
width={250}
|
2021-11-11 13:08:28 +05:00
|
|
|
style={{
|
2022-02-17 00:02:41 +05:00
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
marginBottom: 15,
|
|
|
|
|
borderRadius: 100
|
2021-11-11 13:08:28 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
2022-02-17 00:02:41 +05:00
|
|
|
{!user || userCanRequestTrial ? (
|
2022-02-01 15:17:12 +05:00
|
|
|
<Paragraph
|
|
|
|
|
color={colors.icon}
|
|
|
|
|
size={SIZE.xs}
|
|
|
|
|
style={{
|
|
|
|
|
alignSelf: 'center',
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
marginTop: 10,
|
|
|
|
|
maxWidth: '80%'
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-02-17 00:02:41 +05:00
|
|
|
{user
|
|
|
|
|
? `On clicking "Try free for 14 days", your free trial will be activated.`
|
|
|
|
|
: `After sign up you will be asked to activate your free trial.`}{' '}
|
2022-02-01 15:17:12 +05:00
|
|
|
<Paragraph size={SIZE.xs} style={{ fontWeight: 'bold' }}>
|
|
|
|
|
No credit card is required.
|
|
|
|
|
</Paragraph>
|
|
|
|
|
</Paragraph>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
<Seperator key="seperator_1" />
|
2021-11-11 13:08:28 +05:00
|
|
|
|
|
|
|
|
{features.map((item, index) => (
|
2022-01-07 23:50:19 +05:00
|
|
|
<Group key={item.title} item={item} index={index} />
|
2021-11-11 13:08:28 +05:00
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
<View
|
2022-01-07 23:50:19 +05:00
|
|
|
key="plans"
|
2021-11-11 13:08:28 +05:00
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: 12
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-02-17 00:02:41 +05:00
|
|
|
<PricingPlans showTrialOption={false} promo={promo} />
|
2021-11-11 13:08:28 +05:00
|
|
|
</View>
|
|
|
|
|
</ScrollView>
|
|
|
|
|
|
|
|
|
|
{floatingButton ? (
|
|
|
|
|
<Button
|
|
|
|
|
onPress={onPress}
|
2022-02-01 15:17:12 +05:00
|
|
|
title={promo ? promo.text : user ? `See all plans` : 'Sign up for free'}
|
2021-11-11 13:08:28 +05:00
|
|
|
type="accent"
|
|
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: 24,
|
|
|
|
|
position: 'absolute',
|
2022-02-17 00:02:41 +05:00
|
|
|
borderRadius: 100,
|
2021-11-11 13:08:28 +05:00
|
|
|
bottom: 30,
|
|
|
|
|
...getElevation(10)
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
<Toast context="local" />
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
paddingBottom: 10
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
};
|