feat(ui): add support for StreamMessageThemeData.urlAttachmentTextMaxLine.
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -91,7 +91,7 @@ class StreamUrlAttachment extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
bottom: -1,
|
bottom: 0,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
@@ -103,7 +103,8 @@ class StreamUrlAttachment extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
top: 8,
|
top: 8,
|
||||||
left: 8,
|
left: 8,
|
||||||
right: 8,
|
right: 12,
|
||||||
|
bottom: 4,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
hostDisplayName,
|
hostDisplayName,
|
||||||
@@ -119,20 +120,40 @@ class StreamUrlAttachment extends StatelessWidget {
|
|||||||
padding: textPadding,
|
padding: textPadding,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: <Widget>[
|
||||||
if (urlAttachment.title != null)
|
if (urlAttachment.title != null)
|
||||||
Text(
|
Builder(builder: (context) {
|
||||||
urlAttachment.title!.trim(),
|
final maxLines = messageTheme.urlAttachmentTitleMaxLine;
|
||||||
maxLines: messageTheme.urlAttachmentTitleMaxLine ?? 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
TextOverflow? overflow;
|
||||||
style: messageTheme.urlAttachmentTitleStyle,
|
if (maxLines != null && maxLines > 0) {
|
||||||
),
|
overflow = TextOverflow.ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Text(
|
||||||
|
urlAttachment.title!.trim(),
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: overflow,
|
||||||
|
style: messageTheme.urlAttachmentTitleStyle,
|
||||||
|
);
|
||||||
|
}),
|
||||||
if (urlAttachment.text != null)
|
if (urlAttachment.text != null)
|
||||||
Text(
|
Builder(builder: (context) {
|
||||||
urlAttachment.text!,
|
final maxLines = messageTheme.urlAttachmentTextMaxLine;
|
||||||
style: messageTheme.urlAttachmentTextStyle,
|
|
||||||
),
|
TextOverflow? overflow;
|
||||||
],
|
if (maxLines != null && maxLines > 0) {
|
||||||
|
overflow = TextOverflow.ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Text(
|
||||||
|
urlAttachment.text!,
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: overflow,
|
||||||
|
style: messageTheme.urlAttachmentTextStyle,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
].insertBetween(const SizedBox(height: 4)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class StreamColorTheme {
|
|||||||
this.appBg = const Color(0xff070A0D),
|
this.appBg = const Color(0xff070A0D),
|
||||||
this.barsBg = const Color(0xff101418),
|
this.barsBg = const Color(0xff101418),
|
||||||
this.linkBg = const Color(0xff00193D),
|
this.linkBg = const Color(0xff00193D),
|
||||||
this.accentPrimary = const Color(0xff005FFF),
|
this.accentPrimary = const Color(0xff337eff),
|
||||||
this.accentError = const Color(0xffFF3742),
|
this.accentError = const Color(0xffFF3742),
|
||||||
this.accentInfo = const Color(0xff20E070),
|
this.accentInfo = const Color(0xff20E070),
|
||||||
this.borderTop = const Effect(
|
this.borderTop = const Effect(
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
this.urlAttachmentTitleStyle,
|
this.urlAttachmentTitleStyle,
|
||||||
this.urlAttachmentTextStyle,
|
this.urlAttachmentTextStyle,
|
||||||
this.urlAttachmentTitleMaxLine,
|
this.urlAttachmentTitleMaxLine,
|
||||||
|
this.urlAttachmentTextMaxLine,
|
||||||
}) : urlAttachmentBackgroundColor =
|
}) : urlAttachmentBackgroundColor =
|
||||||
urlAttachmentBackgroundColor ?? linkBackgroundColor;
|
urlAttachmentBackgroundColor ?? linkBackgroundColor;
|
||||||
|
|
||||||
@@ -82,6 +83,9 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
/// Max number of lines in Url link title.
|
/// Max number of lines in Url link title.
|
||||||
final int? urlAttachmentTitleMaxLine;
|
final int? urlAttachmentTitleMaxLine;
|
||||||
|
|
||||||
|
/// Max number of lines in Url link text.
|
||||||
|
final int? urlAttachmentTextMaxLine;
|
||||||
|
|
||||||
/// Copy with a theme
|
/// Copy with a theme
|
||||||
StreamMessageThemeData copyWith({
|
StreamMessageThemeData copyWith({
|
||||||
TextStyle? messageTextStyle,
|
TextStyle? messageTextStyle,
|
||||||
@@ -102,6 +106,7 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
TextStyle? urlAttachmentTitleStyle,
|
TextStyle? urlAttachmentTitleStyle,
|
||||||
TextStyle? urlAttachmentTextStyle,
|
TextStyle? urlAttachmentTextStyle,
|
||||||
int? urlAttachmentTitleMaxLine,
|
int? urlAttachmentTitleMaxLine,
|
||||||
|
int? urlAttachmentTextMaxLine,
|
||||||
}) {
|
}) {
|
||||||
return StreamMessageThemeData(
|
return StreamMessageThemeData(
|
||||||
messageTextStyle: messageTextStyle ?? this.messageTextStyle,
|
messageTextStyle: messageTextStyle ?? this.messageTextStyle,
|
||||||
@@ -128,6 +133,8 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
urlAttachmentTextStyle ?? this.urlAttachmentTextStyle,
|
urlAttachmentTextStyle ?? this.urlAttachmentTextStyle,
|
||||||
urlAttachmentTitleMaxLine:
|
urlAttachmentTitleMaxLine:
|
||||||
urlAttachmentTitleMaxLine ?? this.urlAttachmentTitleMaxLine,
|
urlAttachmentTitleMaxLine ?? this.urlAttachmentTitleMaxLine,
|
||||||
|
urlAttachmentTextMaxLine:
|
||||||
|
urlAttachmentTextMaxLine ?? this.urlAttachmentTextMaxLine,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +185,14 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
b.urlAttachmentTitleStyle,
|
b.urlAttachmentTitleStyle,
|
||||||
t,
|
t,
|
||||||
),
|
),
|
||||||
|
urlAttachmentTitleMaxLine: IntTween(
|
||||||
|
begin: a.urlAttachmentTitleMaxLine,
|
||||||
|
end: b.urlAttachmentTitleMaxLine,
|
||||||
|
).lerp(t),
|
||||||
|
urlAttachmentTextMaxLine: IntTween(
|
||||||
|
begin: a.urlAttachmentTextMaxLine,
|
||||||
|
end: b.urlAttachmentTextMaxLine,
|
||||||
|
).lerp(t),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +221,7 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
urlAttachmentTitleStyle: other.urlAttachmentTitleStyle,
|
urlAttachmentTitleStyle: other.urlAttachmentTitleStyle,
|
||||||
urlAttachmentTextStyle: other.urlAttachmentTextStyle,
|
urlAttachmentTextStyle: other.urlAttachmentTextStyle,
|
||||||
urlAttachmentTitleMaxLine: other.urlAttachmentTitleMaxLine,
|
urlAttachmentTitleMaxLine: other.urlAttachmentTitleMaxLine,
|
||||||
|
urlAttachmentTextMaxLine: other.urlAttachmentTextMaxLine,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +245,8 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
urlAttachmentHostStyle == other.urlAttachmentHostStyle &&
|
urlAttachmentHostStyle == other.urlAttachmentHostStyle &&
|
||||||
urlAttachmentTitleStyle == other.urlAttachmentTitleStyle &&
|
urlAttachmentTitleStyle == other.urlAttachmentTitleStyle &&
|
||||||
urlAttachmentTextStyle == other.urlAttachmentTextStyle &&
|
urlAttachmentTextStyle == other.urlAttachmentTextStyle &&
|
||||||
urlAttachmentTitleMaxLine == other.urlAttachmentTitleMaxLine;
|
urlAttachmentTitleMaxLine == other.urlAttachmentTitleMaxLine &&
|
||||||
|
urlAttachmentTextMaxLine == other.urlAttachmentTextMaxLine;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode =>
|
||||||
@@ -248,7 +265,8 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
urlAttachmentHostStyle.hashCode ^
|
urlAttachmentHostStyle.hashCode ^
|
||||||
urlAttachmentTitleStyle.hashCode ^
|
urlAttachmentTitleStyle.hashCode ^
|
||||||
urlAttachmentTextStyle.hashCode ^
|
urlAttachmentTextStyle.hashCode ^
|
||||||
urlAttachmentTitleMaxLine.hashCode;
|
urlAttachmentTitleMaxLine.hashCode ^
|
||||||
|
urlAttachmentTextMaxLine.hashCode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
@@ -284,6 +302,10 @@ class StreamMessageThemeData with Diagnosticable {
|
|||||||
..add(DiagnosticsProperty(
|
..add(DiagnosticsProperty(
|
||||||
'urlAttachmentTitleMaxLine',
|
'urlAttachmentTitleMaxLine',
|
||||||
urlAttachmentTitleMaxLine,
|
urlAttachmentTitleMaxLine,
|
||||||
|
))
|
||||||
|
..add(DiagnosticsProperty(
|
||||||
|
'urlAttachmentTextMaxLine',
|
||||||
|
urlAttachmentTextMaxLine,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,15 +195,12 @@ class StreamChatThemeData {
|
|||||||
width: 32,
|
width: 32,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
messageLinksStyle: TextStyle(
|
messageLinksStyle: TextStyle(color: accentColor),
|
||||||
color: accentColor,
|
|
||||||
),
|
|
||||||
urlAttachmentBackgroundColor: colorTheme.linkBg,
|
urlAttachmentBackgroundColor: colorTheme.linkBg,
|
||||||
urlAttachmentHostStyle: textTheme.bodyBold.copyWith(color: accentColor),
|
urlAttachmentHostStyle: textTheme.bodyBold.copyWith(color: accentColor),
|
||||||
urlAttachmentTitleStyle:
|
urlAttachmentTitleStyle: textTheme.footnoteBold,
|
||||||
textTheme.body.copyWith(fontWeight: FontWeight.w700),
|
urlAttachmentTextStyle: textTheme.footnote,
|
||||||
urlAttachmentTextStyle:
|
urlAttachmentTitleMaxLine: 1,
|
||||||
textTheme.body.copyWith(fontWeight: FontWeight.w400),
|
|
||||||
),
|
),
|
||||||
otherMessageTheme: StreamMessageThemeData(
|
otherMessageTheme: StreamMessageThemeData(
|
||||||
reactionsBackgroundColor: colorTheme.borders,
|
reactionsBackgroundColor: colorTheme.borders,
|
||||||
@@ -215,9 +212,7 @@ class StreamChatThemeData {
|
|||||||
messageAuthorStyle:
|
messageAuthorStyle:
|
||||||
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
||||||
repliesStyle: textTheme.footnoteBold.copyWith(color: accentColor),
|
repliesStyle: textTheme.footnoteBold.copyWith(color: accentColor),
|
||||||
messageLinksStyle: TextStyle(
|
messageLinksStyle: TextStyle(color: accentColor),
|
||||||
color: accentColor,
|
|
||||||
),
|
|
||||||
messageBackgroundColor: colorTheme.barsBg,
|
messageBackgroundColor: colorTheme.barsBg,
|
||||||
messageBorderColor: colorTheme.borders,
|
messageBorderColor: colorTheme.borders,
|
||||||
avatarTheme: StreamAvatarThemeData(
|
avatarTheme: StreamAvatarThemeData(
|
||||||
@@ -229,10 +224,9 @@ class StreamChatThemeData {
|
|||||||
),
|
),
|
||||||
urlAttachmentBackgroundColor: colorTheme.linkBg,
|
urlAttachmentBackgroundColor: colorTheme.linkBg,
|
||||||
urlAttachmentHostStyle: textTheme.bodyBold.copyWith(color: accentColor),
|
urlAttachmentHostStyle: textTheme.bodyBold.copyWith(color: accentColor),
|
||||||
urlAttachmentTitleStyle:
|
urlAttachmentTitleStyle: textTheme.footnoteBold,
|
||||||
textTheme.body.copyWith(fontWeight: FontWeight.w700),
|
urlAttachmentTextStyle: textTheme.footnote,
|
||||||
urlAttachmentTextStyle:
|
urlAttachmentTitleMaxLine: 1,
|
||||||
textTheme.body.copyWith(fontWeight: FontWeight.w400),
|
|
||||||
),
|
),
|
||||||
messageInputTheme: StreamMessageInputThemeData(
|
messageInputTheme: StreamMessageInputThemeData(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
|||||||
Reference in New Issue
Block a user