@@ -13,8 +13,8 @@ import 'regular_window_edit_dialog.dart';
1313
1414class MainWindow extends StatefulWidget {
1515 MainWindow ({super .key, required WindowController mainController}) {
16- _windowManagerModel.add (
17- KeyedWindowController ( isMainWindow: true , key: UniqueKey (), controller: mainController));
16+ _windowManagerModel.add (KeyedWindowController (
17+ isMainWindow: true , key: UniqueKey (), controller: mainController));
1818 }
1919
2020 final WindowManagerModel _windowManagerModel = WindowManagerModel ();
@@ -38,7 +38,8 @@ class _MainWindowState extends State<MainWindow> {
3838 flex: 60 ,
3939 child: SingleChildScrollView (
4040 scrollDirection: Axis .vertical,
41- child: _ActiveWindowsTable (windowManagerModel: widget._windowManagerModel),
41+ child: _ActiveWindowsTable (
42+ windowManagerModel: widget._windowManagerModel),
4243 ),
4344 ),
4445 Expanded (
@@ -66,15 +67,18 @@ class _MainWindowState extends State<MainWindow> {
6667 listenable: widget._windowManagerModel,
6768 builder: (BuildContext context, Widget ? _) {
6869 final List <Widget > childViews = < Widget > [];
69- for (final KeyedWindowController controller in widget._windowManagerModel.windows) {
70+ for (final KeyedWindowController controller
71+ in widget._windowManagerModel.windows) {
7072 if (controller.parent == null && ! controller.isMainWindow) {
7173 childViews.add (WindowControllerRender (
7274 controller: controller.controller,
7375 key: controller.key,
7476 windowSettings: widget._settings,
7577 windowManagerModel: widget._windowManagerModel,
76- onDestroyed: () => widget._windowManagerModel.remove (controller.key),
77- onError: () => widget._windowManagerModel.remove (controller.key),
78+ onDestroyed: () =>
79+ widget._windowManagerModel.remove (controller.key),
80+ onError: () =>
81+ widget._windowManagerModel.remove (controller.key),
7882 ));
7983 }
8084 }
@@ -130,7 +134,8 @@ class _ActiveWindowsTable extends StatelessWidget {
130134 ),
131135 numeric: true ),
132136 ],
133- rows: (windowManagerModel.windows).map <DataRow >((KeyedWindowController controller) {
137+ rows: (windowManagerModel.windows)
138+ .map <DataRow >((KeyedWindowController controller) {
134139 return DataRow (
135140 key: controller.key,
136141 color: WidgetStateColor .resolveWith ((states) {
@@ -142,49 +147,30 @@ class _ActiveWindowsTable extends StatelessWidget {
142147 selected: controller.controller == windowManagerModel.selected,
143148 onSelectChanged: (selected) {
144149 if (selected != null ) {
145- windowManagerModel
146- .select (selected ? controller.controller.rootView.viewId : null );
150+ windowManagerModel.select (selected
151+ ? controller.controller.rootView.viewId
152+ : null );
147153 }
148154 },
149155 cells: [
150156 DataCell (Text ('${controller .controller .rootView .viewId }' )),
151157 DataCell (
152158 ListenableBuilder (
153159 listenable: controller.controller,
154- builder: (BuildContext context, Widget ? _) => Text (controller
155- .controller.type
156- .toString ()
157- .replaceFirst ('WindowArchetype.' , '' ))),
160+ builder: (BuildContext context, Widget ? _) => Text (
161+ controller .controller.type
162+ .toString ()
163+ .replaceFirst ('WindowArchetype.' , '' ))),
158164 ),
159165 DataCell (
160166 ListenableBuilder (
161167 listenable: controller.controller,
162- builder: (BuildContext context, Widget ? _) => Row (children: [
168+ builder: (BuildContext context, Widget ? _) =>
169+ Row (children: [
163170 IconButton (
164- icon: const Icon (Icons .edit_outlined),
165- onPressed: () {
166- if (controller.controller.type == WindowArchetype .regular) {
167- showRegularWindowEditDialog (
168- context,
169- initialWidth: controller.controller.contentSize.width,
170- initialHeight: controller.controller.contentSize.height,
171- initialTitle: "" ,
172- onSave: (double ? width, double ? height, String ? title) {
173- final regularController =
174- controller.controller as RegularWindowController ;
175- if (width != null && height != null ) {
176- regularController.updateContentSize (
177- WindowSizing (preferredSize: Size (width, height)),
178- );
179- }
180- if (title != null ) {
181- regularController.setTitle (title);
182- }
183- },
184- );
185- }
186- },
187- ),
171+ icon: const Icon (Icons .edit_outlined),
172+ onPressed: () => _showWindowEditDialog (
173+ controller, context)),
188174 IconButton (
189175 icon: const Icon (Icons .delete_outlined),
190176 onPressed: () async {
@@ -199,6 +185,49 @@ class _ActiveWindowsTable extends StatelessWidget {
199185 );
200186 });
201187 }
188+
189+ void _showWindowEditDialog (
190+ KeyedWindowController controller, BuildContext context) {
191+ if (controller.controller.type != WindowArchetype .regular) {
192+ return ;
193+ }
194+
195+ final regularController = controller.controller as RegularWindowController ;
196+ showRegularWindowEditDialog (
197+ context: context,
198+ initialWidth: controller.controller.contentSize.width,
199+ initialHeight: controller.controller.contentSize.height,
200+ initialTitle: "" ,
201+ isFullscreen: regularController.isFullscreen (),
202+ isMaximized: regularController.isMaximized (),
203+ isMinimized: regularController.isMinimized (),
204+ onSave: (EditResult result) {
205+ if (result.width != null && result.height != null ) {
206+ regularController.updateContentSize (
207+ WindowSizing (preferredSize: Size (result.width! , result.height! )),
208+ );
209+ }
210+ if (result.title != null ) {
211+ regularController.setTitle (result.title! );
212+ }
213+ if (result.fullscreen != null ) {
214+ if (regularController.isFullscreen () != result.fullscreen! ) {
215+ regularController.setFullscreen (result.fullscreen! );
216+ }
217+ }
218+ if (result.maximized != null ) {
219+ if (regularController.isMaximized () != result.maximized! ) {
220+ regularController.setMaximized (result.maximized! );
221+ }
222+ }
223+ if (result.minimized != null ) {
224+ if (regularController.isMinimized () != result.minimized! ) {
225+ regularController.setMinimized (result.minimized! );
226+ }
227+ }
228+ },
229+ );
230+ }
202231}
203232
204233class _WindowCreatorCard extends StatelessWidget {
@@ -243,7 +272,8 @@ class _WindowCreatorCard extends StatelessWidget {
243272 onDestroyed: () => windowManagerModel.remove (key),
244273 ),
245274 title: "Regular" ,
246- contentSize: WindowSizing (preferredSize: windowSettings.regularSize),
275+ contentSize: WindowSizing (
276+ preferredSize: windowSettings.regularSize),
247277 )));
248278 },
249279 child: const Text ('Regular' ),
0 commit comments