Skip to content

Commit

Permalink
fix: reenable token clicking after adding linkify spans (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggurdin authored Feb 5, 2025
1 parent 0cce17d commit 76a465f
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lib/pangea/toolbar/widgets/message_token_text.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

import 'package:collection/collection.dart';
Expand Down Expand Up @@ -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) &&
Expand Down

0 comments on commit 76a465f

Please sign in to comment.