@@ -12,20 +12,7 @@ const setWindowProps = (
1212 oldProps : WindowProps
1313) => {
1414 const setter : WindowProps = {
15- set centralWidgetProps ( centralWidgetProps : ViewProps ) {
16- if ( window . centralWidget ) {
17- const oldcentralWidgetProps = oldProps . centralWidgetProps || { } ;
18- setViewProps (
19- window . centralWidget as RNView ,
20- centralWidgetProps ,
21- oldcentralWidgetProps
22- ) ;
23- } else {
24- console . warn (
25- "Trying to set viewProps for main window but no central widget set."
26- ) ;
27- }
28- }
15+ // TODO add more props
2916 } ;
3017 Object . assign ( setter , newProps ) ;
3118 setViewProps ( window , newProps , oldProps ) ;
@@ -38,29 +25,21 @@ export class RNWindow extends QMainWindow implements RNWidget {
3825 setProps ( newProps : WindowProps , oldProps : WindowProps ) : void {
3926 setWindowProps ( this , newProps , oldProps ) ;
4027 }
41- static tagName = "mainwindow" ;
28+ removeChild ( child : NodeWidget ) {
29+ const removedChild = this . takeCentralWidget ( ) ;
30+ if ( removedChild ) {
31+ removedChild . close ( ) ;
32+ }
33+ child . close ( ) ;
34+ }
4235 appendInitialChild ( child : NodeWidget ) : void {
43- this . appendChild ( child ) ;
36+ this . setCentralWidget ( child ) ;
4437 }
4538 appendChild ( child : NodeWidget ) : void {
46- if ( ! child ) {
47- return ;
48- }
49- ( this . layout as FlexLayout ) . addWidget ( child ) ;
39+ this . appendInitialChild ( child ) ;
5040 }
5141 insertBefore ( child : NodeWidget , beforeChild : NodeWidget ) : void {
52- if ( ! this . layout ) {
53- console . warn ( "window has no layout to insert child before another child" ) ;
54- return ;
55- }
56- ( this . layout as FlexLayout ) . insertChildBefore ( child , beforeChild ) ;
57- }
58- removeChild ( child : NodeWidget ) {
59- if ( ! this . layout ) {
60- console . warn ( "parent has no layout to remove child from" ) ;
61- return ;
62- }
63- ( this . layout as FlexLayout ) . removeWidget ( child ) ;
64- child . close ( ) ;
42+ this . appendInitialChild ( child ) ;
6543 }
44+ static tagName = "mainwindow" ;
6645}
0 commit comments