Skip to content

Commit

Permalink
feat: Add TabView.addIconBuilder (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa authored Apr 8, 2024
2 parents 550a9c3 + cb16c5b commit 86ae86b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* feat: Added `DatePicker.fieldFlex` to control the width proportion of each field.
* fix: `Slider` thumb is correct rendered when it's on the edges.
* feat: Added `TabView.addIconBuilder` ([#1047](https://github.com/bdlukaa/fluent_ui/pull/1047))

## 4.8.6

Expand Down
13 changes: 12 additions & 1 deletion lib/src/controls/navigation/tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -91,6 +92,13 @@ class TabView extends StatefulWidget {

/// The icon of the new button
final IconData addIconData;

/// 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:
///
Expand Down Expand Up @@ -562,7 +570,10 @@ class _TabViewState extends State<TabView> {
),
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,
),
Expand Down

0 comments on commit 86ae86b

Please sign in to comment.