Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@nodegui/react-nodegui",
"version": "0.2.5",
"version": "0.2.6",
"description": "React Native for building cross platform desktop applications",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand DownExpand Up@@ -31,7 +31,7 @@
"react": "^16.9.0"
},
"devDependencies":{
"@nodegui/nodegui": "^0.6.5",
"@nodegui/nodegui": "^0.6.7",
"@types/node": "^12.0.10",
"prettier": "^1.18.2",
"react": "^16.9.0",
Expand Down
45 changes: 12 additions & 33 deletions src/components/Window/RNWindow.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,20 +12,7 @@ const setWindowProps = (
oldProps: WindowProps
) =>{
const setter: WindowProps ={
set centralWidgetProps(centralWidgetProps: ViewProps){
if (window.centralWidget){
const oldcentralWidgetProps = oldProps.centralWidgetProps ||{};
setViewProps(
window.centralWidget as RNView,
centralWidgetProps,
oldcentralWidgetProps
);
} else{
console.warn(
"Trying to set viewProps for main window but no central widget set."
);
}
}
// TODO add more props
};
Object.assign(setter, newProps);
setViewProps(window, newProps, oldProps);
Expand All@@ -38,29 +25,21 @@ export class RNWindow extends QMainWindow implements RNWidget{
setProps(newProps: WindowProps, oldProps: WindowProps): void{
setWindowProps(this, newProps, oldProps);
}
static tagName = "mainwindow"
removeChild(child: NodeWidget){
const removedChild = this.takeCentralWidget();
if (removedChild){
removedChild.close();
}
child.close();
}
appendInitialChild(child: NodeWidget): void{
this.appendChild(child);
this.setCentralWidget(child);
}
appendChild(child: NodeWidget): void{
if (!child){
return;
}
(this.layout as FlexLayout).addWidget(child);
this.appendInitialChild(child);
}
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void{
if (!this.layout){
console.warn("window has no layout to insert child before another child");
return;
}
(this.layout as FlexLayout).insertChildBefore(child, beforeChild);
}
removeChild(child: NodeWidget){
if (!this.layout){
console.warn("parent has no layout to remove child from");
return;
}
(this.layout as FlexLayout).removeWidget(child);
child.close();
this.appendInitialChild(child);
}
static tagName = "mainwindow"
}
6 changes: 0 additions & 6 deletions src/components/Window/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
import{registerComponent, ComponentConfig } from "../config"
import{QWidget, FlexLayout } from "@nodegui/nodegui"
import{Fiber } from "react-reconciler"
import{WindowProps, RNWindow } from "./RNWindow"
import{AppContainer } from "../../reconciler"
Expand All@@ -16,11 +15,6 @@ class WindowConfig extends ComponentConfig{
workInProgress: Fiber
): RNWindow{
const window = new RNWindow();
const rootView = new QWidget();
const rootViewLayout = new FlexLayout();
rootViewLayout.setFlexNode(rootView.getFlexNode());
rootView.setLayout(rootViewLayout);
window.setCentralWidget(rootView);
window.setProps(newProps,{});
return window;
}
Expand Down