Skip to content

Commit

Permalink
Implemented TitleBar
Browse files Browse the repository at this point in the history
Finished Implementing Component Titlebar
  • Loading branch information
rafael-figueiredo-alves committed Oct 14, 2024
1 parent b7fcfe6 commit eb6a9a3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 35 deletions.
3 changes: 2 additions & 1 deletion eTasks.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ uses
eTasks.Components.Interfaces in 'src\Components\eTasks.Components.Interfaces.pas',
eTasks.Shared.Utils in 'src\Shared\eTasks.Shared.Utils.pas',
eTasks.Components.Builder in 'src\Components\eTasks.Components.Builder.pas',
eTasks.Components.Offcanvas in 'src\Components\Offcanvas\eTasks.Components.Offcanvas.pas' {Offcanvas};
eTasks.Components.Offcanvas in 'src\Components\Offcanvas\eTasks.Components.Offcanvas.pas' {Offcanvas},
eTasks.Shared.Consts in 'src\Shared\eTasks.Shared.Consts.pas';

{$R *.res}

Expand Down
1 change: 1 addition & 0 deletions eTasks.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
<Form>Offcanvas</Form>
<FormType>fmx</FormType>
</DCCReference>
<DCCReference Include="src\Shared\eTasks.Shared.Consts.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down
17 changes: 8 additions & 9 deletions src/Components/Bars/eTasks.Components.TitleBar.fmx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object TitleBar: TTitleBar
Left = 0
Top = 0
Caption = 'Form1'
Caption = 'Z'
ClientHeight = 480
ClientWidth = 640
FormFactor.Width = 320
Expand All @@ -11,30 +11,29 @@ object TitleBar: TTitleBar
object LayoutTitleBar: TLayout
Align = Top
Size.Width = 640.000000000000000000
Size.Height = 40.000000000000000000
Size.Height = 45.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
object TitleBar: TRectangle
Align = Left
Fill.Color = xFF336699
Margins.Left = -15.000000000000000000
Margins.Top = 5.000000000000000000
Margins.Top = 10.000000000000000000
Margins.Bottom = 5.000000000000000000
Position.X = -15.000000000000000000
Position.Y = 5.000000000000000000
Size.Width = 235.000000000000000000
Position.Y = 10.000000000000000000
Size.Width = 264.000000000000000000
Size.Height = 30.000000000000000000
Size.PlatformDefault = False
Stroke.Kind = None
XRadius = 15.000000000000000000
YRadius = 15.000000000000000000
object TitleBarText: TLabel
Align = Right
Align = Center
AutoSize = True
StyledSettings = [Style]
Position.X = -0.199996948242187500
Size.Width = 235.199996948242200000
Size.Height = 30.000000000000000000
Size.Width = 282.399993896484400000
Size.Height = 25.600000381469730000
Size.PlatformDefault = False
TextSettings.Font.Family = 'Comic Sans MS'
TextSettings.Font.Size = 18.000000000000000000
Expand Down
18 changes: 11 additions & 7 deletions src/Components/Bars/eTasks.Components.TitleBar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ TTitleBar = class(TForm, iTitleBar)
{ Private declarations }
public
{ Public declarations }
function Render : TLayout;
function ChangeTitle(const Title: string): iTitleBar;
function SetTitle(const Title: string): iTitleBar;
function isDarkMode(const value: boolean): iTitleBar;
function Resize(const FormWidth: Integer): iTitleBar;

class function New(const Form: TForm; const Layout: TLayout): iTitleBar;
end;

Expand All @@ -31,21 +32,24 @@ TTitleBar = class(TForm, iTitleBar)
implementation

uses
eTasks.Components.ColorPallete;
eTasks.Components.ColorPallete,
eTasks.Shared.Consts;

{$R *.fmx}

{ TTitleBar }

function TTitleBar.ChangeTitle(const Title: string): iTitleBar;
function TTitleBar.SetTitle(const Title: string): iTitleBar;
begin
Result := self;
self.TitleBarText.text := Title;
end;

function TTitleBar.Render: TLayout;
function TTitleBar.Resize(const FormWidth: Integer): iTitleBar;
begin
Result := self.LayoutTitleBar;
Result := Self;
self.TitleBar.Visible := FormWidth <= MobileSizeWidth;
self.TitleBar.Width := Round((FormWidth * 70) / 100);
end;

function TTitleBar.isDarkMode(const value: boolean): iTitleBar;
Expand All @@ -58,7 +62,7 @@ function TTitleBar.isDarkMode(const value: boolean): iTitleBar;
class function TTitleBar.New(const Form: TForm; const Layout: TLayout): iTitleBar;
begin
Result := self.create(Form);
Layout.AddObject(Result.Render);
Layout.AddObject(TTitleBar(Result).LayoutTitleBar);
end;

end.
4 changes: 2 additions & 2 deletions src/Components/eTasks.Components.Interfaces.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ interface

iTitleBar = interface
['{CCA6D914-787E-495F-ADE7-F9472A0FBC45}']
function Render : TLayout;
function ChangeTitle(const Title: string): iTitleBar;
function SetTitle(const Title: string): iTitleBar;
function Resize(const FormWidth: Integer): iTitleBar;
function isDarkMode(const value: boolean): iTitleBar;
end;

Expand Down
21 changes: 21 additions & 0 deletions src/Shared/eTasks.Shared.Consts.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
unit eTasks.Shared.Consts;

interface

{$REGION 'Dados da Aplicação'}
const AppName = 'eTasks';
const AppVersionName = '2.0.0';
const AppVersion = 1;
{$ENDREGION}

const Firebase_API_Key = '';

{$REGION 'Constantes de Tamanho'}
const MobileSizeWidth = 768;
const MinimumHeight = 640;
const MinimumWidth = 360;
{$ENDREGION}

implementation

end.
25 changes: 9 additions & 16 deletions src/View/eTasks.View.Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ implementation

uses
eTasks.Components.ColorPallete,
eTasks.Components.Builder;
eTasks.Components.Builder,
eTasks.Shared.Consts;

{$R *.fmx}

Expand All @@ -43,29 +44,21 @@ procedure TfMain.FormCreate(Sender: TObject);
fDarkMode := False;
AppBar := TComponentBars.AppBar(fMain, MainLayout).isDarkMode(fDarkMode);
TitleBar := TComponentBars.TitleBar(fMain, MainLayout);
MainMenu := TComponentOffcanvas.MainMenu(fMain, ocdLeft, true);
MainMenu := TComponentOffcanvas.MainMenu(fMain);
AppBar.SetButtonAppBarAction(ThemeBtn, SetTheme);
AppBar.SetButtonAppBarAction(MenuBtn, OpenMenu);
end;

procedure TfMain.FormResize(Sender: TObject);
begin
if(fMain.Width < 360)then
fMain.Width := 360;
if(fMain.Width < MinimumWidth)then
fMain.Width := MinimumWidth;

if(fmain.Height < 640)then
fMain.Height := 640;
if(fmain.Height < MinimumHeight)then
fMain.Height := MinimumHeight;

if(fMain.Width <= 768)then
begin
AppBar.ShowTitleBar(false);
TitleBar.Render.Visible := true;
end
else
begin
AppBar.ShowTitleBar(True);
TitleBar.Render.Visible := false;
end;
AppBar.ShowTitleBar(fMain.Width > MobileSizeWidth);
TitleBar.Resize(fMain.Width);
end;

procedure TfMain.OpenMenu(sender: TObject);
Expand Down

0 comments on commit eb6a9a3

Please sign in to comment.