Jump to content


Photo

SweetAlert2


  • Please log in to reply
22 replies to this topic

#1 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 02 August 2017 - 02:05 AM

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

Attached Files


  • 1

#2 David Lee

David Lee

    Member

  • uniGUI Subscriber
  • PipPip
  • 39 posts

Posted 02 August 2017 - 04:34 AM

Thanks for shareing  !! 

 

In my case ( Delphi XE2 ) , Error  for being compiled .  

 

 

[DCC Fatal Error] uniExtSweetAlert.dpk(46): E2202 Required package 'RESTComponents' not found


  • 0

#3 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 02 August 2017 - 04:47 AM

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.


  • 0

#4 David Lee

David Lee

    Member

  • uniGUI Subscriber
  • PipPip
  • 39 posts

Posted 02 August 2017 - 06:08 AM

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;

  • 0

#5 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 02 August 2017 - 09:39 AM

Add RTTI

To the uses clause..

Will fix the problem..
  • 0

#6 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 02 August 2017 - 09:39 AM

Add RTTI

To the uses clause..

Will fix the problem..
  • 0

#7 David Lee

David Lee

    Member

  • uniGUI Subscriber
  • PipPip
  • 39 posts

Posted 02 August 2017 - 10:05 AM

 I have removed  REST.JSON,REST.Json.Types   only ! 

 

 RTTI is still remained in uses .

 

thanks ,


  • 0

#8 Freeman35

Freeman35

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 177 posts

Posted 02 August 2017 - 10:08 AM

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.


  • 0

#9 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 02 August 2017 - 11:17 AM

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).


  • 0

#10 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 02 August 2017 - 11:30 AM

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/k...ry-toast-plugin

 

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

 

Enjoy.

Attached Files


  • 1

#11 Freeman35

Freeman35

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 177 posts

Posted 02 August 2017 - 01:16 PM

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.


  • 0

#12 luiz rogerio reine

luiz rogerio reine

    Member

  • uniGUI Subscriber
  • PipPip
  • 12 posts

Posted 02 August 2017 - 02:27 PM

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.


  • 0

#13 Freeman35

Freeman35

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 177 posts

Posted 02 August 2017 - 06:27 PM

@CastleSoft

I tested toast, Its work and cool.

I tested sweetalert with  https://daneden.gith...o/animate.css/

  • 0

#14 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 03 August 2017 - 01:20 AM

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.

Attached Files


  • 0

#15 David Lee

David Lee

    Member

  • uniGUI Subscriber
  • PipPip
  • 39 posts

Posted 03 August 2017 - 02:00 AM

@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 !


  • 0

#16 CastleSoft

CastleSoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 153 posts

Posted 04 August 2017 - 02:12 AM

A few minor tweaks and another another freebie.

 

iTyped  - https://github.com/l...icius167/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).
 
 
 
 
 
 
 

  • 1

#17 anasb

anasb

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 13 August 2017 - 08:31 PM

 Thanks for your beautiful ext.

I have this error :

err_1.png


  • 0

#18 fabiomatte

fabiomatte

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 14 August 2017 - 12:37 PM

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?

  • 0

#19 Edmar Frazao

Edmar Frazao

    Member

  • uniGUI Subscriber
  • PipPip
  • 13 posts
  • LocationFormiga - MG - Brasil

Posted 16 August 2017 - 08:19 PM

 
 

Is it possible to change it to work on unigui mobile?


  • 0

#20 Erkan ÇAĞLAR

Erkan ÇAĞLAR

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 172 posts
  • LocationSamsun / Türkiye

Posted 18 August 2017 - 12:18 PM

I am getting an error.

Attached Files


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users