MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / LayoutBaseCommon

Class LayoutBaseCommon

packages/core/ui/layouts/layout-base-common.ts:7–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import { Property } from '../core/properties';
6
7export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefinition, AddChildFromBuilder {
8 private _subViews = new Array<View>();
9
10 public _addChildFromBuilder(name: string, value: any) {
11 if (value instanceof View) {
12 this.addChild(value);
13 }
14 }
15
16 getChildrenCount(): number {
17 return this._subViews.length;
18 }
19
20 // overrides the base property.
21 get _childrenCount(): number {
22 return this._subViews.length;
23 }
24
25 getChildAt(index: number): View {
26 return this._subViews[index];
27 }
28
29 getChildIndex(child: View): number {
30 return this._subViews.indexOf(child);
31 }
32
33 public getChildById(id: string) {
34 return getViewById(this, id);
35 }
36
37 public _registerLayoutChild(child: View) {
38 //Overridden
39 }
40
41 public _unregisterLayoutChild(child: View) {
42 //Overridden
43 }
44
45 public addChild(child: View): void {
46 // TODO: Do we need this method since we have the core logic in the View implementation?
47 this._subViews.push(child);
48 this._addView(child);
49 this._registerLayoutChild(child);
50 }
51
52 public insertChild(child: View, atIndex: number): boolean {
53 if (atIndex > -1) {
54 this._subViews.splice(atIndex, 0, child);
55 this._addView(child, atIndex);
56 this._registerLayoutChild(child);
57 return true;
58 }
59 return false;
60 }
61
62 public removeChild(child: View): void {
63 this._removeView(child);
64

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected