|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
6
|
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Gradient; |
|
9
|
|
|
|
|
10
|
|
|
class FrameComponent extends APLBaseComponent implements \JsonSerializable |
|
11
|
|
|
{ |
|
12
|
|
|
public const TYPE = APLComponentType::FRAME; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @param Gradient|string|null $background Background fill that allows either a color or gradient |
|
16
|
|
|
* @param string|null $backgroundColor Background color (ignored if background is provided) |
|
17
|
|
|
* @param string|null $borderBottomLeftRadius Radius of the bottom-left corner |
|
18
|
|
|
* @param string|null $borderBottomRightRadius Radius of the bottom-right corner |
|
19
|
|
|
* @param string|null $borderColor Color of the border |
|
20
|
|
|
* @param string $borderRadius Corner radius for rounded-rectangle variant |
|
21
|
|
|
* @param string|null $borderStrokeWidth Width of the border stroke |
|
22
|
|
|
* @param string|null $borderTopLeftRadius Radius of the top-left corner |
|
23
|
|
|
* @param string|null $borderTopRightRadius Radius of the top-right corner |
|
24
|
|
|
* @param string $borderWidth Width of the border |
|
25
|
|
|
* @param APLBaseComponent|null $item Single child component to display inside the Frame |
|
26
|
|
|
* @param APLBaseComponent[]|null $items Array of child components to display inside the Frame |
|
27
|
|
|
*/ |
|
28
|
10 |
|
public function __construct( |
|
29
|
|
|
public Gradient|string|null $background = null, |
|
30
|
|
|
public ?string $backgroundColor = null, |
|
31
|
|
|
public ?string $borderBottomLeftRadius = null, |
|
32
|
|
|
public ?string $borderBottomRightRadius = null, |
|
33
|
|
|
public ?string $borderColor = null, |
|
34
|
|
|
public string $borderRadius = '0', |
|
35
|
|
|
public ?string $borderStrokeWidth = null, |
|
36
|
|
|
public ?string $borderTopLeftRadius = null, |
|
37
|
|
|
public ?string $borderTopRightRadius = null, |
|
38
|
|
|
public string $borderWidth = '0', |
|
39
|
|
|
public ?APLBaseComponent $item = null, |
|
40
|
|
|
public ?array $items = null, |
|
41
|
|
|
) { |
|
42
|
10 |
|
parent::__construct(self::TYPE); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
5 |
|
public function jsonSerialize(): array |
|
46
|
|
|
{ |
|
47
|
5 |
|
$data = parent::jsonSerialize(); |
|
48
|
|
|
|
|
49
|
5 |
|
if ($this->background !== null) { |
|
50
|
1 |
|
$data['background'] = $this->background; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
5 |
|
if ($this->backgroundColor !== null) { |
|
54
|
1 |
|
$data['backgroundColor'] = $this->backgroundColor; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
5 |
|
if ($this->borderBottomLeftRadius !== null) { |
|
58
|
1 |
|
$data['borderBottomLeftRadius'] = $this->borderBottomLeftRadius; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
5 |
|
if ($this->borderBottomRightRadius !== null) { |
|
62
|
|
|
$data['borderBottomRightRadius'] = $this->borderBottomRightRadius; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
5 |
|
if ($this->borderColor !== null) { |
|
66
|
1 |
|
$data['borderColor'] = $this->borderColor; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
5 |
|
if ($this->borderRadius !== '0') { |
|
70
|
2 |
|
$data['borderRadius'] = $this->borderRadius; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
5 |
|
if ($this->borderStrokeWidth !== null) { |
|
74
|
1 |
|
$data['borderStrokeWidth'] = $this->borderStrokeWidth; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
5 |
|
if ($this->borderTopLeftRadius !== null) { |
|
78
|
|
|
$data['borderTopLeftRadius'] = $this->borderTopLeftRadius; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
5 |
|
if ($this->borderTopRightRadius !== null) { |
|
82
|
1 |
|
$data['borderTopRightRadius'] = $this->borderTopRightRadius; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
5 |
|
if ($this->borderWidth !== '0') { |
|
86
|
2 |
|
$data['borderWidth'] = $this->borderWidth; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
5 |
|
if ($this->item !== null) { |
|
90
|
1 |
|
$data['item'] = $this->item; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
5 |
|
if ($this->items !== null && !empty($this->items)) { |
|
94
|
1 |
|
$data['items'] = $this->items; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
5 |
|
return $data; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|