-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDetailView1.pas
122 lines (107 loc) · 3.3 KB
/
DetailView1.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
117
118
119
120
121
122
unit DetailView1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Layouts,
FMX.Objects, FMX.ListBox,
FMX.Menus, FMX.Media,
FMX.Ani, FMX.Gestures, FMX.StdCtrls;
type
TDetailViewForm = class(TForm)
StyleBook2: TStyleBook;
MainLayout: TLayout;
HeaderLayout: TLayout;
TitleLabel1: TLabel;
HorzScrollBox1: THorzScrollBox;
Column1: TLayout;
ArticleHeaderLayout: TLayout;
Illustration1: TImageControl;
Layout4: TLayout;
ItemTitle: TLabel;
ItemSubTitle: TLabel;
Label1: TLabel;
Column2: TLayout;
Label2: TLabel;
Label3: TLabel;
Column3: TLayout;
Label4: TLabel;
Layout2: TLayout;
HeaderButton: TButton;
ToolbarHolder: TLayout;
ToolbarPopup: TPopup;
ToolBar1: TToolBar;
ToolbarApplyButton: TButton;
ToolbarCloseButton: TButton;
ToolbarAddButton: TButton;
ToolbarPopupAnimation: TFloatAnimation;
procedure HeaderButtonClick(Sender: TObject);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo;
var Handled: Boolean);
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
private
FGestureOrigin: TPointF;
FGestureInProgress: Boolean;
{ Private declarations }
procedure ShowToolbar(AShow: Boolean);
{ Private declarations }
public
{ Public declarations }
end;
var
DetailViewForm: TDetailViewForm;
implementation
{$R *.fmx}
procedure TDetailViewForm.HeaderButtonClick(Sender: TObject);
begin
Close;
end;
procedure TDetailViewForm.FormGesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
var
DX, DY : Single;
begin
if EventInfo.GestureID = igiPan then
begin
if (TInteractiveGestureFlag.gfBegin in EventInfo.Flags)
and ((Sender = ToolbarPopup)
or (EventInfo.Location.Y > (ClientHeight - 70))) then
begin
FGestureOrigin := EventInfo.Location;
FGestureInProgress := True;
end;
if FGestureInProgress and (TInteractiveGestureFlag.gfEnd in EventInfo.Flags) then
begin
FGestureInProgress := False;
DX := EventInfo.Location.X - FGestureOrigin.X;
DY := EventInfo.Location.Y - FGestureOrigin.Y;
if (Abs(DY) > Abs(DX)) then
ShowToolbar(DY < 0);
end;
end
end;
procedure TDetailViewForm.FormKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
if Key = vkEscape then
Close;
end;
procedure TDetailViewForm.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
if Button = TMouseButton.mbRight then
ShowToolbar(True)
else
ShowToolbar(False);
end;
procedure TDetailViewForm.ShowToolbar(AShow: Boolean);
begin
ToolbarPopup.Width := ClientWidth;
ToolbarPopup.PlacementRectangle.Rect := TRectF.Create(0, ClientHeight-ToolbarPopup.Height, ClientWidth-1, ClientHeight-1);
ToolbarPopupAnimation.StartValue := ToolbarPopup.Height;
ToolbarPopupAnimation.StopValue := 0;
ToolbarPopup.IsOpen := AShow;
end;
end.