Code Monkey home page Code Monkey logo

loading's Introduction

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.

loading's People

Contributors

asrsantos avatar adrianosantostreina avatar igorbastosib avatar

Stargazers

 avatar Cicero Romão avatar dbaspider avatar Steve Narancic avatar César Arrais avatar  avatar Juan Young avatar  avatar Charalampos Michael avatar Pavel Moroz avatar Ali Dehbansiahkarbon avatar  avatar Me avatar

Watchers

James Cloos avatar Charalampos Michael avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.