fix: reenable token clicking after adding linkify spans (#1711)

pull/1593/head
ggurdin 9 months ago committed by GitHub
parent 0cce17d27b
commit 76a465f14f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,3 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
@ -222,22 +221,31 @@ class MessageTextWidget extends StatelessWidget {
), ),
); );
} }
return LinkifySpan( return WidgetSpan(
mouseCursor: SystemMouseCursors.click, child: MouseRegion(
recognizer: TapGestureRecognizer() cursor: SystemMouseCursors.click,
..onTap = child: GestureDetector(
onClick != null ? () => onClick?.call(tokenPosition) : null, onTap: onClick != null
text: substring, ? () => onClick?.call(tokenPosition)
style: style.merge( : null,
TextStyle( child: RichText(
backgroundColor: backgroundColor, 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 { } else {
if ((i > 0 || i < tokenPositions.length - 1) && if ((i > 0 || i < tokenPositions.length - 1) &&

Loading…
Cancel
Save