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

fix(YaruChoiceChipBar): forward parameters to buttons #829

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/src/widgets/yaru_choice_chip_bar.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';
import 'package:yaru_icons/yaru_icons.dart';
import 'package:yaru_widgets/constants.dart';

Expand Down Expand Up @@ -33,6 +34,7 @@ class YaruChoiceChipBar extends StatefulWidget {
this.borderColor,
this.chipBackgroundColor,
this.selectedChipBackgroundColor,
this.navigationButtonElevation,
}) : assert(labels.length == isSelected.length);

/// The [List] of [Widget]'s used to generate a [List] of [ChoiceChip]s
Expand Down Expand Up @@ -79,6 +81,9 @@ class YaruChoiceChipBar extends StatefulWidget {
/// Defaults to `Theme.of(context).chipTheme.selectedColor`
final Color? selectedChipBackgroundColor;

/// The optional elevation of the navigation buttons. Defaults to 0.
final double? navigationButtonElevation;

/// Sets how high the whole bar is.
final double chipHeight;

Expand Down Expand Up @@ -239,6 +244,9 @@ class _YaruChoiceChipBarState extends State<YaruChoiceChipBar> {
);

final goPreviousButton = _NavigationButton(
elevation: widget.navigationButtonElevation,
borderColor: widget.borderColor,
chipBackgroundColor: widget.chipBackgroundColor,
radius: widget.radius,
chipHeight: widget.chipHeight,
icon: widget.goPreviousIcon ?? const Icon(YaruIcons.go_previous),
Expand All @@ -252,6 +260,9 @@ class _YaruChoiceChipBarState extends State<YaruChoiceChipBar> {
);

final goNextButton = _NavigationButton(
elevation: widget.navigationButtonElevation,
borderColor: widget.borderColor,
chipBackgroundColor: widget.chipBackgroundColor,
chipHeight: widget.chipHeight,
radius: widget.radius,
icon: widget.goNextIcon ?? const Icon(YaruIcons.go_next),
Expand Down Expand Up @@ -342,20 +353,26 @@ class _NavigationButton extends StatelessWidget {
required this.icon,
required this.radius,
required this.chipHeight,
this.borderColor,
this.chipBackgroundColor,
this.elevation,
});

final Function()? onTap;
final Widget icon;
final double radius;
final double chipHeight;
final Color? borderColor;
final Color? chipBackgroundColor;
final double? elevation;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final roundedRectangleBorder = RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
side: BorderSide(
color: theme.colorScheme.outline,
color: borderColor ?? theme.colorScheme.outline,
width: 1,
),
);
Expand All @@ -365,6 +382,8 @@ class _NavigationButton extends StatelessWidget {
width: chipHeight,
child: Material(
shape: roundedRectangleBorder,
color: chipBackgroundColor?.scale(lightness: 0.1),
elevation: elevation ?? 0.0,
child: InkWell(
customBorder: roundedRectangleBorder,
onTap: onTap,
Expand Down