Skip to content

Commit 47d3357

Browse files
authored
Merge pull request #740 from ubuntu/Feichtmeier/issue739
fix: add the missing optional icon parameters
2 parents 6e334ab + 2eb78e2 commit 47d3357

File tree

6 files changed

+61
-22
lines changed

6 files changed

+61
-22
lines changed

lib/src/widgets/yaru_back_button.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class YaruBackButton extends StatelessWidget {
1111
super.key,
1212
this.onPressed,
1313
this.style,
14+
this.icon,
1415
});
1516

1617
/// An optional callback that is called when the button is pressed.
@@ -22,13 +23,17 @@ class YaruBackButton extends StatelessWidget {
2223
/// defaults to [YaruBackButtonStyle.square].
2324
final YaruBackButtonStyle? style;
2425

26+
/// Optional icon used inside the [YaruIconButton]
27+
/// Defaults to `const Icon(YaruIcons.go_previous)`
28+
final Widget? icon;
29+
2530
@override
2631
Widget build(BuildContext context) {
2732
final theme = YaruBackButtonTheme.of(context);
2833
final round = (style ?? theme?.style) == YaruBackButtonStyle.rounded;
2934
final shape = round ? const CircleBorder() : const BeveledRectangleBorder();
3035
final button = YaruIconButton(
31-
icon: const Icon(YaruIcons.go_previous),
36+
icon: icon ?? const Icon(YaruIcons.go_previous),
3237
style: ButtonStyle(
3338
shape: ButtonStyleButton.allOrNull(shape),
3439
),

lib/src/widgets/yaru_choice_chip_bar.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class YaruChoiceChipBar extends StatefulWidget {
2323
this.wrapVerticalDirection = VerticalDirection.down,
2424
this.wrapClipBehavior = Clip.none,
2525
this.wrapTextDirection,
26+
this.goPreviousIcon,
27+
this.goNextIcon,
2628
}) : assert(labels.length == isSelected.length);
2729

2830
/// The [List] of [Widget]'s used to generate a [List] of [ChoiceChip]s
@@ -89,6 +91,10 @@ class YaruChoiceChipBar extends StatefulWidget {
8991
/// The [VerticalDirection] of the [ChoiceChip]s with `YaruChoiceChipStyle.wrap`
9092
final VerticalDirection wrapVerticalDirection;
9193

94+
final Widget? goPreviousIcon;
95+
96+
final Widget? goNextIcon;
97+
9298
@override
9399
State<YaruChoiceChipBar> createState() => _YaruChoiceChipBarState();
94100
}
@@ -180,7 +186,7 @@ class _YaruChoiceChipBarState extends State<YaruChoiceChipBar> {
180186
final goPreviousButton = _NavigationButton(
181187
radius: widget.radius,
182188
chipHeight: widget.chipHeight,
183-
icon: const Icon(YaruIcons.go_previous),
189+
icon: widget.goPreviousIcon ?? const Icon(YaruIcons.go_previous),
184190
onTap: _enableGoPreviousButton
185191
? () => _controller.animateTo(
186192
_controller.position.pixels - widget.navigationStep,
@@ -193,7 +199,7 @@ class _YaruChoiceChipBarState extends State<YaruChoiceChipBar> {
193199
final goNextButton = _NavigationButton(
194200
chipHeight: widget.chipHeight,
195201
radius: widget.radius,
196-
icon: const Icon(YaruIcons.go_next),
202+
icon: widget.goNextIcon ?? const Icon(YaruIcons.go_next),
197203
onTap: _enableGoNextButton
198204
? () => _controller.animateTo(
199205
_controller.position.pixels + widget.navigationStep,

lib/src/widgets/yaru_close_button.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ class YaruCloseButton extends StatelessWidget {
1111
this.enabled = true,
1212
this.onPressed,
1313
this.alignment = Alignment.center,
14+
this.icon,
1415
});
1516

1617
final bool enabled;
1718
final VoidCallback? onPressed;
1819
final AlignmentGeometry alignment;
20+
final Widget? icon;
1921

2022
@override
2123
Widget build(BuildContext context) {
@@ -24,7 +26,7 @@ class YaruCloseButton extends StatelessWidget {
2426
child: YaruIconButton(
2527
padding: EdgeInsets.zero,
2628
onPressed: enabled ? onPressed ?? Navigator.of(context).maybePop : null,
27-
icon: const Icon(YaruIcons.window_close),
29+
icon: icon ?? const Icon(YaruIcons.window_close),
2830
iconSize: _kCloseButtonSize,
2931
),
3032
);

lib/src/widgets/yaru_expansion_panel.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class YaruExpansionPanel extends StatefulWidget {
1717
this.headerPadding = const EdgeInsets.only(left: 20),
1818
this.color,
1919
this.placeDividers = true,
20+
this.expandIcon,
2021
});
2122

2223
final List<Widget> children;
@@ -29,6 +30,7 @@ class YaruExpansionPanel extends StatefulWidget {
2930
final EdgeInsetsGeometry headerPadding;
3031
final Color? color;
3132
final bool placeDividers;
33+
final Widget? expandIcon;
3234

3335
@override
3436
State<YaruExpansionPanel> createState() => _YaruExpansionPanelState();
@@ -60,6 +62,7 @@ class _YaruExpansionPanelState extends State<YaruExpansionPanel> {
6062
Column(
6163
children: [
6264
YaruExpandable(
65+
expandIcon: widget.expandIcon,
6366
expandIconPadding: widget.expandIconPadding,
6467
isExpanded: _expandedStore[index],
6568
onChange: (_) {

lib/src/widgets/yaru_popup_menu_button.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class YaruPopupMenuButton<T> extends StatelessWidget {
2424
this.elevation,
2525
this.style,
2626
this.mouseCursor,
27+
this.icon,
2728
});
2829

2930
final T? initialValue;
@@ -42,6 +43,7 @@ class YaruPopupMenuButton<T> extends StatelessWidget {
4243
final double? elevation;
4344
final ButtonStyle? style;
4445
final MouseCursor? mouseCursor;
46+
final Widget? icon;
4547

4648
@override
4749
Widget build(BuildContext context) {
@@ -96,12 +98,13 @@ class YaruPopupMenuButton<T> extends StatelessWidget {
9698
padding: childPadding,
9799
child: child,
98100
),
99-
const SizedBox(
101+
SizedBox(
100102
height: 40,
101-
child: Icon(
102-
YaruIcons.pan_down,
103-
size: 20,
104-
),
103+
child: icon ??
104+
const Icon(
105+
YaruIcons.pan_down,
106+
size: 20,
107+
),
105108
),
106109
],
107110
),

lib/src/widgets/yaru_search_field.dart

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class YaruSearchField extends StatefulWidget {
2929
this.fillColor,
3030
this.controller,
3131
this.focusNode,
32+
this.clearIcon,
3233
});
3334

3435
/// Optional [String] forwarded to the internal [TextEditingController]
@@ -75,6 +76,9 @@ class YaruSearchField extends StatefulWidget {
7576
/// Optional [FocusNode] for the internal [KeyboardListener]
7677
final FocusNode? focusNode;
7778

79+
/// Optional icon shown inside the clear button.
80+
final Widget? clearIcon;
81+
7882
@override
7983
State<YaruSearchField> createState() => _YaruSearchFieldState();
8084
}
@@ -179,9 +183,10 @@ class _YaruSearchFieldState extends State<YaruSearchField> {
179183
onPressed: _clear,
180184
icon: ClipRRect(
181185
borderRadius: suffixRadius,
182-
child: const Icon(
183-
YaruIcons.edit_clear,
184-
),
186+
child: widget.clearIcon ??
187+
const Icon(
188+
YaruIcons.edit_clear,
189+
),
185190
),
186191
),
187192
),
@@ -216,6 +221,8 @@ class YaruSearchTitleField extends StatefulWidget {
216221
this.style = YaruSearchFieldStyle.filled,
217222
this.controller,
218223
this.focusNode,
224+
this.searchIcon,
225+
this.clearIcon,
219226
});
220227

221228
final bool searchActive;
@@ -239,6 +246,10 @@ class YaruSearchTitleField extends StatefulWidget {
239246
/// Optional [FocusNode] for the internal [KeyboardListener]
240247
final FocusNode? focusNode;
241248

249+
final Widget? searchIcon;
250+
251+
final Widget? clearIcon;
252+
242253
@override
243254
State<YaruSearchTitleField> createState() => _YaruSearchTitleFieldState();
244255
}
@@ -273,6 +284,7 @@ class _YaruSearchTitleFieldState extends State<YaruSearchTitleField> {
273284
child: SizedBox(
274285
height: kYaruTitleBarItemHeight,
275286
child: YaruSearchField(
287+
clearIcon: widget.clearIcon,
276288
focusNode: widget.focusNode,
277289
controller: widget.controller,
278290
text: widget.text,
@@ -302,6 +314,8 @@ class _YaruSearchTitleFieldState extends State<YaruSearchTitleField> {
302314
),
303315
),
304316
YaruSearchButton(
317+
icon: widget.searchIcon,
318+
selectedIcon: widget.searchIcon,
305319
style: widget.style == YaruSearchFieldStyle.outlined
306320
? widget.style
307321
: YaruSearchFieldStyle.filled,
@@ -329,6 +343,8 @@ class YaruSearchButton extends StatelessWidget {
329343
this.radius = const Radius.circular(kYaruTitleBarItemHeight),
330344
this.style = YaruSearchFieldStyle.filled,
331345
this.borderColor,
346+
this.icon,
347+
this.selectedIcon,
332348
});
333349

334350
final bool? searchActive;
@@ -337,6 +353,8 @@ class YaruSearchButton extends StatelessWidget {
337353
final Radius radius;
338354
final YaruSearchFieldStyle style;
339355
final Color? borderColor;
356+
final Widget? icon;
357+
final Widget? selectedIcon;
340358

341359
@override
342360
Widget build(BuildContext context) {
@@ -363,16 +381,18 @@ class YaruSearchButton extends StatelessWidget {
363381
),
364382
),
365383
isSelected: searchActive,
366-
selectedIcon: Icon(
367-
YaruIcons.search,
368-
size: kYaruIconSize,
369-
color: theme.colorScheme.onSurface,
370-
),
371-
icon: Icon(
372-
YaruIcons.search,
373-
size: kYaruIconSize,
374-
color: theme.colorScheme.onSurface,
375-
),
384+
selectedIcon: selectedIcon ??
385+
Icon(
386+
YaruIcons.search,
387+
size: kYaruIconSize,
388+
color: theme.colorScheme.onSurface,
389+
),
390+
icon: icon ??
391+
Icon(
392+
YaruIcons.search,
393+
size: kYaruIconSize,
394+
color: theme.colorScheme.onSurface,
395+
),
376396
onPressed: onPressed,
377397
),
378398
),

0 commit comments

Comments
 (0)