Files
packages.dart/deprecated/golden_layout/lib/src/controller.dart
2026-01-15 17:36:22 -08:00

56 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
import 'window.dart';
class WindowController extends ChangeNotifier {
WindowGroup _fullScreenGroup;
WindowGroup get fullScreen => _fullScreenGroup;
void Function(WindowGroup) _closeWindow;
void enterFullScreen(WindowGroup val, void Function(WindowGroup) onClose) {
_fullScreenGroup = val;
_closeWindow = onClose;
notifyListeners();
}
void exitFullScreen([bool close = false]) {
if (close) {
_closeWindow(_fullScreenGroup);
}
_fullScreenGroup = null;
notifyListeners();
}
WindowCollection base = WindowColumn([]);
void addToBase(WindowTab tab) {
_addTab(base, tab);
notifyListeners();
}
bool _addTab(WindowCollection item, WindowTab tab) {
if (item is WindowGroup) {
item.addTab(tab);
item.update();
return true;
}
if (item is WindowColumn) {
for (final child in item.children) {
if (_addTab(child, tab)) {
child.update();
return true;
}
}
}
if (item is WindowRow) {
for (final child in item.children) {
if (_addTab(child, tab)) {
child.update();
return true;
}
}
}
return false;
}
}