rand dart fix
This commit is contained in:
@@ -12,9 +12,7 @@ class MyApp extends StatelessWidget {
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
accentColor: Colors.red,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity, colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.blue).copyWith(secondary: Colors.red),
|
||||
),
|
||||
home: MyHomePage(title: 'Flutter Golden Layout'),
|
||||
);
|
||||
@@ -88,7 +86,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
body: GoldenLayoutTheme(
|
||||
data: GoldenLayoutThemeData(
|
||||
tabSelectedBackgroundColor: Theme.of(context).accentColor,
|
||||
tabSelectedBackgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
child: GoldenLayout(
|
||||
controller: _controller,
|
||||
@@ -103,7 +101,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
title: (context, selected, index) => Text(
|
||||
'Window $count',
|
||||
style: TextStyle(
|
||||
color: selected ? Theme.of(context).accentColor : Colors.white,
|
||||
color: selected ? Theme.of(context).colorScheme.secondary : Colors.white,
|
||||
),
|
||||
),
|
||||
child: Container(color: Colors.red[100 * count]));
|
||||
|
||||
@@ -34,55 +34,51 @@ class _GoldenLayoutState extends State<GoldenLayout> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = widget?.controller ?? WindowController();
|
||||
if (widget?.collection != null) {
|
||||
_controller.base = widget.collection;
|
||||
}
|
||||
super.initState();
|
||||
_controller = widget.controller ?? WindowController();
|
||||
_controller.base = widget.collection;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, dimens) {
|
||||
if (_controller.fullScreen != null) {
|
||||
return RenderWindowGroup(
|
||||
onAddTab: widget.onAddTab,
|
||||
onCancel: (val) {
|
||||
_controller.addToBase(val);
|
||||
},
|
||||
isDragging: _isDragging,
|
||||
onDraggingChanged: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isDragging = val;
|
||||
});
|
||||
}
|
||||
},
|
||||
popUpSize: widget.popupSize,
|
||||
minimize: true,
|
||||
group: _controller.fullScreen,
|
||||
onFullScreen: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen();
|
||||
});
|
||||
}
|
||||
},
|
||||
onClose: !_controller.fullScreen.canClose
|
||||
? null
|
||||
: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen(true);
|
||||
});
|
||||
}
|
||||
},
|
||||
update: () {
|
||||
if (mounted) setState(() {});
|
||||
},
|
||||
);
|
||||
}
|
||||
return _renderItem(
|
||||
return RenderWindowGroup(
|
||||
onAddTab: widget.onAddTab,
|
||||
onCancel: (val) {
|
||||
_controller.addToBase(val);
|
||||
},
|
||||
isDragging: _isDragging,
|
||||
onDraggingChanged: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isDragging = val;
|
||||
});
|
||||
}
|
||||
},
|
||||
popUpSize: widget.popupSize,
|
||||
minimize: true,
|
||||
group: _controller.fullScreen,
|
||||
onFullScreen: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen();
|
||||
});
|
||||
}
|
||||
},
|
||||
onClose: !_controller.fullScreen.canClose
|
||||
? null
|
||||
: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen(true);
|
||||
});
|
||||
}
|
||||
},
|
||||
update: () {
|
||||
if (mounted) setState(() {});
|
||||
},
|
||||
);
|
||||
return _renderItem(
|
||||
_controller.base,
|
||||
index: 0,
|
||||
size: Size(dimens.maxWidth, dimens.maxHeight),
|
||||
|
||||
@@ -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