Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.2.1 #241

Merged
merged 10 commits into from
May 9, 2022
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [1.2.1]
* Fixes issue with error thrown when toolbar actions are modified programmatically [#239](https://github.com/GroovinChip/macos_ui/issues/239)

## [1.2.0]
* Improved styling for `MacosTooltip`:
* Better color and shadows.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.2.0"
version: "1.2.1"
matcher:
dependency: transitive
description:
Expand Down
21 changes: 15 additions & 6 deletions lib/src/layout/toolbar/toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ class ToolBar extends StatefulWidget {
}

class _ToolBarState extends State<ToolBar> {
List<int> overflowedActionsIndexes = [];
int overflowedActionsCount = 0;

@override
void didUpdateWidget(ToolBar oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.actions != null &&
widget.actions!.length != oldWidget.actions!.length) {
overflowedActionsCount = 0;
}
}

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -171,12 +180,12 @@ class _ToolBarState extends State<ToolBar> {
// Collect the toolbar action widgets that can be shown inside the ToolBar
// and the ones that have overflowed.
List<ToolbarItem>? _inToolbarActions = [];
late List<ToolbarItem> _overflowedActions;
List<ToolbarItem> _overflowedActions = [];
bool doAllItemsShowLabel = true;
if (widget.actions != null && widget.actions!.isNotEmpty) {
_inToolbarActions = widget.actions!;
_overflowedActions = overflowedActionsIndexes
.map((index) => widget.actions![index])
_inToolbarActions = widget.actions ?? [];
_overflowedActions = _inToolbarActions
.sublist(_inToolbarActions.length - overflowedActionsCount)
.toList();
// If all toolbar actions have labels shown below their icons,
// reduce the overflow button's size as well.
Expand Down Expand Up @@ -237,7 +246,7 @@ class _ToolBarState extends State<ToolBar> {
e.build(context, ToolbarItemDisplayMode.inToolbar))
.toList(),
overflowChangedCallback: (hiddenItems) {
setState(() => overflowedActionsIndexes = hiddenItems);
setState(() => overflowedActionsCount = hiddenItems.length);
},
),
middleSpacing: 8,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macos_ui
description: Flutter widgets and themes implementing the current macOS design language.
version: 1.2.0
version: 1.2.1
homepage: "https://github.com/GroovinChip/macos_ui"

environment:
Expand Down