Skip to content

Commit

Permalink
Added IsVisible method to ActionButton
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-figueiredo-alves committed Nov 13, 2024
1 parent 4bb6cf9 commit de90981
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion eTasks.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ begin
ReportMemoryLeaksOnShutdown := True;
GlobalUseSkia := True;
Application.Initialize;

{$IFDEF ANDROID}
eTranslate(TPath.Combine(TPath.GetDocumentsPath, 'translate.json'), 'pt-BR');
{$ENDIF}
Expand All @@ -59,6 +60,5 @@ begin
{$ENDIF}

Application.CreateForm(TfMain, fMain);
Application.CreateForm(TActionButton, ActionButton);
Application.Run;
end.
7 changes: 7 additions & 0 deletions src/Components/Buttons/eTasks.Components.ActionButton.pas
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ TActionButton = class(TForm, iActionButton)
function isDarkMode(const value: boolean): iActionButton;
function SetHint(const value: string): iActionButton;
function OnClick(const Event: TEventoClick): iActionButton;
function IsVisible(const Value: Boolean = true): iActionButton;

class function New(const Form: TForm): iActionButton;
end;
Expand Down Expand Up @@ -87,6 +88,12 @@ function TActionButton.isDarkMode(const value: boolean): iActionButton;
MudaCor.Start;
end;

function TActionButton.IsVisible(const Value: Boolean): iActionButton;
begin
Result := Self;
LayoutActionButton.Visible := Value;
end;

class function TActionButton.New(const Form: TForm): iActionButton;
begin
Result := Self.Create(Form);
Expand Down
1 change: 1 addition & 0 deletions src/Components/eTasks.Components.Interfaces.pas
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ interface
function isDarkMode(const value: boolean): iActionButton;
function SetHint(const value: string): iActionButton;
function OnClick(const Event: TEventoClick): iActionButton;
function IsVisible(const Value: Boolean = true): iActionButton;
end;

implementation
Expand Down
37 changes: 18 additions & 19 deletions src/View/eTasks.View.Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Effects,
FMX.Objects, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts,
eTasks.Components.Interfaces, FMX.MultiView;
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
FMX.Types,
FMX.Controls,
FMX.Forms,
FMX.Graphics,
FMX.Dialogs,
FMX.Effects,
FMX.Objects,
FMX.Controls.Presentation,
FMX.StdCtrls, FMX.Layouts,
eTasks.Components.Interfaces,
FMX.MultiView;

type
TTeste = procedure of Object;
Expand All @@ -28,8 +40,6 @@ TfMain = class(TForm)
procedure TranslateUI;
procedure OpenMenu(sender : TObject);
procedure OpenAvatarMenu(sender : TObject);
procedure Teste(sender : TObject);
procedure Teste2(sender : TObject);
public
{ Public declarations }
end;
Expand Down Expand Up @@ -57,7 +67,7 @@ procedure TfMain.FormCreate(Sender: TObject);
AppBar.SetButtonAppBarAction(ThemeBtn, SetTheme);
AppBar.SetButtonAppBarAction(MenuBtn, OpenMenu);
AppBar.SetButtonAppBarAction(AvatarBtn, OpenAvatarMenu);
ActionButton := TComponentButtons.ActionButton(fMain).OnClick(Teste).SetHint('Clique para um teste');
ActionButton := TComponentButtons.ActionButton(fMain).OnClick(SetLanguage).SetHint('Clique para um teste');
TranslateUI;
end;

Expand Down Expand Up @@ -104,22 +114,11 @@ procedure TfMain.SetTheme(sender: TObject);
Self.Fill.Color := TColorPallete.GetColor(Background, fDarkMode);
end;

procedure TfMain.Teste(sender : TObject);
begin
ShowMessage('Teste');
ActionButton.OnClick(Teste2);
end;

procedure TfMain.Teste2(sender: TObject);
begin
ShowMessage('Outro teste');
ActionButton.OnClick(Teste);
end;

procedure TfMain.TranslateUI;
begin
TitleBar.SetTitle(eTranslate.Translate('Main.Title'));
AppBar.SetTitle(eTranslate.Translate('Main.Title'));
ActionButton.SetHint(eTranslate.Translate('Main.Title'));
end;

end.

0 comments on commit de90981

Please sign in to comment.