diff --git a/src/components/dialogs/Dialog.tsx b/src/components/dialogs/Dialog.tsx index 48a7aea8..2cd94a18 100644 --- a/src/components/dialogs/Dialog.tsx +++ b/src/components/dialogs/Dialog.tsx @@ -1,6 +1,6 @@ import React, { PropsWithChildren } from 'react'; import { - StyleProp, + Dimensions, StyleSheet, TextStyle, View, @@ -11,11 +11,12 @@ import { Button } from '../buttons/Button'; import { Headline } from '../typography/Headline'; import { DialogIcon, DialogIconProps } from './DialogIcon'; import { useTheme } from '../../styles/themes'; +import DeviceInfo from 'react-native-device-info'; interface Action { label: string; - disabled?: boolean - loading?: boolean + disabled?: boolean; + loading?: boolean; onPress: () => void; } @@ -40,43 +41,22 @@ export interface DialogProps extends PropsWithChildren { } export const Dialog = (props: DialogProps) => { - const theme = useTheme(); + const { + style, + actionsStyle, + leftActionsStyle, + rightActionsStyle, + actions, + variant, + } = props; - const titleStyle: StyleProp = { - textAlign: props.variant ?? 'left', - fontSize: 20, - fontFamily: 'PublicSans-Bold', - marginBottom: theme.sw.spacing.l, - marginTop: 0, - }; - const styles = StyleSheet.create({ - dialog: { - borderRadius: theme.sw.spacing.l, - paddingHorizontal: '5%', - paddingVertical: '5%', - marginTop: 0, - marginLeft: 'auto', - marginRight: 'auto', - width: '80%', - maxWidth: 500, - backgroundColor: theme.sw.colors.neutral[50], - ...props.style, - }, - actions: { - flexDirection: 'row', - justifyContent: props.actions.cancel ? 'flex-end' : 'center', - marginRight: 0, - marginTop: theme.sw.spacing.l, - ...props.actionsStyle, - }, - leftOption: { - color: theme.sw.colors.neutral[800], - marginRight: theme.sw.spacing.xs, - ...props.leftActionsStyle, - }, - rightOption: { - ...props.rightActionsStyle, - } + const styles = useStyles({ + style, + actionsStyle, + leftActionsStyle, + rightActionsStyle, + cancel: actions.cancel, + variant, }); return ( @@ -95,11 +75,13 @@ export const Dialog = (props: DialogProps) => { /> )} - + {props.title} - {props.children} + + {props.children} + {props.actions.cancel && (