Skip to content

This class is intended to show a Loading image on the device's screen.

License

Notifications You must be signed in to change notification settings

adrianosantostreina/Loading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loading

Loading

This class is intended to show a Loading image on the device's screen.

Installation

Just register in the Library Path of your Delphi the path of the SOURCE folder of the library, or if you prefer, you can use Boss (dependency manager for Delphi) to perform the installation:

boss install github.com/adrianosantostreina/Loading

Use

Declare Loading in the Uses section of the unit where you want to make the call to the class's method.

uses
   Loading;
  • Drag a TButtom control onto the Form
  • Drag a TTimer control onto the Form*
  • Set Enable property to False in TTimer
  • Code TButtom's OnClick event as below
  • Code Ttimer's OnTimer event as below

*The use of Timer in this example is merely didactic, prefer to use TThreads instead of Timers

procedure TForm2.Button1Click(Sender: TObject);
begin
  TLoading.Show('Loading customer...');
  Timer1.Enabled := True;
end;

procedure TForm2.Timer1Timer(Sender: TObject);
begin
  TLoading.Hide;
  Timer1.Enabled := False;
end;

Compile the project, run it and click the Load button.

Print

Change Messaging

If you need to modify the message during the display of Loading, just use the ChangeMessage method passing the new message. Use the Synchornize method for this.

  • Drag a new TButtom control onto the Form
  • Drag a new TTimer control onto the Form*
  • Code TButtom's OnClick event as below
  • Code Ttimer's OnTimer event as below
[...]
  private
    LTime : Integer;
[...]

procedure TForm2.ChangeClick(Sender: TObject);
begin
  TLoading.Show('Loading customer...');
  Timer2.Enabled := True;
end;

[...]

procedure TForm2.Timer2Timer(Sender: TObject);
begin
  Inc(LTime);
  if LTime = 2 then
    TLoading.ChangeMessage('Loading products...')
  else if LTime = 5 then
    TLoading.ChangeMessage('Loading settings...')
  else if LTime = 7 then
    TLoading.ChangeMessage('Ending...')
  else if LTime = 10 then
  begin
    TLoading.Hide;
    Timer2.Enabled := False;
  end;
end;

Print Print

Customizing the Load Circle

If you are interested in modifying the Loading colors or increasing/decreasing the radius of the circles, it is entirely possible**.

** Make a backup of Loading.pas if you want to keep your customizations. New installations and/or updates through Boss will cause the unit to be downloaded with the default values from our GitHub

Open the Loading.pas unit and find the Show method

class procedure TLoading.Show(const AMessage: string; AForm: TFMXObject = nil);

The Show method contains all the code to create the circles at runtime. Just make adjustments where you want.

  [...]
  //Arco menor (Inner Arc)
  ArcLoad.Stroke.Color                     := TAlphaColorRec.White;

  [...]
  //Arco maior (Outer Arc)
  ArcLoadMaior.Stroke.Color                := TAlphaColorRec.White;;

Print

Documentation Languages

English (en)
Português (ptBR)

⚠️ License

Loading is free and open-source library licensed under the MIT License.

About

This class is intended to show a Loading image on the device's screen.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages