2020-10-28 15:15:35 +05:00
|
|
|
import React, {useEffect, useState} from 'react';
|
|
|
|
|
import {Text, View} from 'react-native';
|
|
|
|
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
|
|
|
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, WEIGHT} from '../../utils/SizeUtils';
|
|
|
|
|
import {Button} from '../Button';
|
|
|
|
|
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';
|
2020-10-28 15:15:35 +05:00
|
|
|
|
|
|
|
|
const ResultDialog = () => {
|
|
|
|
|
const [state, dispatch] = useTracked();
|
|
|
|
|
const {colors} = state;
|
|
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
|
const [dialogData, setDialogData] = useState({
|
|
|
|
|
title: '',
|
|
|
|
|
paragraph: '',
|
|
|
|
|
icon: null,
|
|
|
|
|
button: null,
|
|
|
|
|
});
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
eSubscribeEvent(eOpenResultDialog, open);
|
|
|
|
|
eSubscribeEvent(eCloseResultDialog, close);
|
|
|
|
|
return () => {
|
|
|
|
|
eUnSubscribeEvent(eOpenResultDialog, open);
|
|
|
|
|
eUnSubscribeEvent(eCloseResultDialog, close);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const open = (data) => {
|
|
|
|
|
setDialogData(data);
|
|
|
|
|
setVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const close = () => {
|
|
|
|
|
setVisible(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<BaseDialog visible={visible} onRequestClose={close}>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
...getElevation(5),
|
|
|
|
|
width: DDS.isTab ? 350 : '80%',
|
|
|
|
|
maxHeight: 350,
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
backgroundColor: colors.bg,
|
|
|
|
|
paddingHorizontal: ph,
|
|
|
|
|
paddingVertical: 20,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
}}>
|
|
|
|
|
<Icon name={dialogData.icon} color={colors.accent} size={80} />
|
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,
|
|
|
|
|
}}>
|
|
|
|
|
{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',
|
|
|
|
|
}}>
|
|
|
|
|
{dialogData.paragraph}
|
2020-11-20 01:23:05 +05:00
|
|
|
</Paragraph>
|
2020-10-28 15:15:35 +05:00
|
|
|
<Seperator />
|
|
|
|
|
<Button title={dialogData.button} width="100%" onPress={close} />
|
|
|
|
|
</View>
|
|
|
|
|
</BaseDialog>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ResultDialog;
|