Skip to content

Commit 31c18bb

Browse files
committed
Add line edit
1 parent a63618f commit 31c18bb

3 files changed

Lines changed: 78 additions & 1 deletion

File tree

src/app/app.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
import { Component } from '@angular/core';
2+
import { AspectRatioMode } from '@nodegui/nodegui';
23

34
@Component({
45
selector: 'app-root',
56
template: `
67
<window title="Angular app in window!">
78
<view>
8-
<image [src]="'C:/temp/iw.jpg'"></image>
9+
<image
10+
[src]="'C:/temp/angular.png'"
11+
[aspectRatioMode]="aspectRatioMode"
12+
></image>
913
<text [style.font-size.px]="45">Hello, {{ name }}</text>
1014
<checkbox [checked]="true"></checkbox>
1115
<checkbox [checked]="true" [enabled]="false"></checkbox>
1216
<button [style.background-color]="'green'" (clicked)="setName()">
1317
Green button
1418
</button>
19+
<linedit
20+
[text]="name"
21+
[placeholderText]="'Insert your name'"
22+
(textChanged)="textChanged($event)"
23+
></linedit>
1524
</view>
1625
</window>
1726
`
1827
})
1928
export class AppComponent {
2029
public name = 'World!';
30+
public aspectRatioMode = AspectRatioMode.KeepAspectRatio;
2131

2232
setName() {
2333
this.name = 'irustm';
2434
}
35+
36+
textChanged(val: string) {
37+
this.name = val;
38+
}
2539
}

src/lib/components/components-map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { NgView } from './view';
77
import { NgCheckbox } from './checkbox';
88
import { NgDial } from './dial';
99
import { NgImage } from './image';
10+
import { NgLineEdit } from './line-edit';
1011

1112
export type Constructable<T> = new () => T;
1213
export type NgComponentClass = Constructable<NgComponent>;
@@ -26,5 +27,6 @@ export class ComponentsMap {
2627
this.map.set(NgCheckbox.nodeName, NgCheckbox);
2728
this.map.set(NgDial.nodeName, NgDial);
2829
this.map.set(NgImage.nodeName, NgImage);
30+
this.map.set(NgLineEdit.nodeName, NgLineEdit);
2931
}
3032
}

src/lib/components/line-edit.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { QLineEdit } from '@nodegui/nodegui';
2+
import { NgComponent } from './component';
3+
import { RendererStyleFlags2 } from '@angular/core';
4+
5+
export class NgLineEdit extends QLineEdit implements NgComponent {
6+
public static nodeName = 'linedit';
7+
public parent: any;
8+
9+
public appendChild(newChild: any): void {
10+
throw new Error('Method not implemented.');
11+
}
12+
13+
public insertBefore(newChild: any, refChild: any) {}
14+
15+
public setNgAttribute(
16+
name: string,
17+
value: string,
18+
namespace?: string | null
19+
): void {}
20+
21+
public setProperty(name: string, value: boolean | string): void {
22+
switch (name) {
23+
case 'text':
24+
value ? this.setText(value as string) : this.clear();
25+
break;
26+
case 'placeholderText':
27+
this.setPlaceholderText(value as string);
28+
break;
29+
case 'readOnly':
30+
this.setReadOnly(value as boolean);
31+
break;
32+
default:
33+
break;
34+
}
35+
}
36+
37+
public setStyle(
38+
style: string,
39+
value: any,
40+
flags?: RendererStyleFlags2
41+
): void {
42+
this.setInlineStyle(`${style}:${value}`);
43+
}
44+
45+
public setValue(value: string): void {
46+
this.setText(value);
47+
}
48+
49+
removeAttribute(name: string, namespace?: string): void {
50+
throw new Error('Method not implemented.');
51+
}
52+
removeChild(oldChild: any): void {
53+
throw new Error('Method not implemented.');
54+
}
55+
removeClass(name: string): void {
56+
throw new Error('Method not implemented.');
57+
}
58+
removeStyle(style: string, flags?: RendererStyleFlags2): void {
59+
throw new Error('Method not implemented.');
60+
}
61+
}

0 commit comments

Comments
 (0)