mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-08 17:53:25 +10:00
Fix for right-click on message bubbles (right click didn't work on the actual text of the bubble)
This commit is contained in:
@@ -20,6 +20,7 @@ class LinkHandler {
|
|||||||
required String text,
|
required String text,
|
||||||
required TextStyle style,
|
required TextStyle style,
|
||||||
TextStyle? linkStyle,
|
TextStyle? linkStyle,
|
||||||
|
VoidCallback? onSecondaryTap,
|
||||||
}) {
|
}) {
|
||||||
final effectiveLinkStyle = linkStyle ?? defaultLinkStyle(context, style);
|
final effectiveLinkStyle = linkStyle ?? defaultLinkStyle(context, style);
|
||||||
const options = LinkifyOptions(humanize: false, defaultToHttps: false);
|
const options = LinkifyOptions(humanize: false, defaultToHttps: false);
|
||||||
@@ -27,7 +28,7 @@ class LinkHandler {
|
|||||||
void onOpen(LinkableElement link) => handleLinkTap(context, link.url);
|
void onOpen(LinkableElement link) => handleLinkTap(context, link.url);
|
||||||
|
|
||||||
if (PlatformInfo.isDesktop) {
|
if (PlatformInfo.isDesktop) {
|
||||||
return SelectableLinkify(
|
final linkify = SelectableLinkify(
|
||||||
text: text,
|
text: text,
|
||||||
style: style,
|
style: style,
|
||||||
linkStyle: effectiveLinkStyle,
|
linkStyle: effectiveLinkStyle,
|
||||||
@@ -35,6 +36,14 @@ class LinkHandler {
|
|||||||
linkifiers: linkifiers,
|
linkifiers: linkifiers,
|
||||||
onOpen: onOpen,
|
onOpen: onOpen,
|
||||||
);
|
);
|
||||||
|
if (onSecondaryTap == null) return linkify;
|
||||||
|
return Listener(
|
||||||
|
onPointerDown: (event) {
|
||||||
|
if (event.buttons == 2) onSecondaryTap();
|
||||||
|
},
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
|
child: linkify,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return Linkify(
|
return Linkify(
|
||||||
text: text,
|
text: text,
|
||||||
|
|||||||
@@ -646,6 +646,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
color: textColor.withValues(alpha: 0.72),
|
color: textColor.withValues(alpha: 0.72),
|
||||||
),
|
),
|
||||||
|
onSecondaryTap: PlatformInfo.isDesktop
|
||||||
|
? () => _showMessageActions(message)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1435,6 +1435,9 @@ class _MessageBubble extends StatelessWidget {
|
|||||||
color: textColor.withValues(alpha: 0.72),
|
color: textColor.withValues(alpha: 0.72),
|
||||||
fontSize: bodyFontSize * textScale,
|
fontSize: bodyFontSize * textScale,
|
||||||
),
|
),
|
||||||
|
onSecondaryTap: PlatformInfo.isDesktop
|
||||||
|
? onLongPress
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class TranslatedMessageContent extends StatelessWidget {
|
|||||||
final TextStyle style;
|
final TextStyle style;
|
||||||
final TextStyle? originalStyle;
|
final TextStyle? originalStyle;
|
||||||
final bool showOriginalFirst;
|
final bool showOriginalFirst;
|
||||||
|
final VoidCallback? onSecondaryTap;
|
||||||
|
|
||||||
const TranslatedMessageContent({
|
const TranslatedMessageContent({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -16,6 +17,7 @@ class TranslatedMessageContent extends StatelessWidget {
|
|||||||
this.originalText,
|
this.originalText,
|
||||||
this.originalStyle,
|
this.originalStyle,
|
||||||
this.showOriginalFirst = true,
|
this.showOriginalFirst = true,
|
||||||
|
this.onSecondaryTap,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -36,12 +38,14 @@ class TranslatedMessageContent extends StatelessWidget {
|
|||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
fontSize: style.fontSize,
|
fontSize: style.fontSize,
|
||||||
),
|
),
|
||||||
|
onSecondaryTap: onSecondaryTap,
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
final translatedWidget = LinkHandler.buildLinkifyText(
|
final translatedWidget = LinkHandler.buildLinkifyText(
|
||||||
context: context,
|
context: context,
|
||||||
text: trimmedDisplay,
|
text: trimmedDisplay,
|
||||||
style: style,
|
style: style,
|
||||||
|
onSecondaryTap: onSecondaryTap,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!shouldShowOriginal) {
|
if (!shouldShowOriginal) {
|
||||||
|
|||||||
Reference in New Issue
Block a user