Skip to content

Commit 912869e

Browse files
authored
Merge pull request #32 from nodegui/feature/add-scrollarea
Feature/add scrollarea
2 parents a150d4c + 957afa1 commit 912869e

33 files changed

+1017
-671
lines changed

package-lock.json

+70-44
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodegui/react-nodegui",
3-
"version": "0.1.5",
3+
"version": "0.1.9",
44
"description": "React Native for building cross platform desktop applications",
55
"main": "dist/index.js",
66
"files": [
@@ -22,7 +22,7 @@
2222
"react": "16.9.0"
2323
},
2424
"devDependencies": {
25-
"@nodegui/nodegui": "^0.1.7",
25+
"@nodegui/nodegui": "^0.1.9",
2626
"@types/node": "^12.0.10",
2727
"@types/react-reconciler": "^0.18.0",
2828
"prettier": "^1.18.2",

src/components/Button/RNButton.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { QIcon, QPushButton, NodeWidget } from "@nodegui/nodegui";
2+
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
5+
6+
export class RNButton extends QPushButton implements RNWidget {
7+
appendInitialChild(child: NodeWidget): void {
8+
throwUnsupported(this);
9+
}
10+
appendChild(child: NodeWidget): void {
11+
throwUnsupported(this);
12+
}
13+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
14+
throwUnsupported(this);
15+
}
16+
removeChild(child: NodeWidget): void {
17+
throwUnsupported(this);
18+
}
19+
static tagName = "button";
20+
}
21+
export interface ButtonProps extends ViewProps {
22+
text?: string;
23+
flat?: boolean;
24+
icon?: QIcon;
25+
}
26+
27+
export const setProps = (
28+
widget: RNButton,
29+
newProps: ButtonProps,
30+
oldProps: ButtonProps
31+
) => {
32+
const setter: ButtonProps = {
33+
set text(buttonText: string) {
34+
widget.setText(buttonText);
35+
},
36+
set flat(isFlat: boolean) {
37+
widget.setFlat(isFlat);
38+
},
39+
set icon(icon: QIcon) {
40+
widget.setIcon(icon);
41+
}
42+
};
43+
Object.assign(setter, newProps);
44+
setViewProps(widget, newProps, oldProps);
45+
};

src/components/Button/index.ts

+5-30
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,10 @@
1-
import { QPushButton, QIcon, NodeWidget } from "@nodegui/nodegui";
1+
import { NodeWidget } from "@nodegui/nodegui";
22
import { Fiber } from "react-reconciler";
3-
import { ViewProps, setProps as setViewProps } from "../View";
43
import { registerComponent, ComponentConfig } from "../config";
5-
interface ButtonProps extends ViewProps {
6-
text?: string;
7-
flat?: boolean;
8-
icon?: QIcon;
9-
}
10-
11-
const setProps = (
12-
widget: QPushButton,
13-
newProps: ButtonProps,
14-
oldProps: ButtonProps
15-
) => {
16-
const setter: ButtonProps = {
17-
set text(buttonText: string) {
18-
widget.setText(buttonText);
19-
},
20-
set flat(isFlat: boolean) {
21-
widget.setFlat(isFlat);
22-
},
23-
set icon(icon: QIcon) {
24-
widget.setIcon(icon);
25-
}
26-
};
27-
Object.assign(setter, newProps);
28-
setViewProps(widget, newProps, oldProps);
29-
};
4+
import { setProps, ButtonProps, RNButton } from "./RNButton";
305

316
class ButtonConfig extends ComponentConfig {
32-
id = "button";
7+
tagName = RNButton.tagName;
338
shouldSetTextContent(nextProps: object): boolean {
349
return true;
3510
}
@@ -39,7 +14,7 @@ class ButtonConfig extends ComponentConfig {
3914
context: any,
4015
workInProgress: Fiber
4116
): NodeWidget {
42-
const widget = new QPushButton();
17+
const widget = new RNButton();
4318
setProps(widget, newProps, {});
4419
return widget;
4520
}
@@ -50,7 +25,7 @@ class ButtonConfig extends ComponentConfig {
5025
newProps: object,
5126
finishedWork: Fiber
5227
): void {
53-
setProps(instance as QPushButton, newProps, oldProps);
28+
setProps(instance as RNButton, newProps, oldProps);
5429
}
5530
}
5631

src/components/CheckBox/RNCheckBox.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ViewProps, setProps as setViewProps } from "../View/RNView";
2+
import { QCheckBox, NodeWidget } from "@nodegui/nodegui";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
5+
6+
export class RNCheckBox extends QCheckBox implements RNWidget {
7+
appendInitialChild(child: NodeWidget): void {
8+
throwUnsupported(this);
9+
}
10+
appendChild(child: NodeWidget): void {
11+
throwUnsupported(this);
12+
}
13+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
14+
throwUnsupported(this);
15+
}
16+
removeChild(child: NodeWidget): void {
17+
throwUnsupported(this);
18+
}
19+
static tagName = "checkbox";
20+
}
21+
22+
export interface CheckBoxProps extends ViewProps {
23+
text?: string;
24+
checked?: boolean;
25+
}
26+
27+
export const setProps = (
28+
widget: RNCheckBox,
29+
newProps: CheckBoxProps,
30+
oldProps: CheckBoxProps
31+
) => {
32+
const setter: CheckBoxProps = {
33+
set text(checkboxText: string) {
34+
widget.setText(checkboxText);
35+
},
36+
set checked(isChecked: boolean) {
37+
widget.setChecked(isChecked);
38+
}
39+
};
40+
Object.assign(setter, newProps);
41+
setViewProps(widget, newProps, oldProps);
42+
};

0 commit comments

Comments
 (0)