Skip to content

Commit 7a144eb

Browse files
committed
Re architect the react-nodegui codebase to add room for more widgets like scrollarea
1 parent 4e65ff5 commit 7a144eb

File tree

18 files changed

+273
-85
lines changed

18 files changed

+273
-85
lines changed

src/components/Button/RNButton.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
import { QIcon, QPushButton } from "@nodegui/nodegui";
1+
import { QIcon, QPushButton, NodeWidget } from "@nodegui/nodegui";
22
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
35

4-
export class RNButton extends QPushButton {
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+
}
519
static tagName = "button";
620
}
7-
821
export interface ButtonProps extends ViewProps {
922
text?: string;
1023
flat?: boolean;

src/components/CheckBox/RNCheckBox.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import { ViewProps, setProps as setViewProps } from "../View/RNView";
2-
import { QCheckBox } from "@nodegui/nodegui";
2+
import { QCheckBox, NodeWidget } from "@nodegui/nodegui";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
35

4-
export class RNCheckBox extends QCheckBox {
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+
}
519
static tagName = "checkbox";
620
}
721

src/components/Dial/RNDial.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
import { QDial } from "@nodegui/nodegui";
1+
import { QDial, NodeWidget } from "@nodegui/nodegui";
22
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3-
4-
export class RNDial extends QDial {
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
5+
export class RNDial extends QDial implements RNWidget {
6+
appendInitialChild(child: NodeWidget): void {
7+
throwUnsupported(this);
8+
}
9+
appendChild(child: NodeWidget): void {
10+
throwUnsupported(this);
11+
}
12+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
13+
throwUnsupported(this);
14+
}
15+
removeChild(child: NodeWidget): void {
16+
throwUnsupported(this);
17+
}
518
static tagName = "dial";
619
}
720

src/components/Image/RNImage.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import { QLabel, QPixmap, AspectRatioMode } from "@nodegui/nodegui";
1+
import { QLabel, QPixmap, AspectRatioMode, NodeWidget } from "@nodegui/nodegui";
22
import { TextProps, setProps as setTextProps } from "../Text/RNText";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
35

4-
export class RNImage extends QLabel {
6+
export class RNImage extends QLabel 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+
}
519
static tagName = "image";
620
originalPixmap?: QPixmap;
721
aspectRatioMode?: AspectRatioMode;

src/components/LineEdit/RNLineEdit.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
import { QLineEdit } from "@nodegui/nodegui";
1+
import { QLineEdit, NodeWidget } from "@nodegui/nodegui";
22
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3-
4-
export class RNLineEdit extends QLineEdit {
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
5+
export class RNLineEdit extends QLineEdit implements RNWidget {
6+
appendInitialChild(child: NodeWidget): void {
7+
throwUnsupported(this);
8+
}
9+
appendChild(child: NodeWidget): void {
10+
throwUnsupported(this);
11+
}
12+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
13+
throwUnsupported(this);
14+
}
15+
removeChild(child: NodeWidget): void {
16+
throwUnsupported(this);
17+
}
518
static tagName = "linedit";
619
}
720

src/components/PlainTextEdit/RNPlainTextEdit.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import { QPlainTextEdit } from "@nodegui/nodegui";
1+
import { QPlainTextEdit, NodeWidget } from "@nodegui/nodegui";
22
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
35

4-
export class RNPlainTextEdit extends QPlainTextEdit {
6+
export class RNPlainTextEdit extends QPlainTextEdit 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+
}
519
static tagName = "plaintextedit";
620
}
721

src/components/ProgressBar/RNProgressBar.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import { QProgressBar, Orientation } from "@nodegui/nodegui";
1+
import { QProgressBar, Orientation, NodeWidget } from "@nodegui/nodegui";
22
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
35

4-
export class RNProgressBar extends QProgressBar {
6+
export class RNProgressBar extends QProgressBar 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+
}
519
static tagName = "progressbar";
620
}
721

src/components/RadioButton/RNRadioButton.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import { QRadioButton } from "@nodegui/nodegui";
1+
import { QRadioButton, NodeWidget } from "@nodegui/nodegui";
22
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3+
import { RNWidget } from "../config";
4+
import { throwUnsupported } from "../../utils/helpers";
35

4-
export class RNRadioButton extends QRadioButton {
6+
export class RNRadioButton extends QRadioButton 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+
}
519
static tagName = "radiobutton";
620
}
721

src/components/ScrollArea/RNScrollArea.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
import { QScrollArea } from "@nodegui/nodegui";
1+
import { QScrollArea, NodeWidget } from "@nodegui/nodegui";
22
import { ViewProps, setProps as setViewProps } from "../View/RNView";
3-
import { ReactElement } from "react";
3+
import { RNWidget } from "../config";
44

5-
export class RNScrollArea extends QScrollArea {
5+
export class RNScrollArea extends QScrollArea implements RNWidget {
6+
removeChild(child: NodeWidget): void {
7+
throw new Error("Method not implemented.");
8+
//TODO: IMPLEMENT THIS
9+
}
10+
appendInitialChild(child: NodeWidget): void {
11+
this.setWidget(child);
12+
}
13+
appendChild(child: NodeWidget): void {
14+
this.appendInitialChild(child);
15+
}
16+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
17+
this.appendInitialChild(child);
18+
}
619
static tagName = "scrollarea";
720
}
821
export interface ScrollAreaProps extends ViewProps {
9-
children?: ReactElement;
22+
// TODO add props
1023
}
1124

1225
export const setProps = (
@@ -15,10 +28,7 @@ export const setProps = (
1528
oldProps: ScrollAreaProps
1629
) => {
1730
const setter: ScrollAreaProps = {
18-
set children(childWidget: ReactElement) {
19-
console.log(childWidget, "childWidget");
20-
// widget.setWidget(childWidget);
21-
}
31+
//TODO add props
2232
};
2333
Object.assign(setter, newProps);
2434
setViewProps(widget, newProps, oldProps);

src/components/ScrollArea/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { registerComponent, ComponentConfig } from "../config";
2-
import { QScrollArea, NodeWidget } from "@nodegui/nodegui";
2+
import { NodeWidget } from "@nodegui/nodegui";
33
import { Fiber } from "react-reconciler";
44
import { RNScrollArea, setProps, ScrollAreaProps } from "./RNScrollArea";
55

@@ -25,7 +25,7 @@ class ScrollAreaConfig extends ComponentConfig {
2525
newProps: object,
2626
finishedWork: Fiber
2727
): void {
28-
setProps(instance as QScrollArea, newProps, oldProps);
28+
setProps(instance as RNScrollArea, newProps, oldProps);
2929
}
3030
}
3131

0 commit comments

Comments
 (0)