Skip to content

Commit c408455

Browse files
committed
Achieves feature parity with NodeGUI v0.1.9 interms of methods and widgets exported
1 parent 740288b commit c408455

File tree

10 files changed

+75
-73
lines changed

10 files changed

+75
-73
lines changed

package-lock.json

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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"react": "16.9.0"
2323
},
2424
"devDependencies": {
25-
"@nodegui/nodegui": "^0.1.8",
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/CheckBox/RNCheckBox.ts

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export class RNCheckBox extends QCheckBox implements RNWidget {
2020
}
2121

2222
export interface CheckBoxProps extends ViewProps {
23-
children?: string;
2423
text?: string;
2524
checked?: boolean;
2625
}

src/components/LineEdit/RNLineEdit.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export class RNLineEdit extends QLineEdit implements RNWidget {
1919
}
2020

2121
export interface LineEditProps extends ViewProps {
22-
children?: string;
2322
text?: string;
2423
placeholderText?: string;
2524
readOnly?: boolean;

src/components/PlainTextEdit/RNPlainTextEdit.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export class RNPlainTextEdit extends QPlainTextEdit implements RNWidget {
2020
}
2121

2222
export interface PlainTextEditProps extends ViewProps {
23-
children?: string;
2423
text?: string;
2524
readOnly?: boolean;
25+
placeholderText?: string;
2626
}
2727

2828
export const setProps = (
@@ -36,6 +36,9 @@ export const setProps = (
3636
},
3737
set readOnly(isReadOnly: boolean) {
3838
widget.setReadOnly(isReadOnly);
39+
},
40+
set placeholderText(text: string) {
41+
widget.setPlaceholderText(text);
3942
}
4043
};
4144
Object.assign(setter, newProps);

src/components/ScrollArea/RNScrollArea.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { RNWidget } from "../config";
44

55
export class RNScrollArea extends QScrollArea implements RNWidget {
66
removeChild(child: NodeWidget): void {
7-
throw new Error("Method not implemented.");
8-
//TODO: IMPLEMENT THIS
7+
const removedChild = this.takeWidget();
8+
if (removedChild) {
9+
removedChild.close();
10+
}
11+
child.close();
912
}
1013
appendInitialChild(child: NodeWidget): void {
1114
this.setWidget(child);

src/components/View/RNView.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class RNView extends QWidget implements RNWidget {
6060
return;
6161
}
6262
(this.layout as FlexLayout).removeWidget(child);
63+
child.close();
6364
}
6465
}
6566

src/components/Window/RNWindow.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class RNWindow extends QMainWindow implements RNWidget {
2626
return;
2727
}
2828
(this.layout as FlexLayout).removeWidget(child);
29+
child.close();
2930
}
3031
}
3132

src/demo.tsx

+39-29
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,66 @@ import { ScrollArea } from "./components/ScrollArea";
99

1010
const App = () => {
1111
const winRef = useRef<QMainWindow>(null);
12-
const [fileUrl, setFileUrl] = useState();
13-
const [imageSrc, setImageSrc] = useState();
12+
const [value, setValue] = useState(false);
1413
useEffect(() => {
1514
if (winRef.current) {
1615
winRef.current.resize(800, 450);
1716
}
1817
}, []);
19-
const lineEditHandler = useMemo(
20-
() => ({
21-
[QLineEditEvents.textChanged]: (text: string) => {
22-
setFileUrl(text);
23-
}
24-
}),
25-
[]
26-
);
2718

28-
const loadButtonHandler = useMemo(
19+
const toggleHandler = useMemo(
2920
() => ({
3021
[QPushButtonEvents.clicked]: () => {
31-
setImageSrc(fileUrl);
22+
setValue(!value);
3223
}
3324
}),
34-
[fileUrl]
25+
[value]
3526
);
3627

3728
return (
3829
<>
3930
<Window ref={winRef} styleSheet={styleSheet}>
4031
<View id="container">
4132
<View id="controls">
42-
<LineEdit
43-
on={lineEditHandler}
44-
id="textField"
45-
text={fileUrl}
46-
placeholderText="Absolute path to an image"
47-
/>
48-
<Button text="Load Image" on={loadButtonHandler} />
33+
<Button text="Toggle scollwidget" on={toggleHandler} />
4934
</View>
5035
<ScrollArea style={`width:400px;height:400px;`}>
51-
<View
52-
style={`
36+
{value ? (
37+
<View
38+
style={`
39+
min-width: 0;
5340
min-width: 0;
54-
min-height:0;
55-
height:500px;
56-
width: 500px;
57-
background-color:green;
41+
min-width: 0;
42+
min-height:0;
43+
height:500px;
44+
width: 500px;
45+
background-color:green;
46+
`}
47+
>
48+
<Text>Hello</Text>
49+
<View
50+
style={`
51+
height: '50%';
52+
width: '50%';
53+
background-color: pink;
54+
`}
55+
></View>
56+
</View>
57+
) : (
58+
<View
59+
style={`
60+
min-width: 0;
61+
min-width: 0;
62+
min-width: 0;
63+
min-height:0;
64+
height:500px;
65+
width: 500px;
66+
background-color:blue;
5867
`}
59-
>
60-
<Text>Hello</Text>
61-
</View>
68+
>
69+
<Text>World</Text>
70+
</View>
71+
)}
6272
</ScrollArea>
6373
</View>
6474
</Window>

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export { ProgressBar } from "./components/ProgressBar";
1111
export { RadioButton } from "./components/RadioButton";
1212
export { Dial } from "./components/Dial";
1313
export { SpinBox } from "./components/SpinBox";
14-
// export { ScrollArea } from "./components/ScrollArea"; // TODO: Not working correctly yet
14+
export { ScrollArea } from "./components/ScrollArea";
1515
export { useEventHandler } from "./hooks";

0 commit comments

Comments
 (0)