From 4b33f876db09daaeea508dadd05eb7508657dd72 Mon Sep 17 00:00:00 2001 From: normal-me <147307373+normal-me@users.noreply.github.com> Date: Sat, 30 Mar 2024 16:15:59 +0800 Subject: [PATCH 1/4] Update tab_view.dart add 'addIconBuilder' to TabView --- lib/src/controls/navigation/tab_view.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/controls/navigation/tab_view.dart b/lib/src/controls/navigation/tab_view.dart index 06b888615..88f3b9bb9 100644 --- a/lib/src/controls/navigation/tab_view.dart +++ b/lib/src/controls/navigation/tab_view.dart @@ -61,6 +61,7 @@ class TabView extends StatefulWidget { required this.tabs, this.onNewPressed, this.addIconData = FluentIcons.add, + this.addIconBuilder, this.shortcutsEnabled = true, this.onReorder, this.showScrollButtons = true, @@ -91,6 +92,9 @@ class TabView extends StatefulWidget { /// The icon of the new button final IconData addIconData; + + /// The builder for the add icon + final Widget Function(Widget)? addIconBuilder; /// Whether the following shortcuts are enabled: /// @@ -562,7 +566,10 @@ class _TabViewState extends State { ), child: _buttonTabBuilder( context, - Icon(widget.addIconData, size: 12.0), + widget.addIconBuilder?.call( + Icon(widget.addIconData, size: 12.0), + ) ?? + Icon(widget.addIconData, size: 12.0), widget.onNewPressed!, localizations.newTabLabel, ), From 4a33e54809b10a35446d233e89b6d57c16ef5b99 Mon Sep 17 00:00:00 2001 From: normalllll <147307373+normalllll@users.noreply.github.com> Date: Sat, 30 Mar 2024 16:24:32 +0800 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a844c590e..ab4a35c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [next] +* feat: Added `addIconBuilder` to `TabView`. + ## 4.8.6 * fix: Pop the menu flyout before than calling the close callback ([#1009](https://github.com/bdlukaa/fluent_ui/issues/1009)) From 7fceac43e160273aee851b7eeabca15a8f4ae280 Mon Sep 17 00:00:00 2001 From: normalllll <147307373+normalllll@users.noreply.github.com> Date: Sat, 30 Mar 2024 16:28:38 +0800 Subject: [PATCH 3/4] Update tab_view.dart --- lib/src/controls/navigation/tab_view.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/controls/navigation/tab_view.dart b/lib/src/controls/navigation/tab_view.dart index 88f3b9bb9..525e52808 100644 --- a/lib/src/controls/navigation/tab_view.dart +++ b/lib/src/controls/navigation/tab_view.dart @@ -567,8 +567,8 @@ class _TabViewState extends State { child: _buttonTabBuilder( context, widget.addIconBuilder?.call( - Icon(widget.addIconData, size: 12.0), - ) ?? + Icon(widget.addIconData, size: 12.0), + ) ?? Icon(widget.addIconData, size: 12.0), widget.onNewPressed!, localizations.newTabLabel, From 83218ec172dcf8d44495b2051fb4cb8ec900afed Mon Sep 17 00:00:00 2001 From: Bruno D'Luka <45696119+bdlukaa@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:48:11 -0300 Subject: [PATCH 4/4] Apply suggestions from code review --- CHANGELOG.md | 2 +- lib/src/controls/navigation/tab_view.dart | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab4a35c41..13ec05ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## [next] -* feat: Added `addIconBuilder` to `TabView`. +* feat: Added `addIconBuilder` to `TabView` ([#1047](https://github.com/bdlukaa/fluent_ui/pull/1047)) ## 4.8.6 diff --git a/lib/src/controls/navigation/tab_view.dart b/lib/src/controls/navigation/tab_view.dart index 525e52808..02e8c28c6 100644 --- a/lib/src/controls/navigation/tab_view.dart +++ b/lib/src/controls/navigation/tab_view.dart @@ -93,8 +93,12 @@ class TabView extends StatefulWidget { /// The icon of the new button final IconData addIconData; - /// The builder for the add icon - final Widget Function(Widget)? addIconBuilder; + /// The builder for the add icon. + /// + /// This does not build the add button, only its icon. + /// + /// When null, the add icon is rendered. + final Widget Function(Widget addIcon)? addIconBuilder; /// Whether the following shortcuts are enabled: ///