Files
notesnook/apps/mobile/src/components/ResultDialog/index.js

102 lines
2.8 KiB
JavaScript
Raw Normal View History

2021-07-30 09:23:24 +05:00
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
import { useTracked } from '../../provider';
import { DDS } from '../../services/DeviceDetection';
import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
import { getElevation } from '../../utils';
import { eCloseResultDialog, eOpenResultDialog } from '../../utils/Events';
import { ph, SIZE } from '../../utils/SizeUtils';
import { Button } from '../Button';
2020-10-28 15:15:35 +05:00
import BaseDialog from '../Dialog/base-dialog';
import Seperator from '../Seperator';
2020-11-20 01:23:05 +05:00
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
import { ProFeatures } from './pro-features';
2020-10-28 15:15:35 +05:00
const ResultDialog = () => {
const [state, dispatch] = useTracked();
const {colors} = state;
2021-11-09 09:28:56 +05:00
const [visible, setVisible] = useState(false);
2020-10-28 15:15:35 +05:00
const [dialogData, setDialogData] = useState({
2021-11-08 11:56:54 +05:00
title: 'Thank you for signing up!',
paragraph:
'Try out all features of Notesnook free for 7 days. No limitations. No commitments.',
button: 'Start taking notes'
2020-10-28 15:15:35 +05:00
});
useEffect(() => {
eSubscribeEvent(eOpenResultDialog, open);
eSubscribeEvent(eCloseResultDialog, close);
return () => {
eUnSubscribeEvent(eOpenResultDialog, open);
eUnSubscribeEvent(eCloseResultDialog, close);
};
}, []);
2021-04-11 10:34:01 +05:00
const open = data => {
2020-10-28 15:15:35 +05:00
setDialogData(data);
setVisible(true);
};
const close = () => {
setVisible(false);
};
2020-11-23 12:32:33 +05:00
return !visible ? null : (
<BaseDialog visible={true} onRequestClose={close}>
2020-10-28 15:15:35 +05:00
<View
style={{
...getElevation(5),
2020-12-22 10:27:51 +05:00
width: DDS.isTab ? 350 : '85%',
2021-11-08 11:56:54 +05:00
maxHeight: 500,
borderRadius: 10,
2020-10-28 15:15:35 +05:00
backgroundColor: colors.bg,
paddingHorizontal: ph,
paddingVertical: 20,
justifyContent: 'center',
2021-11-08 11:56:54 +05:00
alignItems: 'center'
2020-10-28 15:15:35 +05:00
}}>
2020-11-20 01:23:05 +05:00
<Heading
size={SIZE.lg}
2021-07-30 09:23:24 +05:00
textBreakStrategy="balanced"
2020-10-28 15:15:35 +05:00
style={{
alignSelf: 'center',
textAlign: 'center',
marginTop: 10,
2021-03-09 10:39:57 +05:00
maxWidth: '80%',
2021-11-08 11:56:54 +05:00
marginBottom: 10
2020-10-28 15:15:35 +05:00
}}>
{dialogData.title}
2020-11-20 01:23:05 +05:00
</Heading>
2020-11-20 01:23:05 +05:00
<Paragraph
color={colors.icon}
2021-11-08 11:56:54 +05:00
size={SIZE.md}
2020-10-28 15:15:35 +05:00
style={{
alignSelf: 'center',
textAlign: 'center',
2021-03-09 10:39:57 +05:00
maxWidth: '80%',
2021-11-08 11:56:54 +05:00
lineHeight: SIZE.sm + 5
2020-10-28 15:15:35 +05:00
}}>
{dialogData.paragraph}
2020-11-20 01:23:05 +05:00
</Paragraph>
<Seperator />
<ProFeatures />
2020-10-28 15:15:35 +05:00
<Seperator />
2021-03-09 10:39:57 +05:00
<Button
title={dialogData.button}
width="100%"
onPress={close}
2021-11-08 11:56:54 +05:00
type="accent"
height={50}
2021-03-09 10:39:57 +05:00
fontSize={SIZE.md}
/>
2020-10-28 15:15:35 +05:00
</View>
</BaseDialog>
);
};
export default ResultDialog;