Adding custom line for url attachment
This commit is contained in:
@@ -74,6 +74,9 @@ class MyApp extends StatelessWidget {
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
ownMessageTheme: const StreamMessageThemeData(
|
||||
urlLinkTitleMaxLine: 1,
|
||||
),
|
||||
otherMessageTheme: StreamMessageThemeData(
|
||||
messageBackgroundColor: colorTheme.textHighEmphasis,
|
||||
messageTextStyle: TextStyle(
|
||||
@@ -82,6 +85,7 @@ class MyApp extends StatelessWidget {
|
||||
avatarTheme: StreamAvatarThemeData(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
urlLinkTitleMaxLine: 1,
|
||||
),
|
||||
).merge(defaultTheme);
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class StreamUrlAttachment extends StatelessWidget {
|
||||
if (urlAttachment.title != null)
|
||||
Text(
|
||||
urlAttachment.title!.trim(),
|
||||
maxLines: 1,
|
||||
maxLines: messageTheme.urlLinkTitleMaxLine ?? 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.urlLinkTitleMaxLine,
|
||||
});
|
||||
|
||||
/// 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? urlLinkTitleMaxLine;
|
||||
|
||||
/// 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,7 @@ class StreamMessageThemeData with Diagnosticable {
|
||||
reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor,
|
||||
reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor,
|
||||
linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor,
|
||||
urlLinkTitleMaxLine: urlLinkTitleMaxLine ?? this.urlLinkTitleMaxLine,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -148,6 +154,7 @@ class StreamMessageThemeData with Diagnosticable {
|
||||
reactionsBorderColor: other.reactionsBorderColor,
|
||||
reactionsMaskColor: other.reactionsMaskColor,
|
||||
linkBackgroundColor: other.linkBackgroundColor,
|
||||
urlLinkTitleMaxLine: other.urlLinkTitleMaxLine,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -167,7 +174,8 @@ class StreamMessageThemeData with Diagnosticable {
|
||||
reactionsBorderColor == other.reactionsBorderColor &&
|
||||
reactionsMaskColor == other.reactionsMaskColor &&
|
||||
avatarTheme == other.avatarTheme &&
|
||||
linkBackgroundColor == other.linkBackgroundColor;
|
||||
linkBackgroundColor == other.linkBackgroundColor &&
|
||||
urlLinkTitleMaxLine == other.urlLinkTitleMaxLine;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
@@ -182,7 +190,8 @@ class StreamMessageThemeData with Diagnosticable {
|
||||
reactionsBorderColor.hashCode ^
|
||||
reactionsMaskColor.hashCode ^
|
||||
avatarTheme.hashCode ^
|
||||
linkBackgroundColor.hashCode;
|
||||
linkBackgroundColor.hashCode ^
|
||||
urlLinkTitleMaxLine.hashCode;
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
@@ -199,6 +208,7 @@ 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('urlLinkTitleMaxLine', urlLinkTitleMaxLine));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user