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

Add YaruBanner.selected property #596

Merged
merged 1 commit into from
Feb 5, 2023
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
12 changes: 11 additions & 1 deletion lib/src/widgets/yaru_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class YaruBanner extends StatelessWidget {
required this.child,
this.padding = const EdgeInsets.all(kYaruPagePadding),
this.onHover,
this.selected,
});

/// Creates a banner with a [YaruTile] child widget.
Expand All @@ -30,6 +31,7 @@ class YaruBanner extends StatelessWidget {
Widget? icon,
Widget? subtitle,
EdgeInsetsGeometry padding = const EdgeInsets.all(kYaruPagePadding),
bool? selected,
}) : this(
key: key,
onTap: onTap,
Expand All @@ -38,6 +40,7 @@ class YaruBanner extends StatelessWidget {
color: color,
elevation: elevation,
surfaceTintColor: surfaceTintColor,
selected: selected,
child: YaruTile(
leading: icon,
title: title,
Expand Down Expand Up @@ -70,6 +73,10 @@ class YaruBanner extends StatelessWidget {
/// Padding for the banner content. Defaults to `EdgeInsets.all(kYaruPagePadding)`
final EdgeInsetsGeometry padding;

/// Whether the banner is selected. A selected banner is highlighted with the
/// theme's primary color.
final bool? selected;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
Expand All @@ -80,7 +87,10 @@ class YaruBanner extends StatelessWidget {
final defaultSurfaceTintColor =
light ? theme.cardColor : const Color.fromARGB(255, 126, 126, 126);
return Material(
color: Colors.transparent,
color: selected == true
? theme.primaryColor.withOpacity(0.8)
: Colors.transparent,
borderRadius: borderRadius,
child: InkWell(
onTap: onTap,
onHover: onHover,
Expand Down