forked from cwtch.im/cwtch-ui
Show tooltip for links
This commit is contained in:
parent
1700306c78
commit
ca44fd798c
|
@ -353,20 +353,24 @@ TextSpan buildTextSpan(
|
||||||
(element) {
|
(element) {
|
||||||
if (element is LinkableElement) {
|
if (element is LinkableElement) {
|
||||||
if (useMouseRegion) {
|
if (useMouseRegion) {
|
||||||
return LinkableSpan(
|
return TooltipSpan(
|
||||||
mouseCursor: SystemMouseCursors.click,
|
message: element.url,
|
||||||
inlineSpan: TextSpan(
|
inlineSpan: LinkableSpan(
|
||||||
text: element.text,
|
mouseCursor: SystemMouseCursors.click,
|
||||||
style: linkStyle,
|
inlineSpan: TextSpan(
|
||||||
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
text: element.text,
|
||||||
),
|
style: linkStyle,
|
||||||
);
|
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
||||||
|
),
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
return TextSpan(
|
return TooltipSpan(
|
||||||
text: element.text,
|
message: element.url,
|
||||||
style: linkStyle,
|
inlineSpan: TextSpan(
|
||||||
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
text: element.text,
|
||||||
);
|
style: linkStyle,
|
||||||
|
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return TextSpan(
|
return TextSpan(
|
||||||
|
@ -378,3 +382,18 @@ TextSpan buildTextSpan(
|
||||||
).toList(),
|
).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show a tooltip over an inlined element in a Rich Text widget.
|
||||||
|
class TooltipSpan extends WidgetSpan {
|
||||||
|
TooltipSpan({
|
||||||
|
required String message,
|
||||||
|
required InlineSpan inlineSpan,
|
||||||
|
}) : super(
|
||||||
|
child: Tooltip(
|
||||||
|
message: message,
|
||||||
|
child: Text.rich(
|
||||||
|
inlineSpan,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue