import { LayoutBase } from '@nativescript/core';
import { Canvas } from '../Canvas';
import { Image } from './Image';
import { Paint } from './Paint';
export class Dom extends LayoutBase {
    constructor() {
        super();
        this._children = [];
        this._canvas = new Canvas();
        this._canvas.on('ready', this._ready.bind(this));
    }
    createNativeView() {
        return new android.widget.LinearLayout(this._context);
    }
    initNativeView() {
        super.initNativeView();
        this._addView(this._canvas);
    }
    _ready(args) {
        this._children.forEach((child) => {
            child.draw();
        });
    }
    _addViewToNativeVisualTree(view, atIndex) {
        if (view === this._canvas) {
            this.nativeView.addView(this._canvas.nativeView);
            return true;
        }
        else if (view instanceof Paint || view instanceof Image) {
            view._addCanvas(this._canvas);
            this._children.push(view);
        }
        return false;
    }
}
//# sourceMappingURL=Dom.js.map