rand dart fix
This commit is contained in:
@@ -27,7 +27,7 @@ class _WindowAcceptRegionState extends State<WindowAcceptRegion> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox.fromSize(
|
||||
size: widget?.size,
|
||||
size: widget.size,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, dimens) => Stack(
|
||||
fit: StackFit.expand,
|
||||
@@ -42,22 +42,22 @@ class _WindowAcceptRegionState extends State<WindowAcceptRegion> {
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
left: widget?.left ?? 0,
|
||||
right: widget?.right ?? 0,
|
||||
top: widget?.top ?? 0,
|
||||
bottom: widget?.bottom ?? 0,
|
||||
left: widget.left ?? 0,
|
||||
right: widget.right ?? 0,
|
||||
top: widget.top ?? 0,
|
||||
bottom: widget.bottom ?? 0,
|
||||
child: Container(
|
||||
child: DragTarget<WindowTab>(
|
||||
builder: (context, accepted, rejected) => Container(),
|
||||
onAccept: (val) {
|
||||
onAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
accepting = false;
|
||||
});
|
||||
}
|
||||
if (widget.onAccept != null) widget.onAccept(val);
|
||||
widget.onAccept(val);
|
||||
},
|
||||
onWillAccept: (val) {
|
||||
onWillAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
accepting = true;
|
||||
|
||||
@@ -24,12 +24,8 @@ class WindowController extends ChangeNotifier {
|
||||
WindowCollection base = WindowColumn([]);
|
||||
|
||||
void addToBase(WindowTab tab) {
|
||||
if (base == null) {
|
||||
base = WindowColumn([WindowGroup(tab)]);
|
||||
} else {
|
||||
_addTab(base, tab);
|
||||
}
|
||||
notifyListeners();
|
||||
_addTab(base, tab);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool _addTab(WindowCollection item, WindowTab tab) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class WindowColumn extends WindowCollection {
|
||||
|
||||
class WindowGroup extends WindowCollection {
|
||||
WindowGroup([WindowTab tab, bool closeable = true]) {
|
||||
if (tab != null) _tabs.add(tab);
|
||||
_tabs.add(tab);
|
||||
canClose = closeable;
|
||||
}
|
||||
bool canClose = true;
|
||||
@@ -56,14 +56,9 @@ class WindowGroup extends WindowCollection {
|
||||
}
|
||||
|
||||
void addTab(WindowTab tab, [int index]) {
|
||||
if (index != null) {
|
||||
_tabs.insert(index, tab);
|
||||
_activeTab = index;
|
||||
} else {
|
||||
_tabs.add(tab);
|
||||
_activeTab = _tabs.length - 1;
|
||||
}
|
||||
notifyListeners();
|
||||
_tabs.insert(index, tab);
|
||||
_activeTab = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void removeTab(WindowTab tab) {
|
||||
|
||||
@@ -54,11 +54,11 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _theme =
|
||||
GoldenLayoutTheme.of(context)?.theme ?? GoldenLayoutThemeData();
|
||||
GoldenLayoutTheme.of(context).theme ?? GoldenLayoutThemeData();
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
color: _theme?.backgroundColor,
|
||||
color: _theme.backgroundColor,
|
||||
height: 32,
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -72,13 +72,12 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
for (var i = 0; i < widget.group.tabs.length; i++)
|
||||
Draggable<WindowTab>(
|
||||
data: widget.group.tabs[i],
|
||||
dragAnchor: DragAnchor.child,
|
||||
onDragStarted: () {
|
||||
_draggingTab = widget.group.tabs[i];
|
||||
widget.group.removeTab(_draggingTab);
|
||||
widget.update();
|
||||
if (widget.group.tabs.isEmpty) {
|
||||
widget.onClose?.call();
|
||||
widget.onClose.call();
|
||||
}
|
||||
widget.onDraggingChanged(true);
|
||||
},
|
||||
@@ -128,7 +127,7 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
});
|
||||
}
|
||||
},
|
||||
onWillAccept: (val) {
|
||||
onWillAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
accepting = i;
|
||||
@@ -136,7 +135,7 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onAccept: (val) {
|
||||
onAcceptWithDetails: (val) {
|
||||
widget.onModify(
|
||||
context, val, WindowPos.tab, accepting);
|
||||
if (mounted) {
|
||||
@@ -155,9 +154,9 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: selected
|
||||
? _theme?.tabSelectedBackgroundColor ??
|
||||
? _theme.tabSelectedBackgroundColor ??
|
||||
Colors.grey.shade600
|
||||
: _theme?.backgroundColor,
|
||||
: _theme.backgroundColor,
|
||||
borderRadius: selected
|
||||
? BorderRadius.only(
|
||||
topLeft: Radius.circular(5),
|
||||
@@ -197,17 +196,17 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: 18,
|
||||
color: _theme?.tabIconColor ??
|
||||
color: _theme.tabIconColor ??
|
||||
Colors.white,
|
||||
),
|
||||
onTap: () {
|
||||
widget.group.tabs[i].onClose
|
||||
?.call();
|
||||
.call();
|
||||
widget.group.removeTab(
|
||||
widget.group.tabs[i]);
|
||||
widget.update();
|
||||
if (widget.group.tabs.isEmpty) {
|
||||
widget.onClose?.call();
|
||||
widget.onClose.call();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -225,17 +224,16 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
), dragAnchorStrategy: childDragAnchorStrategy,
|
||||
),
|
||||
if (widget.onAddTab != null)
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
icon: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () =>
|
||||
widget.group.addTab(widget.onAddTab())),
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
icon: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () =>
|
||||
widget.group.addTab(widget.onAddTab())),
|
||||
if (widget.isDragging)
|
||||
WindowAcceptRegion(
|
||||
size: Size(100, 32),
|
||||
@@ -249,18 +247,17 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
color: _theme?.tabIconColor ?? Colors.white,
|
||||
color: _theme.tabIconColor ?? Colors.white,
|
||||
iconSize: 18,
|
||||
icon: Icon(widget.minimize ? Icons.minimize : Icons.fullscreen),
|
||||
onPressed: widget.onFullScreen,
|
||||
),
|
||||
if (widget.onClose != null)
|
||||
IconButton(
|
||||
color: _theme?.tabIconColor ?? Colors.white,
|
||||
iconSize: 18,
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: widget.onClose,
|
||||
),
|
||||
IconButton(
|
||||
color: _theme.tabIconColor ?? Colors.white,
|
||||
iconSize: 18,
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: widget.onClose,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user