mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
chore(overlays): generic for present/dismiss options (#26287)
This commit is contained in:
@ -19,7 +19,7 @@ import { iosEnterAnimation } from './animations/ios.enter';
|
||||
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||
import { mdEnterAnimation } from './animations/md.enter';
|
||||
import { mdLeaveAnimation } from './animations/md.leave';
|
||||
import type { ToastAttributes } from './toast-interface';
|
||||
import type { ToastAttributes, ToastPosition } from './toast-interface';
|
||||
|
||||
/**
|
||||
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
|
||||
@ -97,7 +97,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
/**
|
||||
* The position of the toast on the screen.
|
||||
*/
|
||||
@Prop() position: 'top' | 'bottom' | 'middle' = 'bottom';
|
||||
@Prop() position: ToastPosition = 'bottom';
|
||||
|
||||
/**
|
||||
* An array of buttons for the toast.
|
||||
@ -156,7 +156,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
*/
|
||||
@Method()
|
||||
async present(): Promise<void> {
|
||||
await present(this, 'toastEnter', iosEnterAnimation, mdEnterAnimation, this.position);
|
||||
await present<ToastPresentOptions>(this, 'toastEnter', iosEnterAnimation, mdEnterAnimation, this.position);
|
||||
|
||||
if (this.duration > 0) {
|
||||
this.durationTimeout = setTimeout(() => this.dismiss(undefined, 'timeout'), this.duration);
|
||||
@ -177,7 +177,15 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
if (this.durationTimeout) {
|
||||
clearTimeout(this.durationTimeout);
|
||||
}
|
||||
return dismiss(this, data, role, 'toastLeave', iosLeaveAnimation, mdLeaveAnimation, this.position);
|
||||
return dismiss<ToastDismissOptions>(
|
||||
this,
|
||||
data,
|
||||
role,
|
||||
'toastLeave',
|
||||
iosLeaveAnimation,
|
||||
mdLeaveAnimation,
|
||||
this.position
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,3 +352,6 @@ const buttonClass = (button: ToastButton): CssClassMap => {
|
||||
...getClassMap(button.cssClass),
|
||||
};
|
||||
};
|
||||
|
||||
type ToastPresentOptions = ToastPosition;
|
||||
type ToastDismissOptions = ToastPosition;
|
||||
|
||||
Reference in New Issue
Block a user