forked from academiadocodigo/TBGWebCharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardStyled.Shape.pas
104 lines (86 loc) · 2.65 KB
/
CardStyled.Shape.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
unit CardStyled.Shape;
interface
uses
Interfaces;
Type
TModelCardStyledShape = class(TInterfacedObject, iModelCardStyledShape)
private
[weak]
FParent : iModelCardStyledGeneric;
FColAuto : boolean;
FShapeClass : iModelCardStyledShapeClasses;
FStyle : iModelGenericStyle<iModelCardStyledShape>;
FText : string;
FIcon : string;
public
constructor Create(Parent : iModelCardStyledGeneric);
destructor Destroy; override;
class function New(Parent : iModelCardStyledGeneric) : iModelCardStyledShape;
function ColAuto(Value : boolean) : iModelCardStyledShape;
function Icon(Value : String) : iModelCardStyledShape;
function ResultClass : String;
function ShapeClass : iModelCardStyledShapeClasses;
function Style : iModelGenericStyle<iModelCardStyledShape>;
function Text(Value : String) : iModelCardStyledShape; overload;
function &End : iModelCardStyledGeneric;
end;
implementation
uses
Injection,
CardStyled.Shape.Classes,
System.SysUtils, Generic.Style;
{ TModelCardStyledShape }
function TModelCardStyledShape.&End: iModelCardStyledGeneric;
begin
Result := FParent;
end;
function TModelCardStyledShape.Icon(Value: String): iModelCardStyledShape;
begin
Result := Self;
FIcon := format('<i class="%s"></i>', [Value]);
end;
function TModelCardStyledShape.ColAuto(Value: boolean): iModelCardStyledShape;
begin
Result := Self;
FColAuto := Value;
end;
constructor TModelCardStyledShape.Create(Parent : iModelCardStyledGeneric);
begin
{$IF RTLVERSION > 27 }
TInjection.Weak(@FParent, Parent);
{$ELSE}
FParent := Parent;
{$IFEND}
FColAuto := True;
FShapeClass := TModelCardStyledShapeClasses.New(Self);
FStyle := TModelGenericStyle<iModelCardStyledShape>.New(Self);
end;
destructor TModelCardStyledShape.Destroy;
begin
inherited;
end;
class function TModelCardStyledShape.New(Parent : iModelCardStyledGeneric) : iModelCardStyledShape;
begin
Result := Self.Create(Parent);
end;
function TModelCardStyledShape.ResultClass: String;
begin
Result := Format('<div %s %s>%s</div>', [FShapeClass.ResultShapeClass,
FStyle.ResultStyle, FIcon]);
if FColAuto then
Result := Format('<div class="col-auto col">%s</div>', [Result]);
end;
function TModelCardStyledShape.ShapeClass: iModelCardStyledShapeClasses;
begin
Result := FShapeClass;
end;
function TModelCardStyledShape.Style: iModelGenericStyle<iModelCardStyledShape>;
begin
Result := FStyle;
end;
function TModelCardStyledShape.Text(Value: String): iModelCardStyledShape;
begin
Result := Self;
FText := Value;
end;
end.