From 99d36e1d74a7f109bfc6d467dbc67bfeef41ad1b Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 6 Jan 2020 20:36:11 +0100 Subject: [PATCH] Fix linktext --- lib/components/message_content.dart | 43 ++++++++++++++++++++++------- pubspec.yaml | 2 +- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/lib/components/message_content.dart b/lib/components/message_content.dart index 873791c..809adfd 100644 --- a/lib/components/message_content.dart +++ b/lib/components/message_content.dart @@ -3,6 +3,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:link_text/link_text.dart'; import 'package:url_launcher/url_launcher.dart'; import 'matrix.dart'; @@ -113,21 +114,43 @@ class MessageContent extends StatelessWidget { ? "You: " : "${event.sender.calcDisplayname()}: " : ""; - return Text( - senderPrefix + event.getBody(), - maxLines: maxLines, - overflow: textOnly ? TextOverflow.ellipsis : null, - style: TextStyle( + if (textOnly) { + return Text( + senderPrefix + event.getBody(), + maxLines: maxLines, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: textColor, + decoration: + event.redacted ? TextDecoration.lineThrough : null, + ), + ); + } + return LinkText( + text: senderPrefix + event.getBody(), + textStyle: TextStyle( color: textColor, decoration: event.redacted ? TextDecoration.lineThrough : null, ), ); + case MessageTypes.Emote: - return Text( - "* " + event.getBody(), - maxLines: maxLines, - overflow: textOnly ? TextOverflow.ellipsis : null, - style: TextStyle( + if (textOnly) { + return Text( + "* " + event.getBody(), + maxLines: maxLines, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: textColor, + fontStyle: FontStyle.italic, + decoration: + event.redacted ? TextDecoration.lineThrough : null, + ), + ); + } + return LinkText( + text: "* " + event.getBody(), + textStyle: TextStyle( color: textColor, fontStyle: FontStyle.italic, decoration: event.redacted ? TextDecoration.lineThrough : null, diff --git a/pubspec.yaml b/pubspec.yaml index 5b5294f..85f6b4c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Chat with your friends. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.2.0+10 +version: 0.2.1+11 environment: sdk: ">=2.1.0 <3.0.0"