Allow Tor Caching + Our Own Linkify #316

Merged
erinn merged 7 commits from torcache into trunk 2022-01-18 23:06:25 +00:00
1 changed files with 32 additions and 13 deletions
Showing only changes of commit ca44fd798c - Show all commits

View File

@ -353,20 +353,24 @@ TextSpan buildTextSpan(
(element) {
if (element is LinkableElement) {
if (useMouseRegion) {
return LinkableSpan(
mouseCursor: SystemMouseCursors.click,
inlineSpan: TextSpan(
text: element.text,
style: linkStyle,
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
),
);
return TooltipSpan(
message: element.url,
inlineSpan: LinkableSpan(
mouseCursor: SystemMouseCursors.click,
inlineSpan: TextSpan(
text: element.text,
style: linkStyle,
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
),
));
} else {
return TextSpan(
text: element.text,
style: linkStyle,
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
);
return TooltipSpan(
message: element.url,
inlineSpan: TextSpan(
text: element.text,
style: linkStyle,
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
));
}
} else {
return TextSpan(
@ -378,3 +382,18 @@ TextSpan buildTextSpan(
).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,
),
),
);
}