|
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\StandardCommand\AbstractStandardCommand; |
|
9
|
|
|
|
|
10
|
|
|
class ScrollViewComponent extends ActionableComponent implements \JsonSerializable |
|
11
|
|
|
{ |
|
12
|
|
|
public const TYPE = APLComponentType::SCROLL_VIEW; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @param APLBaseComponent|null $item Single component displayed in the ScrollView |
|
16
|
|
|
* @param APLBaseComponent[]|null $items Array of components displayed in the ScrollView |
|
17
|
|
|
* @param string[]|null $preserve Properties to save when reinflating the document |
|
18
|
|
|
* @param AbstractStandardCommand[]|null $onScroll Commands to run during scrolling |
|
19
|
|
|
*/ |
|
20
|
9 |
|
public function __construct( |
|
21
|
|
|
public ?APLBaseComponent $item = null, |
|
22
|
|
|
public ?array $items = null, |
|
23
|
|
|
?array $preserve = null, |
|
24
|
|
|
public ?array $onScroll = null, |
|
25
|
|
|
) { |
|
26
|
9 |
|
parent::__construct(type: self::TYPE, preserve: $preserve); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
5 |
|
public function jsonSerialize(): array |
|
30
|
|
|
{ |
|
31
|
5 |
|
$data = parent::jsonSerialize(); |
|
32
|
|
|
|
|
33
|
5 |
|
if ($this->item !== null) { |
|
34
|
2 |
|
$data['item'] = $this->item; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
5 |
|
if ($this->items !== null && !empty($this->items)) { |
|
38
|
2 |
|
$data['items'] = $this->items; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
5 |
|
if ($this->preserve !== null && !empty($this->preserve)) { |
|
42
|
1 |
|
$data['preserve'] = $this->preserve; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
5 |
|
if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
46
|
1 |
|
$data['onScroll'] = $this->onScroll; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
5 |
|
return $data; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|