|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
6
|
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Request\ScrollDirection; |
|
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\ActionableComponentTrait; |
|
9
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits\MultiChildComponentTrait; |
|
10
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
11
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\FlexAlignItems; |
|
12
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Snap; |
|
13
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
14
|
|
|
|
|
15
|
|
|
class FlexSequenceComponent extends APLBaseComponent implements \JsonSerializable |
|
16
|
|
|
{ |
|
17
|
|
|
use ActionableComponentTrait; |
|
18
|
|
|
use MultiChildComponentTrait; |
|
19
|
|
|
|
|
20
|
|
|
public const TYPE = APLComponentType::FLEX_SEQUENCE; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param FlexAlignItems|null $alignItems Alignment for children in the cross-axis |
|
24
|
|
|
* @param bool $numbered When true, assign ordinal numbers to the FlexSequence children |
|
25
|
|
|
* @param AbstractStandardCommand[]|null $onScroll Commands to run when scrolling |
|
26
|
|
|
* @param ScrollDirection|null $scrollDirection The direction to scroll this FlexSequence |
|
27
|
|
|
* @param Snap|null $snap The alignment that the child components snap to when scrolling stops |
|
28
|
|
|
*/ |
|
29
|
12 |
|
public function __construct( |
|
30
|
|
|
public ?FlexAlignItems $alignItems = null, |
|
31
|
|
|
public bool $numbered = false, |
|
32
|
|
|
public ?array $onScroll = null, |
|
33
|
|
|
public ?ScrollDirection $scrollDirection = null, |
|
34
|
|
|
public ?Snap $snap = null, |
|
35
|
|
|
) { |
|
36
|
12 |
|
parent::__construct(self::TYPE); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
6 |
|
public function jsonSerialize(): array |
|
40
|
|
|
{ |
|
41
|
6 |
|
$data = array_merge( |
|
42
|
6 |
|
parent::jsonSerialize(), |
|
43
|
6 |
|
$this->serializeActionableProperties(), |
|
44
|
6 |
|
$this->serializeMultiChildProperties() |
|
45
|
6 |
|
); |
|
46
|
|
|
|
|
47
|
6 |
|
if ($this->alignItems !== null) { |
|
48
|
1 |
|
$data['alignItems'] = $this->alignItems->value; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
6 |
|
if ($this->numbered) { |
|
52
|
2 |
|
$data['numbered'] = $this->numbered; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
6 |
|
if ($this->onScroll !== null && !empty($this->onScroll)) { |
|
56
|
2 |
|
$data['onScroll'] = $this->onScroll; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
6 |
|
if ($this->scrollDirection !== null) { |
|
60
|
1 |
|
$data['scrollDirection'] = $this->scrollDirection->value; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
6 |
|
if ($this->snap !== null) { |
|
64
|
1 |
|
$data['snap'] = $this->snap->value; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
6 |
|
return $data; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|