mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 23:14:18 +03:00
Merge PR #1527
This commit is contained in:
commit
0349b37065
@ -19,6 +19,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/state.dart';
|
||||
import '../../widgets/list_title.dart';
|
||||
import '../../widgets/tooltip_if_truncated.dart';
|
||||
import '../models.dart';
|
||||
|
||||
class ActionListItem extends StatelessWidget {
|
||||
@ -51,15 +52,26 @@ class ActionListItem extends StatelessWidget {
|
||||
// ActionStyle.primary => (theme.onPrimary, theme.primary),
|
||||
// ActionStyle.error => (theme.onError, theme.error),
|
||||
// };
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return ListTile(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(48)),
|
||||
title: Text(title),
|
||||
subtitle: subtitle != null ? Text(subtitle!) : null,
|
||||
title: TooltipIfTruncated(
|
||||
text: title,
|
||||
style: TextStyle(fontSize: theme.textTheme.bodyLarge!.fontSize),
|
||||
),
|
||||
subtitle: subtitle != null
|
||||
? TooltipIfTruncated(
|
||||
text: subtitle!,
|
||||
style: TextStyle(fontSize: theme.textTheme.bodyMedium!.fontSize),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)
|
||||
: null,
|
||||
leading: Opacity(
|
||||
opacity: onTap != null ? 1.0 : 0.4,
|
||||
child: CircleAvatar(
|
||||
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
foregroundColor: theme.colorScheme.onSurfaceVariant,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: icon,
|
||||
),
|
||||
|
@ -20,8 +20,15 @@ class TooltipIfTruncated extends StatelessWidget {
|
||||
final String text;
|
||||
final TextStyle style;
|
||||
final String? tooltip;
|
||||
final int maxLines;
|
||||
final TextOverflow overflow;
|
||||
const TooltipIfTruncated(
|
||||
{super.key, required this.text, required this.style, this.tooltip});
|
||||
{super.key,
|
||||
required this.text,
|
||||
required this.style,
|
||||
this.tooltip,
|
||||
this.maxLines = 1,
|
||||
this.overflow = TextOverflow.fade});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -30,14 +37,15 @@ class TooltipIfTruncated extends StatelessWidget {
|
||||
final textWidget = Text(
|
||||
text,
|
||||
textAlign: TextAlign.left,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
overflow: overflow,
|
||||
maxLines: maxLines,
|
||||
softWrap: maxLines != 1,
|
||||
style: style,
|
||||
);
|
||||
final TextPainter textPainter = TextPainter(
|
||||
text: TextSpan(text: text, style: style),
|
||||
textDirection: TextDirection.ltr,
|
||||
maxLines: 1,
|
||||
maxLines: maxLines,
|
||||
)..layout(minWidth: 0, maxWidth: constraints.maxWidth);
|
||||
return textPainter.didExceedMaxLines
|
||||
? Tooltip(
|
||||
|
Loading…
Reference in New Issue
Block a user