1
+ import 'dart:ui' ;
2
+
1
3
import 'package:flutter/material.dart' ;
2
- import 'package:multi_window_ref_app/app/window_metadata_content .dart' ;
4
+ import 'package:multi_window_ref_app/app/window_controller_render .dart' ;
3
5
4
6
import 'window_settings.dart' ;
5
7
import 'window_settings_dialog.dart' ;
@@ -47,6 +49,7 @@ class MainWindow extends StatefulWidget {
47
49
48
50
class _MainWindowState extends State <MainWindow > {
49
51
final _WindowManagerModel _windowManagerModel = _WindowManagerModel ();
52
+ final WindowSettings _settings = WindowSettings ();
50
53
51
54
@override
52
55
Widget build (BuildContext context) {
@@ -75,7 +78,8 @@ class _MainWindowState extends State<MainWindow> {
75
78
builder: (BuildContext context, Widget ? child) {
76
79
return _WindowCreatorCard (
77
80
selectedWindow: _windowManagerModel.selected,
78
- windowManagerModel: _windowManagerModel);
81
+ windowManagerModel: _windowManagerModel,
82
+ windowSettings: _settings);
79
83
})
80
84
],
81
85
),
@@ -88,22 +92,31 @@ class _MainWindowState extends State<MainWindow> {
88
92
view: ListenableBuilder (
89
93
listenable: _windowManagerModel,
90
94
builder: (BuildContext context, Widget ? widget) {
91
- return _ViewCollection (windowManagerModel: _windowManagerModel);
95
+ return _ViewCollection (
96
+ windowManagerModel: _windowManagerModel,
97
+ windowSettings: _settings);
92
98
}),
93
99
child: widget);
94
100
}
95
101
}
96
102
97
103
class _ViewCollection extends StatelessWidget {
98
- _ViewCollection ({required this .windowManagerModel});
104
+ _ViewCollection (
105
+ {required this .windowManagerModel, required this .windowSettings});
99
106
100
- _WindowManagerModel windowManagerModel;
107
+ final _WindowManagerModel windowManagerModel;
108
+ final WindowSettings windowSettings;
101
109
102
110
@override
103
111
Widget build (BuildContext context) {
104
112
final List <Widget > childViews = < Widget > [];
105
- for (final WindowController childWindow in windowManagerModel.windows) {
106
- childViews.add (WindowMetadataContent (controller: childWindow));
113
+ for (final WindowController controller in windowManagerModel.windows) {
114
+ childViews.add (WindowControllerRender (
115
+ controller: controller,
116
+ onDestroyed: () {
117
+ windowManagerModel.remove (controller);
118
+ },
119
+ windowSettings: windowSettings));
107
120
}
108
121
109
122
return ViewCollection (views: childViews);
@@ -211,19 +224,15 @@ class _ActiveWindowsTable extends StatelessWidget {
211
224
}
212
225
}
213
226
214
- class _WindowCreatorCard extends StatefulWidget {
215
- const _WindowCreatorCard (
216
- {required this .selectedWindow, required this .windowManagerModel});
227
+ class _WindowCreatorCard extends StatelessWidget {
228
+ _WindowCreatorCard (
229
+ {required this .selectedWindow,
230
+ required this .windowManagerModel,
231
+ required this .windowSettings});
217
232
218
233
final WindowController ? selectedWindow;
219
234
final _WindowManagerModel windowManagerModel;
220
-
221
- @override
222
- State <StatefulWidget > createState () => _WindowCreatorCardState ();
223
- }
224
-
225
- class _WindowCreatorCardState extends State <_WindowCreatorCard > {
226
- WindowSettings _settings = WindowSettings ();
235
+ final WindowSettings windowSettings;
227
236
228
237
@override
229
238
Widget build (BuildContext context) {
@@ -249,7 +258,7 @@ class _WindowCreatorCardState extends State<_WindowCreatorCard> {
249
258
children: [
250
259
OutlinedButton (
251
260
onPressed: () async {
252
- widget. windowManagerModel.add (RegularWindowController ());
261
+ windowManagerModel.add (RegularWindowController ());
253
262
},
254
263
child: const Text ('Regular' ),
255
264
),
@@ -259,13 +268,7 @@ class _WindowCreatorCardState extends State<_WindowCreatorCard> {
259
268
child: TextButton (
260
269
child: const Text ('SETTINGS' ),
261
270
onPressed: () {
262
- windowSettingsDialog (context, _settings).then (
263
- (WindowSettings ? settings) {
264
- if (settings != null ) {
265
- _settings = settings;
266
- }
267
- },
268
- );
271
+ windowSettingsDialog (context, windowSettings);
269
272
},
270
273
),
271
274
),
0 commit comments