* Allow to specify delay in ShowToast

This commit is contained in:
Michaël Van Canneyt 2022-06-13 10:01:46 +02:00
parent f81077146d
commit ade8cdd468

View File

@ -111,7 +111,13 @@ Type
Public Public
Constructor Create(aOwner : TComponent); override; Constructor Create(aOwner : TComponent); override;
class function Instance : TToastManager; class function Instance : TToastManager;
function ShowToast(const aHeader, aBody: String; aContext: TContextual=cNone; Closable: Boolean=True): TSimpleToastWidget; { Show toast with given header & body.
aHideDelay overrides ToastHideDelay:
-1 means do not autohide.
0 means use default (ToastAutoHide,ToastHideDelay)
>0 means use AutoHide after specified milliseconds.
}
function ShowToast(const aHeader, aBody: String; aContext: TContextual=cNone; Closable: Boolean=True; aHideDelay : Integer = 0): TSimpleToastWidget;
Published Published
Property MultiToast : Boolean Read FMultiToast Write SetMultiToast; Property MultiToast : Boolean Read FMultiToast Write SetMultiToast;
Property MinHeight : Integer Read FMinheight Write SetMinHeight default 250; Property MinHeight : Integer Read FMinheight Write SetMinHeight default 250;
@ -455,8 +461,26 @@ begin
FAnimate:=False; FAnimate:=False;
end; end;
function TToastManager.ShowToast(const aHeader, aBody: String; aContext : TContextual = cNone; Closable: Boolean = True): TSimpleToastWidget; function TToastManager.ShowToast(const aHeader, aBody: String;
aContext: TContextual; Closable: Boolean; aHideDelay: Integer
): TSimpleToastWidget;
Var
MsgDelay : Integer;
aHide : Boolean;
begin begin
MsgDelay:=aHideDelay;
if MsgDelay=0 then
begin
MsgDelay:=ToastHideDelay;
aHide:=ToastAutoHide;
end
else if MsgDelay=-1 then
begin
MsgDelay:=0;
aHide:=False;
end;
CheckInit; CheckInit;
Result:=TSimpleToastWidget.Create(Self) ; Result:=TSimpleToastWidget.Create(Self) ;
With Result do With Result do
@ -467,8 +491,8 @@ begin
HeaderImage:=ToastIcon; HeaderImage:=ToastIcon;
CloseButton:=Closable; CloseButton:=Closable;
Contextual:=aContext; Contextual:=aContext;
AutoHide:=ToastAutoHide; AutoHide:=aHide;
HideDelay:=ToastHideDelay; HideDelay:=msgDelay;
Animate:=ToastAnimate; Animate:=ToastAnimate;
MinWidth:=ToastMinWidth; MinWidth:=ToastMinWidth;
Refresh; Refresh;