Merge pull request #1452 from GetStream/ISSUE-1399/AddingCustomLineForTitleUrl

This commit is contained in:
Sahil Kumar
2023-02-09 15:54:00 +05:30
committed by GitHub
4 changed files with 28 additions and 4 deletions
@@ -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
@@ -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);
@@ -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),
@@ -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,
));
}
}