import React from 'react';
import { View, Text } from 'react-native';
import noop from 'lodash-es/noop';
import PopupDialog from '../Popup/Dialog';
import { ActionBar } from '../ActionBar';
import Button from '../Button';
import { useThemeFactory } from '../Theme';
import createStyle from './style';
import type { DialogProps } from './type';
const Dialog = (props: DialogProps): JSX.Element => {
const { width, title, theme, visible, message, messageAlign = 'center', ...others } = props;
const { styles } = useThemeFactory(createStyle);
const renderTitle = () => {
if (props.title) {
return (
{title}
);
}
return null;
};
const renderContent = () => {
if (props.children) {
return {props.children};
}
if (message) {
return (
{message}
);
}
return null;
};
const renderButtons = () => (
{props.showCancelButton && (
)}
{props.showConfirmButton && (
)}
);
const renderRoundButtons = () => (
{props.showCancelButton && (
)}
{props.showConfirmButton && (
)}
);
const renderFooter = () => {
if (props.footer) return props.footer;
return props.theme === 'round-button' ? renderRoundButtons() : renderButtons();
};
return (
{renderTitle()}
{renderContent()}
{renderFooter()}
);
};
export default Dialog;