extend prompt instead
This commit is contained in:
@@ -34,6 +34,7 @@ export function Outer({
|
|||||||
control,
|
control,
|
||||||
testID,
|
testID,
|
||||||
nativeOptions,
|
nativeOptions,
|
||||||
|
type = 'sheet',
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
testID?: string
|
testID?: string
|
||||||
@@ -41,6 +42,12 @@ export function Outer({
|
|||||||
* Native-specific options for the prompt. Extends `BottomSheetViewProps`
|
* Native-specific options for the prompt. Extends `BottomSheetViewProps`
|
||||||
*/
|
*/
|
||||||
nativeOptions?: Omit<BottomSheetViewProps, 'children'>
|
nativeOptions?: Omit<BottomSheetViewProps, 'children'>
|
||||||
|
/**
|
||||||
|
* The presentation style of the prompt.
|
||||||
|
* - `sheet` (default): Bottom sheet on native, standard modal on web.
|
||||||
|
* - `alert`: Centered alert modal on all platforms.
|
||||||
|
*/
|
||||||
|
type?: 'sheet' | 'alert'
|
||||||
}>) {
|
}>) {
|
||||||
const titleId = useId()
|
const titleId = useId()
|
||||||
const descriptionId = useId()
|
const descriptionId = useId()
|
||||||
@@ -54,9 +61,10 @@ export function Outer({
|
|||||||
<Dialog.Outer
|
<Dialog.Outer
|
||||||
control={control}
|
control={control}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
|
type={type}
|
||||||
webOptions={{alignCenter: true}}
|
webOptions={{alignCenter: true}}
|
||||||
nativeOptions={{preventExpansion: true, ...nativeOptions}}>
|
nativeOptions={{preventExpansion: true, ...nativeOptions}}>
|
||||||
<Dialog.Handle />
|
{type !== 'alert' && <Dialog.Handle />}
|
||||||
<Context.Provider value={context}>
|
<Context.Provider value={context}>
|
||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
accessibilityLabelledBy={titleId}
|
accessibilityLabelledBy={titleId}
|
||||||
@@ -69,6 +77,35 @@ export function Outer({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function Icon({
|
||||||
|
icon: Comp,
|
||||||
|
color,
|
||||||
|
}: {
|
||||||
|
icon: React.ComponentType<SVGIconProps>
|
||||||
|
color?: ButtonColor
|
||||||
|
}) {
|
||||||
|
const t = useTheme()
|
||||||
|
|
||||||
|
let iconColor: string
|
||||||
|
switch (color) {
|
||||||
|
case 'negative':
|
||||||
|
iconColor = t.palette.negative_500
|
||||||
|
break
|
||||||
|
case 'primary':
|
||||||
|
iconColor = t.palette.primary_500
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
iconColor = t.atoms.text.color
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={[a.pb_sm]}>
|
||||||
|
<Comp size="xl" style={{color: iconColor}} />
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export function TitleText({
|
export function TitleText({
|
||||||
children,
|
children,
|
||||||
style,
|
style,
|
||||||
@@ -210,6 +247,8 @@ export function Basic({
|
|||||||
onConfirm,
|
onConfirm,
|
||||||
confirmButtonColor,
|
confirmButtonColor,
|
||||||
showCancel = true,
|
showCancel = true,
|
||||||
|
type,
|
||||||
|
icon,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogOuterProps['control']
|
||||||
title: string
|
title: string
|
||||||
@@ -226,10 +265,13 @@ export function Basic({
|
|||||||
onConfirm: (e: GestureResponderEvent) => void
|
onConfirm: (e: GestureResponderEvent) => void
|
||||||
confirmButtonColor?: ButtonColor
|
confirmButtonColor?: ButtonColor
|
||||||
showCancel?: boolean
|
showCancel?: boolean
|
||||||
|
type?: 'sheet' | 'alert'
|
||||||
|
icon?: React.ComponentType<SVGIconProps>
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<Outer control={control} testID="confirmModal">
|
<Outer control={control} testID="confirmModal" type={type}>
|
||||||
<Content>
|
<Content>
|
||||||
|
{icon && <Icon icon={icon} color={confirmButtonColor} />}
|
||||||
<TitleText>{title}</TitleText>
|
<TitleText>{title}</TitleText>
|
||||||
{description && <DescriptionText>{description}</DescriptionText>}
|
{description && <DescriptionText>{description}</DescriptionText>}
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
Reference in New Issue
Block a user