Skip to content

Commit

Permalink
Adicionando cor do fundo e do topo da mensagem
Browse files Browse the repository at this point in the history
  • Loading branch information
Rtrevisan20 committed Jul 29, 2024
1 parent 81eefd3 commit 7a9bfbb
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 88 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Renato Trevisan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 17 additions & 6 deletions Samples/Samples.Principal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +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.Controls,
FMX.Controls.Presentation,
FMX.StdCtrls, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo;
FMX.Dialogs,
FMX.Forms,
FMX.Graphics,
FMX.Memo,
FMX.Memo.Types,
FMX.ScrollBox,
FMX.StdCtrls,
FMX.Types,

System.Classes,
System.SysUtils,
System.Types,
System.UITypes,
System.Variants;

type
TForm1 = class(TForm)
Expand All @@ -34,11 +45,11 @@ TForm1 = class(TForm)

implementation

{$R *.fmx}

uses
HDMessageDlg,
HDMessageDlg.Interfaces;
{$R *.fmx}


procedure TForm1.BtnAttentionClick(Sender: TObject);
var
Expand Down
2 changes: 1 addition & 1 deletion src/FMX/HDMessageDlg.View.FMX.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object HDMessageDlgFMX: THDMessageDlgFMX
Size.Height = 40.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
object ReclblTitle: TRectangle
object RecLblTitle: TRectangle
Align = Client
Fill.Color = xFF086FFB
Size.Width = 580.000000000000000000
Expand Down
69 changes: 36 additions & 33 deletions src/FMX/HDMessageDlg.View.FMX.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ interface
FMX.StdCtrls,
FMX.Types,

HDMessageDlg.Consts,
HDMessageDlg.Interfaces,

System.Classes,
System.SysUtils,
System.Types,
System.UITypes,
System.Variants,

Winapi.Windows;

Expand All @@ -30,7 +27,7 @@ THDMessageDlgFMX = class(TForm)
RecBackGround : TRectangle;
LayoutContainer : TLayout;
LayoutTop : TLayout;
ReclblTitle : TRectangle;
RecLblTitle: TRectangle;
lbl_Title : TLabel;
LayoutContainerMessage: TLayout;
LayoutIMG : TLayout;
Expand All @@ -56,12 +53,14 @@ THDMessageDlgFMX = class(TForm)
procedure btnYesClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FMsgTitle : string;
FMsgQuestion: string;
FMsgBody : string;
FMsgType : TType;
FMsgIcon : string;
FColorSvgIcon: TAlphaColor;
FMsgTitle : string;
FMsgQuestion : string;
FMsgBody : string;
FMsgType : TType;
FMsgIcon : string;
FColorSvgIcon : TAlphaColor;
FMsgResponse : Boolean;
FColorBackuground : TAlphaColor;
procedure SetMsgIcon(const Value: string);
procedure SetMsgBody(const Value: string);
procedure SetMsgQuestion(const Value: string);
Expand All @@ -72,18 +71,22 @@ THDMessageDlgFMX = class(TForm)
procedure SetNo;
procedure SetYes;
public
MsgResponse : Boolean;
published
property MsgTitle : string read FMsgTitle write SetMsgTitle;
property MsgQuestion : string read FMsgQuestion write SetMsgQuestion;
property MsgBody : string read FMsgBody write SetMsgBody;
property MsgIcon : string read FMsgIcon write SetMsgIcon;
property MsgType : TType read FMsgType write SetMsgType;
property ColorSvgIcon: TAlphaColor read FColorSvgIcon write FColorSvgIcon;
property MsgTitle : string read FMsgTitle write SetMsgTitle;
property MsgQuestion : string read FMsgQuestion write SetMsgQuestion;
property MsgBody : string read FMsgBody write SetMsgBody;
property MsgIcon : string read FMsgIcon write SetMsgIcon;
property MsgResponse : Boolean read FMsgResponse write FMsgResponse;
property MsgType : TType read FMsgType write SetMsgType;
property ColorSvgIcon : TAlphaColor read FColorSvgIcon write FColorSvgIcon;
property ColorBackuground : TAlphaColor read FColorBackuground write FColorBackuground;
end;

implementation

uses
HDMessageDlg.Consts;

{$R *.fmx}

procedure THDMessageDlgFMX.btnNoClick(Sender: TObject);
Expand All @@ -99,8 +102,6 @@ procedure THDMessageDlgFMX.btnYesClick(Sender: TObject);
procedure THDMessageDlgFMX.FormCreate(Sender: TObject);
begin
// Set Color
ReclblTitle.Fill.Color := TAlphaColor(FMXColorTop);
RecBackGround.Fill.Color := TAlphaColor(FMXColorBackuground);
BackbtnNo.Fill.Color := TAlphaColor(FMXColorButtonNo);
BackbtnYes.Fill.Color := TAlphaColor(FMXColorButtonYes);
lbl_Title.FontColor := TAlphaColor(FMXLabelTitle);
Expand All @@ -114,30 +115,31 @@ procedure THDMessageDlgFMX.FormKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
if LayoutYes.Visible then
if key = VK_RETURN then
if Key = VK_RETURN then
SetYes;

if LayoutNo.Visible then
if key = VK_ESCAPE then
if Key = VK_ESCAPE then
SetNo;
end;

procedure THDMessageDlgFMX.FormShow(Sender: TObject);
begin
MsgResponse := False;
btnNo.Text := TextButtonNo;
lbl_Title.Text := FMsgTitle;
lbl_Question.Text := FMsgQuestion;
lbl_BodyMessage.Text := FMsgBody;
FMsgResponse := False;
btnNo.Text := TextButtonNo;
lbl_Title.Text := FMsgTitle;
lbl_Question.Text := FMsgQuestion;
lbl_BodyMessage.Text := FMsgBody;
RecBackGround.Fill.Color := TAlphaColor(FColorBackuground);
RecLblTitle.Fill.Color := TAlphaColor(FColorSvgIcon);
PathIconSVG.Fill.Color := FColorSvgIcon;
PathIconSVG.WrapMode := TPathWrapMode.Fit;
PathIconSVG.Data.Data := FMsgIcon;

case FMsgType of
TyOK : TypeOk;
TyQuestion: TypeQuestion;
end;
PathIconSVG.Fill.Color := FColorSvgIcon;
PathIconSVG.WrapMode := TPathWrapMode.Fit;
PathIconSVG.Data.Data := FMsgIcon;
// imgMenssage.Bitmap := imgMenssage.MultiResBitmap.Items[FMsgIcon.ToInteger].Bitmap;
end;

procedure THDMessageDlgFMX.SetMsgIcon(const Value: string);
Expand All @@ -152,7 +154,7 @@ procedure THDMessageDlgFMX.SetMsgBody(const Value: string);

procedure THDMessageDlgFMX.SetNo;
begin
MsgResponse := False;
FMsgResponse := False;
Close;
end;

Expand All @@ -163,7 +165,7 @@ procedure THDMessageDlgFMX.SetMsgQuestion(const Value: string);

procedure THDMessageDlgFMX.SetYes;
begin
MsgResponse := True;
FMsgResponse := True;
Close;
end;

Expand All @@ -187,7 +189,8 @@ procedure THDMessageDlgFMX.TypeQuestion;
begin
LayoutNo.Visible := True;
btnYes.Text := TextButtonYes;
BackbtnYes.Fill.Color := TAlphaColor(FMXColorButtonYes);//($FFEF553B);
btnNo.Text := TextButtonNo;
BackbtnYes.Fill.Color := TAlphaColor(FMXColorButtonYes);
end;

end.
1 change: 0 additions & 1 deletion src/HDMessageDlg.Consts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ interface
FMXColorTop = $FF086FFB;
FMXColorButtonNo = $FF086FFB;
FMXColorButtonYes = $FF0CA950;
FMXColorBackuground = $FFD7D8DB;
FMXLabelTitle = $FFFFFFFF;
FMXLabelQuestion = $FF086FFB;
FMXLabelBodyMessage = $FF555962;
Expand Down
33 changes: 27 additions & 6 deletions src/HDMessageDlg.IconsSVG.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ THDMessageDlgIconsSVG = class
public
class function Icon(ATipo : TIcon) : string;
class function ColorSvgIcon(ATipo : TIcon) : TAlphaColor;
class function ColorBackuground(ATipo : TIcon) : TAlphaColor;
end;

const
Expand Down Expand Up @@ -49,15 +50,35 @@ THDMessageDlgIconsSVG = class
'1.26,0,0,1,4.22,15l1.61-2.42A1,1,0,0,0,6,12V9a6,6,0,0,1,6-6,6.07,6.07,0,0,1,2.31.47A3.91,'+
'3.91,0,0,0,14,5a4,4,0,0,0,4,4v3a1,1,0,0,0,.17.55L19.78,15a1.2,1.2,0,0,1,.22.72A1.3,1.3,0,0,1,18.7,17Z';
//Colors SVG
CColorSvgError = $FFD54309;
CColorSvgAttention = $FFFFBE2E;
CColorSvgLike = $FF00BDE3;
CColorSvgQuestion = $FF9C3D10;
CColorSvgMessage = $FF00BDE3;
CColorSvgDefault = $FF086FFB;
CColorSvgError = $FFD54309;
CColorSvgAttention = $FFFFBE2E;
CColorSvgLike = $FF00BDE3;
CColorSvgQuestion = $FF9C3D10;
CColorSvgMessage = $FF00BDE3;
CColorSvgDefault = $FF086FFB;

CColorBackugroundAttention = $FFFAF3D1;
CColorBackugroundError = $FFF4E3DB;
CColorBackugroundLike = $FFE7F6F8;
CColorBackugroundMessage = $FFE7F6F8;
CColorBackugroundQuestion = $FFF4E3DB;
CColorBackugroundDefault = $FFD7D8DB;


implementation

class function THDMessageDlgIconsSVG.ColorBackuground(ATipo: TIcon): TAlphaColor;
begin
Result := CColorBackugroundDefault;
case ATipo of
TiAttention : Result := CColorBackugroundAttention;
TiError : Result := CColorBackugroundError;
TiLike : Result := CColorBackugroundLike;
TiMessage : Result := CColorBackugroundMessage;
TiQuestion : Result := CColorBackugroundQuestion;
end;
end;

class function THDMessageDlgIconsSVG.ColorSvgIcon(ATipo: TIcon): TAlphaColor;
begin
Result := CColorSvgDefault;
Expand Down
12 changes: 6 additions & 6 deletions src/HDMessageDlg.Interfaces.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ interface

iHDMessageDlg = interface
['{206A0343-2168-418C-9AB6-8A6412F91916}']
function MsgTitle(aValue: String): iHDMessageDlg;
function MsgTitle(aValue: String) : iHDMessageDlg;
function MsgQuestion(aValue: String): iHDMessageDlg;
function MsgBody(aValue: String): iHDMessageDlg;
function MsgIcon(aValue: TIcon): iHDMessageDlg;
function MsgType(aValue: TType): iHDMessageDlg;
function DisplayMessage: iHDMessageDlg;
function DisplayQuestion: Boolean;
function MsgBody(aValue: String) : iHDMessageDlg;
function MsgIcon(aValue: TIcon) : iHDMessageDlg;
function MsgType(aValue: TType) : iHDMessageDlg;
function DisplayMessage : iHDMessageDlg;
function DisplayQuestion : Boolean;
end;

implementation
Expand Down
Loading

0 comments on commit 7a9bfbb

Please sign in to comment.