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

100 lines
2.8 KiB
JavaScript
Raw Normal View History

2021-03-09 10:14:00 +05:00
import React, {useEffect, useState} from 'react';
import {View} from 'react-native';
import {SvgXml} from 'react-native-svg';
import {WELCOME_SVG} from '../../assets/images/assets';
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';
2021-04-11 10:34:01 +05:00
import {SvgToPngView} from '../ListPlaceholders';
2020-10-28 15:15:35 +05:00
import Seperator from '../Seperator';
2020-11-20 01:23:05 +05:00
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
2020-10-28 15:15:35 +05:00
const ResultDialog = () => {
const [state, dispatch] = useTracked();
const {colors} = state;
const [visible, setVisible] = useState(false);
2020-10-28 15:15:35 +05:00
const [dialogData, setDialogData] = useState({
2021-03-09 10:39:57 +05:00
title: 'Welcome to your private\nnote taking haven',
paragraph: 'Please confirm your email to encrypt and sync all your notes.',
2021-03-09 10:14:00 +05:00
icon: 'check',
2021-03-09 10:39:57 +05:00
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%',
2020-10-28 15:15:35 +05:00
maxHeight: 350,
borderRadius: 5,
backgroundColor: colors.bg,
paddingHorizontal: ph,
paddingVertical: 20,
justifyContent: 'center',
alignItems: 'center',
}}>
2021-04-11 10:34:01 +05:00
<SvgToPngView
src={WELCOME_SVG(colors.accent)}
color={colors.accent}
img="welcome"
width={170}
height={170}
/>
2021-03-09 10:14:00 +05:00
2020-11-20 01:23:05 +05:00
<Heading
size={SIZE.lg}
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%',
2020-10-28 15:15:35 +05:00
}}>
{dialogData.title}
2020-11-20 01:23:05 +05:00
</Heading>
<Paragraph
color={colors.icon}
2020-10-28 15:15:35 +05:00
style={{
alignSelf: 'center',
textAlign: 'center',
2021-03-09 10:39:57 +05:00
maxWidth: '80%',
2020-10-28 15:15:35 +05:00
}}>
{dialogData.paragraph}
2020-11-20 01:23:05 +05:00
</Paragraph>
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}
fontSize={SIZE.md}
/>
2020-10-28 15:15:35 +05:00
</View>
</BaseDialog>
);
};
export default ResultDialog;