Skip to content

Commit b10562a

Browse files
committed
Add spinbox
1 parent 08a69f7 commit b10562a

3 files changed

Lines changed: 84 additions & 0 deletions

File tree

src/app/app.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ import { AspectRatioMode } from '@nodegui/nodegui';
2222
(textChanged)="textChanged($event)"
2323
></linedit>
2424
<progressbar [value]="40" [minimum]="0" [maximum]="100"></progressbar>
25+
<spinbox
26+
[prefix]="'aa'"
27+
[suffix]="'bb'"
28+
[singleStep]="10"
29+
[range]="{ minimum: 0, maximum: 50 }"
30+
[value]="20"
31+
></spinbox>
2532
</view>
2633
</window>
2734
`

src/lib/components/components-map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { NgPlainTextEdit } from './pline-text-edit';
1212
import { NgRadioButton } from './radiobutton';
1313
import { NgProgressBar } from './progress-bar';
1414
import { NgScrollArea } from './scroll-area';
15+
import { NgSpinnBox } from './spin-box';
1516

1617
export type Constructable<T> = new () => T;
1718
export type NgComponentClass = Constructable<NgComponent>;
@@ -36,5 +37,6 @@ export class ComponentsMap {
3637
this.map.set(NgRadioButton.nodeName, NgRadioButton);
3738
this.map.set(NgProgressBar.nodeName, NgProgressBar);
3839
this.map.set(NgScrollArea.nodeName, NgScrollArea);
40+
this.map.set(NgSpinnBox.nodeName, NgSpinnBox);
3941
}
4042
}

src/lib/components/spin-box.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { QSpinBox } from '@nodegui/nodegui';
2+
import { NgComponent } from './component';
3+
import { RendererStyleFlags2 } from '@angular/core';
4+
5+
interface Range {
6+
minimum: number;
7+
maximum: number;
8+
}
9+
10+
export class NgSpinnBox extends QSpinBox implements NgComponent {
11+
public static nodeName = 'spinbox';
12+
public parent: any;
13+
14+
public appendChild(newChild: any): void {
15+
throw new Error('Method not implemented.');
16+
}
17+
18+
public insertBefore(newChild: any, refChild: any) {}
19+
20+
public setNgAttribute(
21+
name: string,
22+
value: string,
23+
namespace?: string | null
24+
): void {}
25+
26+
public setProperty(
27+
name: string,
28+
value: boolean | string | Range | number
29+
): void {
30+
switch (name) {
31+
case 'prefix':
32+
this.setPrefix(value as string);
33+
break;
34+
case 'suffix':
35+
this.setSuffix(value as string);
36+
break;
37+
case 'singleStep':
38+
this.setSingleStep(value as number);
39+
break;
40+
case 'range':
41+
this.setRange((value as Range).minimum, (value as Range).maximum);
42+
break;
43+
case 'value':
44+
this.setValue(value as number);
45+
break;
46+
default:
47+
break;
48+
}
49+
}
50+
51+
public setStyle(
52+
style: string,
53+
value: any,
54+
flags?: RendererStyleFlags2
55+
): void {
56+
this.setInlineStyle(`${style}:${value}`);
57+
}
58+
59+
public setValue(value: number): void {
60+
super.setValue(value);
61+
}
62+
63+
removeAttribute(name: string, namespace?: string): void {
64+
throw new Error('Method not implemented.');
65+
}
66+
removeChild(oldChild: any): void {
67+
throw new Error('Method not implemented.');
68+
}
69+
removeClass(name: string): void {
70+
throw new Error('Method not implemented.');
71+
}
72+
removeStyle(style: string, flags?: RendererStyleFlags2): void {
73+
throw new Error('Method not implemented.');
74+
}
75+
}

0 commit comments

Comments
 (0)