-
Notifications
You must be signed in to change notification settings - Fork 2
/
View.ContactsList.Item.pas
116 lines (97 loc) · 3.32 KB
/
View.ContactsList.Item.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//---------------------------------------------------------------------------
// This software is Copyright (c) 2021 Embarcadero Technologies, Inc.
// You may only use this software if you are an authorized licensee
// of an Embarcadero developer tools product.
// This software is considered a Redistributable as defined under
// the software license agreement that comes with the Embarcadero Products
// and is subject to that software license agreement.
//---------------------------------------------------------------------------
unit View.ContactsList.Item;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
FMX.Objects, FMX.Layouts, FMX.Controls.Presentation, FMX.AddressBook,
Model.Types, StrUtils, FMX.Effects, Model.Constants, Model.Utils;
type
// Address book contact item representation frame.
TContactListItemFrame = class(TFrame)
ContactInfoPanel: TGridPanelLayout;
imgUserpic: TImage;
lblPhone: TLabel;
lblUsername: TLabel;
UserInfoPanel: TGridPanelLayout;
imgEditContact: TPath;
BgRect: TRectangle;
GlowEffect: TGlowEffect;
UserpicGlowEffect: TGlowEffect;
private
FContact: TAddressBookContact;
function GetContactName: string;
procedure SetContactName(const AName: string);
function GetPhone: string;
procedure SetPhone(const APhone: string);
function GetUserPic: TBitmap;
procedure SetUserPic(const AUserPic: TBitmap);
procedure DoOnApplyStyleLookupItem(Sender: TObject);
public
constructor Create(AContact: TAddressBookContact); reintroduce;
property ContactName: string read GetContactName write SetContactName;
property Phone: string read GetPhone write SetPhone;
property UserPic: TBitmap read GetUserPic write SetUserPic;
end;
implementation
{$R *.fmx}
{ TContactListItemFrame }
constructor TContactListItemFrame.Create(AContact: TAddressBookContact);
begin
inherited Create(nil);
if Assigned(AContact) then
begin
lblUsername.OnApplyStyleLookup := DoOnApplyStyleLookupItem;
FContact := AContact;
ContactName := Concat(FContact.FirstName, sSpaceChar, FContact.LastName);
UserPic.Assign(FContact.PhotoThumbnail);
imgUserpic.MakeCircleMask;
if FContact.Phones.Count > 0 then
Phone := FContact.Phones.Items[0].Number
else
Phone := sNotDefined;
lblUsername.ApplyStyleLookup;
end;
end;
procedure TContactListItemFrame.DoOnApplyStyleLookupItem(Sender: TObject);
begin
BgRect.Stroke.Color := lblUsername.GetStyledColor;
end;
function TContactListItemFrame.GetContactName: string;
begin
Result := lblUsername.Text;
end;
function TContactListItemFrame.GetPhone: string;
begin
Result := lblPhone.Text;
end;
function TContactListItemFrame.GetUserPic: TBitmap;
begin
Result := imgUserpic.Bitmap;
end;
procedure TContactListItemFrame.SetContactName(const AName: string);
begin
lblUsername.Text := AName;
end;
procedure TContactListItemFrame.SetPhone(const APhone: string);
begin
lblPhone.Text := APhone;
end;
procedure TContactListItemFrame.SetUserPic(const AUserPic: TBitmap);
begin
imgUserpic.Bitmap.Assign(AUserPic);
end;
initialization
// Register frame
RegisterClass(TContactListItemFrame);
finalization
// Unregister frame
UnRegisterClass(TContactListItemFrame);
end.