This class is intended to show a Loading image on the device's screen.
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
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.
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;
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;;
Loading
is free and open-source library licensed under the MIT License.