Skip to content

Commit f752fa9

Browse files
committed
Add progress bar
1 parent b713962 commit f752fa9

4 files changed

Lines changed: 71 additions & 1 deletion

File tree

src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { AspectRatioMode } from '@nodegui/nodegui';
2121
[placeholderText]="'Insert your name'"
2222
(textChanged)="textChanged($event)"
2323
></linedit>
24+
<progressbar [value]="40" [minimum]="0" [maximum]="100"></progressbar>
2425
</view>
2526
</window>
2627
`

src/lib/components/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface NgComponent {
1111

1212
setStyle(style: string, value: any, flags?: RendererStyleFlags2): void;
1313

14-
setValue(value: string): void;
14+
setValue(value: any): void;
1515

1616
removeAttribute(name: string, namespace?: string | null): void;
1717

src/lib/components/components-map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { NgImage } from './image';
1010
import { NgLineEdit } from './line-edit';
1111
import { NgPlainTextEdit } from './pline-text-edit';
1212
import { NgRadioButton } from './radiobutton';
13+
import { NgProgressBar } from './progress-bar';
1314

1415
export type Constructable<T> = new () => T;
1516
export type NgComponentClass = Constructable<NgComponent>;
@@ -32,5 +33,6 @@ export class ComponentsMap {
3233
this.map.set(NgLineEdit.nodeName, NgLineEdit);
3334
this.map.set(NgPlainTextEdit.nodeName, NgPlainTextEdit);
3435
this.map.set(NgRadioButton.nodeName, NgRadioButton);
36+
this.map.set(NgProgressBar.nodeName, NgProgressBar);
3537
}
3638
}

src/lib/components/progress-bar.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { QProgressBar } from '@nodegui/nodegui';
2+
import { NgComponent } from './component';
3+
import { RendererStyleFlags2 } from '@angular/core';
4+
5+
export class NgProgressBar extends QProgressBar implements NgComponent {
6+
public static nodeName = 'progressbar';
7+
public parent: any;
8+
9+
public appendChild(newChild: any): void {
10+
console.warn('progressbar do not have append child');
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: any): void {
22+
switch (name) {
23+
case 'value':
24+
this.setValue(value);
25+
break;
26+
case 'minimum':
27+
this.setMinimum(value);
28+
break;
29+
case 'maximum':
30+
this.setMaximum(value);
31+
break;
32+
case 'orientation':
33+
this.setOrientation(value);
34+
break;
35+
case 'enabled':
36+
this.setEnabled(value);
37+
break;
38+
default:
39+
break;
40+
}
41+
}
42+
43+
public setStyle(
44+
style: string,
45+
value: any,
46+
flags?: RendererStyleFlags2
47+
): void {
48+
this.setInlineStyle(`${style}:${value}`);
49+
}
50+
51+
public setValue(value: number): void {
52+
super.setValue(value);
53+
}
54+
55+
removeAttribute(name: string, namespace?: string): void {
56+
throw new Error('Method not implemented.');
57+
}
58+
removeChild(oldChild: any): void {
59+
throw new Error('Method not implemented.');
60+
}
61+
removeClass(name: string): void {
62+
throw new Error('Method not implemented.');
63+
}
64+
removeStyle(style: string, flags?: RendererStyleFlags2): void {
65+
throw new Error('Method not implemented.');
66+
}
67+
}

0 commit comments

Comments
 (0)