diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 7d7b1498..532bc755 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,5 +1,11 @@ ## Upcoming +✅ Added + +- Now it is possible to customize the max lines of the title of a url attachment. Before it was always 1 line. + +🔄 Changed + - Updated `share_plus` dependency to `^6.3.0` ## 5.3.0 diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart index cd80af44..dca8eaa1 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart @@ -74,6 +74,9 @@ class MyApp extends StatelessWidget { fit: BoxFit.cover, ), ), + ownMessageTheme: const StreamMessageThemeData( + urlAttachmentTitleMaxLine: 1, + ), otherMessageTheme: StreamMessageThemeData( messageBackgroundColor: colorTheme.textHighEmphasis, messageTextStyle: TextStyle( @@ -82,6 +85,7 @@ class MyApp extends StatelessWidget { avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(8), ), + urlAttachmentTitleMaxLine: 1, ), ).merge(defaultTheme); diff --git a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart index ce166195..10170bb1 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart @@ -107,7 +107,7 @@ class StreamUrlAttachment extends StatelessWidget { if (urlAttachment.title != null) Text( urlAttachment.title!.trim(), - maxLines: 1, + maxLines: messageTheme.urlAttachmentTitleMaxLine ?? 1, overflow: TextOverflow.ellipsis, style: chatThemeData.textTheme.body .copyWith(fontWeight: FontWeight.w700), diff --git a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart index f83971f2..7f34800c 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart @@ -21,6 +21,7 @@ class StreamMessageThemeData with Diagnosticable { this.avatarTheme, this.createdAtStyle, this.linkBackgroundColor, + this.urlAttachmentTitleMaxLine, }); /// Text style for message text @@ -59,6 +60,9 @@ class StreamMessageThemeData with Diagnosticable { /// Background color for messages with url attachments. final Color? linkBackgroundColor; + /// Max number of lines in Url link title + final int? urlAttachmentTitleMaxLine; + /// Copy with a theme StreamMessageThemeData copyWith({ TextStyle? messageTextStyle, @@ -73,6 +77,7 @@ class StreamMessageThemeData with Diagnosticable { Color? reactionsBorderColor, Color? reactionsMaskColor, Color? linkBackgroundColor, + int? urlLinkTitleMaxLine, }) { return StreamMessageThemeData( messageTextStyle: messageTextStyle ?? this.messageTextStyle, @@ -89,6 +94,8 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor, reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor, linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor, + urlAttachmentTitleMaxLine: + urlLinkTitleMaxLine ?? this.urlAttachmentTitleMaxLine, ); } @@ -148,6 +155,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor: other.reactionsBorderColor, reactionsMaskColor: other.reactionsMaskColor, linkBackgroundColor: other.linkBackgroundColor, + urlLinkTitleMaxLine: other.urlAttachmentTitleMaxLine, ); } @@ -167,7 +175,8 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor == other.reactionsBorderColor && reactionsMaskColor == other.reactionsMaskColor && avatarTheme == other.avatarTheme && - linkBackgroundColor == other.linkBackgroundColor; + linkBackgroundColor == other.linkBackgroundColor && + urlAttachmentTitleMaxLine == other.urlAttachmentTitleMaxLine; @override int get hashCode => @@ -182,7 +191,8 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor.hashCode ^ reactionsMaskColor.hashCode ^ avatarTheme.hashCode ^ - linkBackgroundColor.hashCode; + linkBackgroundColor.hashCode ^ + urlAttachmentTitleMaxLine.hashCode; @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { @@ -199,6 +209,10 @@ class StreamMessageThemeData with Diagnosticable { ..add(ColorProperty('reactionsBackgroundColor', reactionsBackgroundColor)) ..add(ColorProperty('reactionsBorderColor', reactionsBorderColor)) ..add(ColorProperty('reactionsMaskColor', reactionsMaskColor)) - ..add(ColorProperty('linkBackgroundColor', linkBackgroundColor)); + ..add(ColorProperty('linkBackgroundColor', linkBackgroundColor)) + ..add(DiagnosticsProperty( + 'urlAttachmentTitleMaxLine', + urlAttachmentTitleMaxLine, + )); } }