Skip to content

Commit

Permalink
PageLayout is working properly now
Browse files Browse the repository at this point in the history
Fixed PageLayout behavior and now it's working properly. Now I have to work on improve it to be able to continue with the project.
  • Loading branch information
rafael-figueiredo-alves committed Nov 23, 2024
1 parent 5bf7af3 commit 4a5de37
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 23 deletions.
4 changes: 3 additions & 1 deletion eTasks.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ uses
eTasks.Components.Menu in 'src\Components\Offcanvas\eTasks.Components.Menu.pas' {OffcanvasMenu},
eTasks.Components.ActionButton in 'src\Components\Buttons\eTasks.Components.ActionButton.pas' {ActionButton},
eTasks.Components.NavBar in 'src\Components\Bars\eTasks.Components.NavBar.pas' {NavBar},
eTasks.View.PageLayout in 'src\View\eTasks.View.PageLayout.pas' {PageLayout};
eTasks.View.PageLayout in 'src\View\eTasks.View.PageLayout.pas' {PageLayout},
eTasks.View.Teste in 'src\View\eTasks.View.Teste.pas' {PageLayout1};

{$R *.res}

Expand All @@ -62,5 +63,6 @@ begin
{$ENDIF}

Application.CreateForm(TfMain, fMain);
Application.CreateForm(TPageLayout1, PageLayout1);
Application.Run;
end.
4 changes: 4 additions & 0 deletions eTasks.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@
<Form>PageLayout</Form>
<FormType>fmx</FormType>
</DCCReference>
<DCCReference Include="src\View\eTasks.View.Teste.pas">
<Form>PageLayout1</Form>
<FormType>fmx</FormType>
</DCCReference>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down
12 changes: 10 additions & 2 deletions src/View/eTasks.View.Main.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ object fMain: TfMain
Size.PlatformDefault = False
TabOrder = 0
object Button1: TButton
Position.X = 104.000000000000000000
Position.X = 96.000000000000000000
Position.Y = 80.000000000000000000
TabOrder = 0
TabOrder = 1
Text = 'Button1'
TextSettings.Trimming = None
OnClick = Button1Click
end
object Button2: TButton
Position.X = 96.000000000000000000
Position.Y = 200.000000000000000000
TabOrder = 0
Text = 'Button2'
TextSettings.Trimming = None
OnClick = Button2Click
end
end
object ScreensLayout: TLayout
Align = Right
Expand Down
34 changes: 26 additions & 8 deletions src/View/eTasks.View.Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ TfMain = class(TForm)
ScreensLayout: TLayout;
Button1: TButton;
Circle1: TCircle;
Button2: TButton;
procedure FormResize(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
AppBar : iAppBar;
Expand All @@ -41,7 +43,7 @@ TfMain = class(TForm)
AvatarMenu : iAvatarMenu;
ActionButton : iActionButton;
fDarkMode : Boolean;
Teste : TLayout;
Teste : iPageLayout;
procedure SetTheme(sender : TObject);
procedure SetLanguage(sender : TObject);
procedure TranslateUI;
Expand All @@ -63,19 +65,31 @@ implementation
eTasks.Components.ColorPallete,
eTasks.Components.Builder,
eTasks.Shared.Consts,
eTranslate4Pascal;
eTranslate4Pascal, eTasks.View.Teste;

{$R *.fmx}

procedure TfMain.Button1Click(Sender: TObject);
begin
if(Assigned(Teste))then
begin
//Teste.Release;
Teste := nil;
if(ScreensLayout.ContainsObject(Teste._Layout))then
ScreensLayout.RemoveObject(Teste._Layout);
end;

Teste := TPageLayout.New(ScreensLayout);
Teste := TPageLayout.New(ScreensLayout, ScreensLayoutChange);
ScreensLayoutChange;
end;

procedure TfMain.Button2Click(Sender: TObject);
begin
if(Assigned(Teste))then
begin
if(ScreensLayout.ContainsObject(Teste._Layout))then
ScreensLayout.RemoveObject(Teste._Layout);
end;

Teste := TPageLayout1.New(ScreensLayout, ScreensLayoutChange);
ScreensLayoutChange;
end;

Expand Down Expand Up @@ -124,24 +138,28 @@ procedure TfMain.RestrictScreenSize;

procedure TfMain.ScreensLayoutChange;
begin
ScreensLayout.Width := fMain.Width / 2;

if(fMain.Width > MobileSizeWidth)then
begin
ScreensLayout.Parent := ContentLayout;
ScreensLayout.Align := TAlignLayout.Right;
ScreensLayout.Width := fMain.Width / 2;
ScreensLayout.Visible := True;
end
else
begin
if(Assigned(Teste))then
if(Assigned(Teste))then
if(ScreensLayout.ContainsObject(Teste))then
if(ScreensLayout.ContainsObject(Teste._Layout))then
begin
ScreensLayout.Parent := fMain;
ScreensLayout.Align := TAlignLayout.Contents;
ScreensLayout.Visible := True;
end
else
begin
ScreensLayout.Parent := nil;
ScreensLayout.Visible := False;
end
else
begin
ScreensLayout.Parent := nil;
Expand Down
21 changes: 9 additions & 12 deletions src/View/eTasks.View.PageLayout.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface
function _Layout: TLayout;
end;

TMetodoScreen = Procedure of object;

TPageLayout = class(TForm, iPageLayout)
Button1: TButton;
Layout1: TLayout;
Expand All @@ -21,10 +23,11 @@ TPageLayout = class(TForm, iPageLayout)
private
{ Private declarations }
Layout: TLayout;
Metodo : TMetodoScreen;
public
{ Public declarations }
function _Layout: TLayout;
class function New(const pLayout: TLayout) : TLayout;
class function New(const pLayout: TLayout; met: TMetodoScreen) : iPageLayout;
destructor Destroy; override;
end;

Expand All @@ -39,18 +42,14 @@ implementation

procedure TPageLayout.Button1Click(Sender: TObject);
begin
if Assigned(Self) then
begin
// Remove Layout1 do Layout principal
if Assigned(Layout) and Layout.ContainsObject(Layout1) then
Layout.RemoveObject(Layout1);

// Força a atualização do foco para o formulário principal
Application.ProcessMessages;

// Use Release em vez de Free para evitar problemas de memória e foco
PageLayout.Release;
end;
Metodo;
end;

destructor TPageLayout.Destroy;
Expand All @@ -63,15 +62,13 @@ destructor TPageLayout.Destroy;
inherited;
end;

class function TPageLayout.New(const pLayout: TLayout): TLayout;
class function TPageLayout.New(const pLayout: TLayout; met: TMetodoScreen): iPageLayout;
begin
if(Assigned(PageLayout))then
PageLayout.Release;

PageLayout := Self.Create(nil);
PageLayout := Self.Create(pLayout);
PageLayout.Layout := pLayout;
pLayout.AddObject(PageLayout.Layout1);
Result := PageLayout.Layout1;
PageLayout.Metodo := met;
Result := PageLayout;
end;

function TPageLayout._Layout: TLayout;
Expand Down
16 changes: 16 additions & 0 deletions src/View/eTasks.View.Teste.fmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
inherited PageLayout1: TPageLayout1
Caption = 'PageLayout1'
DesignerMasterStyle = 0
inherited Layout1: TLayout
inherited Rectangle1: TRectangle
object Rectangle2: TRectangle
Fill.Color = xFFB90606
Position.X = 88.000000000000000000
Position.Y = 88.000000000000000000
Size.Width = 50.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
end
end
end
end
26 changes: 26 additions & 0 deletions src/View/eTasks.View.Teste.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
unit eTasks.View.Teste;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
eTasks.View.PageLayout, FMX.Controls.Presentation, FMX.Objects, FMX.Layouts;

type
TPageLayout1 = class(TPageLayout)
Rectangle2: TRectangle;
private
{ Private declarations }
public
{ Public declarations }
end;

var
PageLayout1: TPageLayout1;

implementation

{$R *.fmx}

end.

0 comments on commit 4a5de37

Please sign in to comment.