import * as React from 'react'; import { Dialog, Divider, Surface, Text } from 'react-native-paper'; import { DialogType, PromptDialogData } from './types'; import { StyleSheet } from 'react-native'; import { useMemo } from 'react'; import { themeStyle } from '../global-style'; import PromptButton from './PromptButton'; interface Props { dialog: PromptDialogData; themeId: number; } const useStyles = (themeId: number, isMenu: boolean) => { return useMemo(() => { const theme = themeStyle(themeId); return StyleSheet.create({ dialogContainer: { backgroundColor: theme.backgroundColor, borderRadius: theme.borderRadius, paddingTop: theme.borderRadius, marginLeft: 4, marginRight: 4, }, dialogContent: { paddingBottom: 14, }, dialogActions: { paddingBottom: 14, paddingTop: 4, ...(isMenu ? { flexDirection: 'column', alignItems: 'stretch', } : {}), }, dialogLabel: { textAlign: isMenu ? 'center' : undefined, }, }); }, [themeId, isMenu]); }; const PromptDialog: React.FC = ({ dialog, themeId }) => { const isMenu = dialog.type === DialogType.Menu; const styles = useStyles(themeId, isMenu); const buttons = dialog.buttons.map((button, index) => { return ; }); const titleComponent = {dialog.title}; return ( {dialog.title ? titleComponent : null} {dialog.message} {isMenu ? : null} {buttons} ); }; export default PromptDialog;