@@ -12,20 +12,7 @@ const setWindowProps = (
12
12
oldProps : WindowProps
13
13
) => {
14
14
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
29
16
} ;
30
17
Object . assign ( setter , newProps ) ;
31
18
setViewProps ( window , newProps , oldProps ) ;
@@ -38,29 +25,21 @@ export class RNWindow extends QMainWindow implements RNWidget {
38
25
setProps ( newProps : WindowProps , oldProps : WindowProps ) : void {
39
26
setWindowProps ( this , newProps , oldProps ) ;
40
27
}
41
- static tagName = "mainwindow" ;
28
+ removeChild ( child : NodeWidget ) {
29
+ const removedChild = this . takeCentralWidget ( ) ;
30
+ if ( removedChild ) {
31
+ removedChild . close ( ) ;
32
+ }
33
+ child . close ( ) ;
34
+ }
42
35
appendInitialChild ( child : NodeWidget ) : void {
43
- this . appendChild ( child ) ;
36
+ this . setCentralWidget ( child ) ;
44
37
}
45
38
appendChild ( child : NodeWidget ) : void {
46
- if ( ! child ) {
47
- return ;
48
- }
49
- ( this . layout as FlexLayout ) . addWidget ( child ) ;
39
+ this . appendInitialChild ( child ) ;
50
40
}
51
41
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 ) ;
65
43
}
44
+ static tagName = "mainwindow" ;
66
45
}
0 commit comments