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

YaruBanner: add textoverflow parameters #173

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions lib/src/yaru_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class YaruBanner extends StatelessWidget {
this.url,
this.icon,
required this.fallbackIconData,
this.nameTextOverflow,
this.summaryTextOverflow,
}) : super(key: key);

/// The name of the card
Expand All @@ -26,11 +28,25 @@ class YaruBanner extends StatelessWidget {

/// An optional callback
final Function()? onTap;

/// The color used for the soft background tint.
/// If null [Theme]'s background color is used.
final Color? surfaceTintColor;

/// If true the [icon] will be displayed a second time, with small opacity.
final bool watermark;

/// The [Widget] used as the trailing icon.
final Widget? icon;

/// If the icon is not loaded this fallback icon is displayed.
final IconData fallbackIconData;

final TextOverflow? nameTextOverflow;

/// Optional [TextOverflow]
final TextOverflow? summaryTextOverflow;

@override
Widget build(BuildContext context) {
final borderRadius = BorderRadius.circular(10);
Expand All @@ -54,7 +70,9 @@ class YaruBanner extends StatelessWidget {
url: url,
fallBackIconData: fallbackIconData,
),
textOverflow: TextOverflow.fade,
titleTextOverflow: nameTextOverflow ?? TextOverflow.ellipsis,
subTitleTextOverflow:
summaryTextOverflow ?? TextOverflow.fade,
mouseCursor: onTap != null ? SystemMouseCursors.click : null,
),
if (watermark == true)
Expand Down Expand Up @@ -90,7 +108,9 @@ class YaruBanner extends StatelessWidget {
),
title: name,
summary: summary,
textOverflow: TextOverflow.ellipsis,
titleTextOverflow: summaryTextOverflow ?? TextOverflow.ellipsis,
subTitleTextOverflow:
summaryTextOverflow ?? TextOverflow.ellipsis,
mouseCursor: onTap != null ? SystemMouseCursors.click : null,
),
);
Expand All @@ -106,8 +126,9 @@ class _Banner extends StatelessWidget {
required this.elevation,
required this.icon,
required this.borderRadius,
required this.textOverflow,
required this.subTitleTextOverflow,
this.mouseCursor,
required this.titleTextOverflow,
}) : super(key: key);

final Color color;
Expand All @@ -116,7 +137,8 @@ class _Banner extends StatelessWidget {
final double elevation;
final Widget icon;
final BorderRadius borderRadius;
final TextOverflow textOverflow;
final TextOverflow subTitleTextOverflow;
final TextOverflow titleTextOverflow;
final MouseCursor? mouseCursor;

@override
Expand All @@ -136,7 +158,7 @@ class _Banner extends StatelessWidget {
child: ListTile(
mouseCursor: mouseCursor,
subtitle: summary != null && summary!.isNotEmpty
? Text(summary!, overflow: textOverflow)
? Text(summary!, overflow: subTitleTextOverflow)
: null,
title: Text(
title,
Expand Down