Skip to content

Commit

Permalink
Merge pull request #740 from ubuntu/Feichtmeier/issue739
Browse files Browse the repository at this point in the history
fix: add the missing optional icon parameters
  • Loading branch information
Feichtmeier authored Jul 29, 2023
2 parents 6e334ab + 2eb78e2 commit 47d3357
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 22 deletions.
7 changes: 6 additions & 1 deletion lib/src/widgets/yaru_back_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class YaruBackButton extends StatelessWidget {
super.key,
this.onPressed,
this.style,
this.icon,
});

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

/// Optional icon used inside the [YaruIconButton]
/// Defaults to `const Icon(YaruIcons.go_previous)`
final Widget? icon;

@override
Widget build(BuildContext context) {
final theme = YaruBackButtonTheme.of(context);
final round = (style ?? theme?.style) == YaruBackButtonStyle.rounded;
final shape = round ? const CircleBorder() : const BeveledRectangleBorder();
final button = YaruIconButton(
icon: const Icon(YaruIcons.go_previous),
icon: icon ?? const Icon(YaruIcons.go_previous),
style: ButtonStyle(
shape: ButtonStyleButton.allOrNull(shape),
),
Expand Down
10 changes: 8 additions & 2 deletions lib/src/widgets/yaru_choice_chip_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class YaruChoiceChipBar extends StatefulWidget {
this.wrapVerticalDirection = VerticalDirection.down,
this.wrapClipBehavior = Clip.none,
this.wrapTextDirection,
this.goPreviousIcon,
this.goNextIcon,
}) : assert(labels.length == isSelected.length);

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

final Widget? goPreviousIcon;

final Widget? goNextIcon;

@override
State<YaruChoiceChipBar> createState() => _YaruChoiceChipBarState();
}
Expand Down Expand Up @@ -180,7 +186,7 @@ class _YaruChoiceChipBarState extends State<YaruChoiceChipBar> {
final goPreviousButton = _NavigationButton(
radius: widget.radius,
chipHeight: widget.chipHeight,
icon: const Icon(YaruIcons.go_previous),
icon: widget.goPreviousIcon ?? const Icon(YaruIcons.go_previous),
onTap: _enableGoPreviousButton
? () => _controller.animateTo(
_controller.position.pixels - widget.navigationStep,
Expand All @@ -193,7 +199,7 @@ class _YaruChoiceChipBarState extends State<YaruChoiceChipBar> {
final goNextButton = _NavigationButton(
chipHeight: widget.chipHeight,
radius: widget.radius,
icon: const Icon(YaruIcons.go_next),
icon: widget.goNextIcon ?? const Icon(YaruIcons.go_next),
onTap: _enableGoNextButton
? () => _controller.animateTo(
_controller.position.pixels + widget.navigationStep,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/widgets/yaru_close_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class YaruCloseButton extends StatelessWidget {
this.enabled = true,
this.onPressed,
this.alignment = Alignment.center,
this.icon,
});

final bool enabled;
final VoidCallback? onPressed;
final AlignmentGeometry alignment;
final Widget? icon;

@override
Widget build(BuildContext context) {
Expand All @@ -24,7 +26,7 @@ class YaruCloseButton extends StatelessWidget {
child: YaruIconButton(
padding: EdgeInsets.zero,
onPressed: enabled ? onPressed ?? Navigator.of(context).maybePop : null,
icon: const Icon(YaruIcons.window_close),
icon: icon ?? const Icon(YaruIcons.window_close),
iconSize: _kCloseButtonSize,
),
);
Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/yaru_expansion_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class YaruExpansionPanel extends StatefulWidget {
this.headerPadding = const EdgeInsets.only(left: 20),
this.color,
this.placeDividers = true,
this.expandIcon,
});

final List<Widget> children;
Expand All @@ -29,6 +30,7 @@ class YaruExpansionPanel extends StatefulWidget {
final EdgeInsetsGeometry headerPadding;
final Color? color;
final bool placeDividers;
final Widget? expandIcon;

@override
State<YaruExpansionPanel> createState() => _YaruExpansionPanelState();
Expand Down Expand Up @@ -60,6 +62,7 @@ class _YaruExpansionPanelState extends State<YaruExpansionPanel> {
Column(
children: [
YaruExpandable(
expandIcon: widget.expandIcon,
expandIconPadding: widget.expandIconPadding,
isExpanded: _expandedStore[index],
onChange: (_) {
Expand Down
13 changes: 8 additions & 5 deletions lib/src/widgets/yaru_popup_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class YaruPopupMenuButton<T> extends StatelessWidget {
this.elevation,
this.style,
this.mouseCursor,
this.icon,
});

final T? initialValue;
Expand All @@ -42,6 +43,7 @@ class YaruPopupMenuButton<T> extends StatelessWidget {
final double? elevation;
final ButtonStyle? style;
final MouseCursor? mouseCursor;
final Widget? icon;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -96,12 +98,13 @@ class YaruPopupMenuButton<T> extends StatelessWidget {
padding: childPadding,
child: child,
),
const SizedBox(
SizedBox(
height: 40,
child: Icon(
YaruIcons.pan_down,
size: 20,
),
child: icon ??
const Icon(
YaruIcons.pan_down,
size: 20,
),
),
],
),
Expand Down
46 changes: 33 additions & 13 deletions lib/src/widgets/yaru_search_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class YaruSearchField extends StatefulWidget {
this.fillColor,
this.controller,
this.focusNode,
this.clearIcon,
});

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

/// Optional icon shown inside the clear button.
final Widget? clearIcon;

@override
State<YaruSearchField> createState() => _YaruSearchFieldState();
}
Expand Down Expand Up @@ -179,9 +183,10 @@ class _YaruSearchFieldState extends State<YaruSearchField> {
onPressed: _clear,
icon: ClipRRect(
borderRadius: suffixRadius,
child: const Icon(
YaruIcons.edit_clear,
),
child: widget.clearIcon ??
const Icon(
YaruIcons.edit_clear,
),
),
),
),
Expand Down Expand Up @@ -216,6 +221,8 @@ class YaruSearchTitleField extends StatefulWidget {
this.style = YaruSearchFieldStyle.filled,
this.controller,
this.focusNode,
this.searchIcon,
this.clearIcon,
});

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

final Widget? searchIcon;

final Widget? clearIcon;

@override
State<YaruSearchTitleField> createState() => _YaruSearchTitleFieldState();
}
Expand Down Expand Up @@ -273,6 +284,7 @@ class _YaruSearchTitleFieldState extends State<YaruSearchTitleField> {
child: SizedBox(
height: kYaruTitleBarItemHeight,
child: YaruSearchField(
clearIcon: widget.clearIcon,
focusNode: widget.focusNode,
controller: widget.controller,
text: widget.text,
Expand Down Expand Up @@ -302,6 +314,8 @@ class _YaruSearchTitleFieldState extends State<YaruSearchTitleField> {
),
),
YaruSearchButton(
icon: widget.searchIcon,
selectedIcon: widget.searchIcon,
style: widget.style == YaruSearchFieldStyle.outlined
? widget.style
: YaruSearchFieldStyle.filled,
Expand Down Expand Up @@ -329,6 +343,8 @@ class YaruSearchButton extends StatelessWidget {
this.radius = const Radius.circular(kYaruTitleBarItemHeight),
this.style = YaruSearchFieldStyle.filled,
this.borderColor,
this.icon,
this.selectedIcon,
});

final bool? searchActive;
Expand All @@ -337,6 +353,8 @@ class YaruSearchButton extends StatelessWidget {
final Radius radius;
final YaruSearchFieldStyle style;
final Color? borderColor;
final Widget? icon;
final Widget? selectedIcon;

@override
Widget build(BuildContext context) {
Expand All @@ -363,16 +381,18 @@ class YaruSearchButton extends StatelessWidget {
),
),
isSelected: searchActive,
selectedIcon: Icon(
YaruIcons.search,
size: kYaruIconSize,
color: theme.colorScheme.onSurface,
),
icon: Icon(
YaruIcons.search,
size: kYaruIconSize,
color: theme.colorScheme.onSurface,
),
selectedIcon: selectedIcon ??
Icon(
YaruIcons.search,
size: kYaruIconSize,
color: theme.colorScheme.onSurface,
),
icon: icon ??
Icon(
YaruIcons.search,
size: kYaruIconSize,
color: theme.colorScheme.onSurface,
),
onPressed: onPressed,
),
),
Expand Down

0 comments on commit 47d3357

Please sign in to comment.