Jump to content
uniGUI Discussion Forums

Recommended Posts

Attached is a simple wrapper for the SweetAlert2 library.  (QUICK HACK.. No unit testing, no tidy up etc..)

 

** No warranty - Use at your own risk **

 

FREE for commercial use, etc.. (just don't remove the copyright header).

 

1) Compile the Package/Install

2) Make sure your path includes the control folder

3) Copy the files/sweetalert folder into your project

4) Drag/Drop the uniSweetAlert control onto your form.

 

Simple usage like:

 

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
 
   UniSweetAlert1.ShowMessage;
 
// or like
 
   UniSweetAlert1.Error('Oops','Something went wrong');
 
// or like
 
   UniSweetAlert1.Error('Oops','Error again','FixMe',3000);
 
// or like
 
   UniSweetAlert1.Question('Is this true','Please click one of the options below:','YES','NO',3000);
 
// or like
 
   UniSweetAlert1.title := 'Hello';
   UniSweetAlert1.text  := 'Testing';
   UniSweetAlert1.alertType := TAlertType.success;
   UniSweetAlert1.ShowMessage;
end;
 
// Events for Confirm or Cancel/Dismiss
 
procedure TMainForm.UniSweetAlert1Dismiss(Sender: TObject);
begin
   UniButton1.Caption := 'DIS';
   uniMemo1.Lines.Add('Dis');
end;
 
procedure TMainForm.UniSweetAlert1Success(Sender: TObject);
begin
   UniButton1.Caption := 'CLICKED';
   uniMemo1.Lines.Add('Clicked');
end;
 
Either (1) set properties and call .ShowMessage;
 
Or call the Error, Info, etc methods.
 
Enjoy..
 
Regards
Andrew

2017-07-29-uniSweetAlert V3.zip

post-14-0-33457200-1501639154_thumb.png

post-14-0-83284700-1501639167_thumb.png

post-14-0-41627600-1501639177_thumb.png

post-14-0-77223100-1501639190_thumb.png

post-14-0-60900300-1501639209_thumb.png

post-14-0-64863000-1501639219_thumb.png

  • Upvote 1

Share this post


Link to post
Share on other sites

RESTComponents can be removed. Originally I planned on using the TJSon.OjectToJson method.. But removed the code and went simple strings instead.
So it shouldn't be needed.

Share this post


Link to post
Share on other sites

Thanks for you .

 

After I removed RESTComponent , Error 

 

Uses 

......

 

REST.JSON,REST.Json.Types ,    <-- removed 

 

I removed it ( REST.JSON,REST.Json.Types , )  

 

compiled again , but Error 

 

function TUniSweetAlert.GetAlertType(a: TAlertType): string;

begin
   result := TRttiEnumerationType.GetName(a);             <--- Error !!
 
end;

Share this post


Link to post
Share on other sites

Castle soft,

I was lookfor how to use sweetalert. Thank you.

need to work on it, For example, I'll tested it,

UniSweetAlert1.Error('Oops','Something went wrong');   this box allways behind my form.

on my loginform, same, behind my loginform, and its just paint whitebox I can't see in.

js & css files hasto under "files" folder, need copy there.

Just myidea. This usage can be a unit. Not have to component, so can use with callback procedure for dissmis or Success events. And need to wich button clicked on thats events. For example, cancel and no buttons is diffrent.

Best regards.

Share this post


Link to post
Share on other sites

To fix the Floating behind the Login form you could add the following to the ServerModule.CustomCSS

 

.swal2-container { z-index:20000; }

 

OR..

 

The next post has an updated version (new files/sweetalert with the extra css). + a new jQuery Toast control + DEMO / Test (c:\tmp was the original folder containing the files).

Share this post


Link to post
Share on other sites

Updated SweetAlert2 control (REST) removed, fix Z-Order issue when the alert appears behind the form.

 

Added TEST / DEMO

 

Added a new control wrapper for jToast 

 

https://github.com/kamranahmedse/jquery-toast-plugin

 

(uniJToast currently has properties, a simple ShowMessage and events for Before/After Show/Hide.)

 

Enjoy.

uniExtensions.zip

post-14-0-71038200-1501672976_thumb.png

post-14-0-58625100-1501673368_thumb.png

post-14-0-73359200-1501673377_thumb.png

post-14-0-92507400-1501673388_thumb.png

  • Upvote 1

Share this post


Link to post
Share on other sites

To fix the Floating behind the Login form you could add the following to the ServerModule.CustomCSS

 

.swal2-container { z-index:20000; }

Thank you, This solution fixed my problem.

I'll test toast example soon

regards.

Share this post


Link to post
Share on other sites

Hi. I'm trying to install these components on Delphi XE8 and got the error on the UniGUI unit seCSSParser.pas that says the unit Dialogs is missing.

Is there a way to install it on this version? (it looks like you use version 10.2 Tokyo). 

Thanks.

Share this post


Link to post
Share on other sites

A few more fixes.

 

- Z-Index for jToast fixed

- buttonsStyling (typo / spelling incorrect in SweetAlert2)

 

New css file added to jToast.  (re-grab the files/jtoast and   files/sweetalert folders in any code you use for the updated).

 

Added 'custom' to  jToast..  when 'Pos: custom' the Left and Top are used for positioning.

 

*** If you are using an older version you may need to ignore the buttonStyling missing error and toggle the 'buttonsStyling' and save to fix.

*** If you have Z-Index issues.. Clear your browser cache and try again.

 

Enjoy.

uniExtensions-V5.zip

Share this post


Link to post
Share on other sites

@CastleSoft .

 

In XE2 , still got Same Error !   ( result := TRttiEnumerationType.GetName(a);             <--- Error !!   

 

To install and test your nice component , I edited some lines of code .

 ex )  result :=  'anyString'  ;    // each one of  arrays 

 

Now , it works , Cooool !! 

 

Many thanks !

Share this post


Link to post
Share on other sites

A few minor tweaks and another another freebie.

 

iTyped  - https://github.com/luisvinicius167/ityped

 

Simply add the uniTyped control (resize to your size).

 

var s: TStrings;
begin
  s := TStringList.Create;
  s.Add('Welcome to the jungle');
  s.Add('Restarting soo...');
  UniTyped1.text := s;
  UniTyped1.PlayTyped;
  s.Free;
end;
 
or 
 
Just set the properties in the control and do a UniTyped.PlayTyped.
 
Source code and Example below (includes the sweetalert/jquerytoast/iTyped).
 
 
 
 
 
 
 
  • Upvote 1

Share this post


Link to post
Share on other sites
When I implemented SweetAlert2 to display a message, the message is opening behind the MainForm form and not where I want it.

I have already added the files / * in the indicated places and everything, but the message still appears behind the MainForm.

 

And I did exactly as in DEMO.

 

How could I solve this?

Share this post


Link to post
Share on other sites

Try first remove delphi settings files. dcu, dof etc. without dpk,pas,res etc. after then try build dpk file. that error mean can not find unicore bpl in search file.

Share this post


Link to post
Share on other sites
Hi @CastleSoft  !!

 

When I do InputType on SweetAlwert2 like below codes , How can i get the filename from SweetAlert2 ?  

 

<button click>

    UniSweetAlert.inputType := TInputType.fileinput ;

    UniSweetAlert.ShowMessage ;

 

<OnSussess Event>

 

   - How can i get the FileName from SweetAlert2 ? 

 

 

Thanks !! 

Share this post


Link to post
Share on other sites

Na versão 1397 esta com esse erro [dcc32 Fatal Error] uniExtensions.dpk(32): E2202 Required package 'uniGUI25Core' not found

Resolvido galera, é só remover do projeto o arquivos que tem 25, quando for compilar o próprio delphi vai surgerir colocar os arquivos de acordo com sua versão do unigui, abraços galera

Share this post


Link to post
Share on other sites

×