diff --git a/package-lock.json b/package-lock.json index 5c464cf2..4f137adf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@nodegui/react-nodegui", - "version": "0.2.5", + "version": "0.2.6", "lockfileVersion": 1, "requires": true, "dependencies": { "@nodegui/nodegui": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/@nodegui/nodegui/-/nodegui-0.6.5.tgz", - "integrity": "sha512-oAp99eyiVyVBjnEB54ghy058oB37Xb3LW18VFcrLog8MU2RfetaKjIGk6LPgeCe5IBStfVmlZbJnuW7Tq/Te4A==", + "version": "0.6.7", + "resolved": "https://registry.npmjs.org/@nodegui/nodegui/-/nodegui-0.6.7.tgz", + "integrity": "sha512-YQrviZw9o7O2Fff5LmU1voPm6JIVebfQ1atyowvTBtMmgFfUQ7iCLGnbbiJD+3uZV9DJANO+3kb/20UPSr00yg==", "dev": true, "requires": { - "@nodegui/qode": "^1.0.5", + "@nodegui/qode": "^1.0.6", "cmake-js": "^6.0.0", "cross-env": "^6.0.0", "cuid": "^2.1.6", diff --git a/package.json b/package.json index 67e85735..a2efa58b 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/components/Window/RNWindow.ts b/src/components/Window/RNWindow.ts index 28334db6..2f8aac60 100644 --- a/src/components/Window/RNWindow.ts +++ b/src/components/Window/RNWindow.ts @@ -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); @@ -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"; } diff --git a/src/components/Window/index.ts b/src/components/Window/index.ts index bac055ae..068a57c5 100644 --- a/src/components/Window/index.ts +++ b/src/components/Window/index.ts @@ -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"; @@ -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; }