1 | import { View, CustomLayoutView } from '../core/view';
|
2 | import { booleanConverter, getViewById } from '../core/view-base';
|
3 | import { Property } from '../core/properties';
|
4 | import { accessibilityEnabledProperty } from '../../accessibility/accessibility-properties';
|
5 | export class LayoutBaseCommon extends CustomLayoutView {
|
6 | constructor() {
|
7 | super();
|
8 | this._subViews = new Array();
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 | this.style[accessibilityEnabledProperty.key] = false;
|
15 | }
|
16 | _addChildFromBuilder(name, value) {
|
17 | if (value instanceof View) {
|
18 | this.addChild(value);
|
19 | }
|
20 | }
|
21 | getChildrenCount() {
|
22 | return this._subViews.length;
|
23 | }
|
24 |
|
25 | get _childrenCount() {
|
26 | return this._subViews.length;
|
27 | }
|
28 | getChildAt(index) {
|
29 | return this._subViews[index];
|
30 | }
|
31 | getChildIndex(child) {
|
32 | return this._subViews.indexOf(child);
|
33 | }
|
34 | getChildById(id) {
|
35 | return getViewById(this, id);
|
36 | }
|
37 | _registerLayoutChild(child) {
|
38 |
|
39 | }
|
40 | _unregisterLayoutChild(child) {
|
41 |
|
42 | }
|
43 | addChild(child) {
|
44 |
|
45 | this._subViews.push(child);
|
46 | this._addView(child);
|
47 | this._registerLayoutChild(child);
|
48 | }
|
49 | insertChild(child, atIndex) {
|
50 | this._subViews.splice(atIndex, 0, child);
|
51 | this._addView(child, atIndex);
|
52 | this._registerLayoutChild(child);
|
53 | }
|
54 | removeChild(child) {
|
55 | this._removeView(child);
|
56 |
|
57 | const index = this._subViews.indexOf(child);
|
58 | this._subViews.splice(index, 1);
|
59 | this._unregisterLayoutChild(child);
|
60 | }
|
61 | removeChildren() {
|
62 | while (this.getChildrenCount() !== 0) {
|
63 | this.removeChild(this._subViews[this.getChildrenCount() - 1]);
|
64 | }
|
65 | }
|
66 | get padding() {
|
67 | return this.style.padding;
|
68 | }
|
69 | set padding(value) {
|
70 | this.style.padding = value;
|
71 | }
|
72 | get paddingTop() {
|
73 | return this.style.paddingTop;
|
74 | }
|
75 | set paddingTop(value) {
|
76 | this.style.paddingTop = value;
|
77 | }
|
78 | get paddingRight() {
|
79 | return this.style.paddingRight;
|
80 | }
|
81 | set paddingRight(value) {
|
82 | this.style.paddingRight = value;
|
83 | }
|
84 | get paddingBottom() {
|
85 | return this.style.paddingBottom;
|
86 | }
|
87 | set paddingBottom(value) {
|
88 | this.style.paddingBottom = value;
|
89 | }
|
90 | get paddingLeft() {
|
91 | return this.style.paddingLeft;
|
92 | }
|
93 | set paddingLeft(value) {
|
94 | this.style.paddingLeft = value;
|
95 | }
|
96 | _childIndexToNativeChildIndex(index) {
|
97 | if (index === undefined) {
|
98 | return undefined;
|
99 | }
|
100 | let result = 0;
|
101 | for (let i = 0; i < index && i < this._subViews.length; i++) {
|
102 | result += this._subViews[i]._getNativeViewsCount();
|
103 | }
|
104 | return result;
|
105 | }
|
106 | eachChildView(callback) {
|
107 | for (let i = 0, length = this._subViews.length; i < length; i++) {
|
108 | const retVal = callback(this._subViews[i]);
|
109 | if (retVal === false) {
|
110 | break;
|
111 | }
|
112 | }
|
113 | }
|
114 | eachLayoutChild(callback) {
|
115 | let lastChild = null;
|
116 | this.eachChildView((cv) => {
|
117 | cv._eachLayoutView((lv) => {
|
118 | if (lastChild && !lastChild.isCollapsed) {
|
119 | callback(lastChild, false);
|
120 | }
|
121 | lastChild = lv;
|
122 | });
|
123 | return true;
|
124 | });
|
125 | if (lastChild && !lastChild.isCollapsed) {
|
126 | callback(lastChild, true);
|
127 | }
|
128 | }
|
129 | }
|
130 | export const clipToBoundsProperty = new Property({
|
131 | name: 'clipToBounds',
|
132 | defaultValue: true,
|
133 | valueConverter: booleanConverter,
|
134 | });
|
135 | clipToBoundsProperty.register(LayoutBaseCommon);
|
136 | export const isPassThroughParentEnabledProperty = new Property({
|
137 | name: 'isPassThroughParentEnabled',
|
138 | defaultValue: false,
|
139 | valueConverter: booleanConverter,
|
140 | });
|
141 | isPassThroughParentEnabledProperty.register(LayoutBaseCommon);
|
142 |
|
\ | No newline at end of file |