Skip to content

Commit b713962

Browse files
committed
add radio button
1 parent 7579a22 commit b713962

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

src/lib/components/components-map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { NgDial } from './dial';
99
import { NgImage } from './image';
1010
import { NgLineEdit } from './line-edit';
1111
import { NgPlainTextEdit } from './pline-text-edit';
12+
import { NgRadioButton } from './radiobutton';
1213

1314
export type Constructable<T> = new () => T;
1415
export type NgComponentClass = Constructable<NgComponent>;
@@ -30,5 +31,6 @@ export class ComponentsMap {
3031
this.map.set(NgImage.nodeName, NgImage);
3132
this.map.set(NgLineEdit.nodeName, NgLineEdit);
3233
this.map.set(NgPlainTextEdit.nodeName, NgPlainTextEdit);
34+
this.map.set(NgRadioButton.nodeName, NgRadioButton);
3335
}
3436
}

src/lib/components/radiobutton.ts

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

0 commit comments

Comments
 (0)