|
| 1 | +import { QWidget, FlexLayout } from '@nodegui/nodegui'; |
| 2 | +import { NgComponent } from './component'; |
| 3 | +import { RendererStyleFlags2 } from '@angular/core'; |
| 4 | + |
| 5 | +export class NgView extends QWidget implements NgComponent { |
| 6 | + public static nodeName = 'view'; |
| 7 | + public parent: any; |
| 8 | + |
| 9 | + public appendChild(newChild: any): void { |
| 10 | + if (!newChild) { |
| 11 | + return; |
| 12 | + } |
| 13 | + if (!this.layout) { |
| 14 | + const flexLayout = new FlexLayout(); |
| 15 | + flexLayout.setFlexNode(this.getFlexNode()); |
| 16 | + this.setLayout(flexLayout); |
| 17 | + this.layout = flexLayout; |
| 18 | + } |
| 19 | + |
| 20 | + this.layout.addWidget(newChild); |
| 21 | + } |
| 22 | + |
| 23 | + public insertBefore(newChild: any, refChild: any) { |
| 24 | + if (!this.layout) { |
| 25 | + console.warn('parent has no layout to insert child before another child'); |
| 26 | + return; |
| 27 | + } |
| 28 | + (this.layout as FlexLayout).insertChildBefore(newChild, this); |
| 29 | + } |
| 30 | + |
| 31 | + public setNgAttribute( |
| 32 | + name: string, |
| 33 | + value: string, |
| 34 | + namespace?: string | null |
| 35 | + ): void {} |
| 36 | + |
| 37 | + public setProperty(name: string, value: any): void { |
| 38 | + throw new Error('Method not implemented.'); |
| 39 | + } |
| 40 | + |
| 41 | + public setStyle( |
| 42 | + style: string, |
| 43 | + value: any, |
| 44 | + flags?: RendererStyleFlags2 |
| 45 | + ): void { |
| 46 | + this.setInlineStyle(`${style}:${value}`); |
| 47 | + } |
| 48 | + |
| 49 | + public setValue(value: string): void { |
| 50 | + throw new Error('Method not implemented.'); |
| 51 | + } |
| 52 | + |
| 53 | + removeAttribute(name: string, namespace?: string): void { |
| 54 | + throw new Error('Method not implemented.'); |
| 55 | + } |
| 56 | + removeChild(oldChild: any): void { |
| 57 | + throw new Error('Method not implemented.'); |
| 58 | + } |
| 59 | + removeClass(name: string): void { |
| 60 | + throw new Error('Method not implemented.'); |
| 61 | + } |
| 62 | + removeStyle(style: string, flags?: RendererStyleFlags2): void { |
| 63 | + throw new Error('Method not implemented.'); |
| 64 | + } |
| 65 | +} |
0 commit comments