From 76a465f14fad47e8c6b632bd6eaae07fa6dccf82 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Wed, 5 Feb 2025 12:03:52 -0500 Subject: [PATCH] fix: reenable token clicking after adding linkify spans (#1711) --- .../toolbar/widgets/message_token_text.dart | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/pangea/toolbar/widgets/message_token_text.dart b/lib/pangea/toolbar/widgets/message_token_text.dart index 1ca0cfe74..8ba366f7a 100644 --- a/lib/pangea/toolbar/widgets/message_token_text.dart +++ b/lib/pangea/toolbar/widgets/message_token_text.dart @@ -1,4 +1,3 @@ -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:collection/collection.dart'; @@ -222,22 +221,31 @@ class MessageTextWidget extends StatelessWidget { ), ); } - return LinkifySpan( - mouseCursor: SystemMouseCursors.click, - recognizer: TapGestureRecognizer() - ..onTap = - onClick != null ? () => onClick?.call(tokenPosition) : null, - text: substring, - style: style.merge( - TextStyle( - backgroundColor: backgroundColor, + return WidgetSpan( + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: onClick != null + ? () => onClick?.call(tokenPosition) + : null, + child: RichText( + text: LinkifySpan( + text: substring, + style: style.merge( + TextStyle( + backgroundColor: backgroundColor, + ), + ), + linkStyle: TextStyle( + decoration: TextDecoration.underline, + color: Theme.of(context).colorScheme.primary, + ), + onOpen: (url) => + UrlLauncher(context, url.url).launchUrl(), + ), + ), ), ), - linkStyle: TextStyle( - decoration: TextDecoration.underline, - color: Theme.of(context).colorScheme.primary, - ), - onOpen: (url) => UrlLauncher(context, url.url).launchUrl(), ); } else { if ((i > 0 || i < tokenPositions.length - 1) &&