+11
-11
@@ -30,23 +30,25 @@ class UrlAttachmentBuilder extends StreamAttachmentWidgetBuilder {
|
|||||||
final StreamAttachmentWidgetTapCallback? onAttachmentTap;
|
final StreamAttachmentWidgetTapCallback? onAttachmentTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool canHandle(Message message,
|
bool canHandle(
|
||||||
Map<String, List<Attachment>> attachments,) {
|
Message message,
|
||||||
|
Map<String, List<Attachment>> attachments,
|
||||||
|
) {
|
||||||
final urls = attachments[AttachmentType.urlPreview];
|
final urls = attachments[AttachmentType.urlPreview];
|
||||||
return urls != null && urls.isNotEmpty;
|
return urls != null && urls.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context,
|
Widget build(
|
||||||
Message message,
|
BuildContext context,
|
||||||
Map<String, List<Attachment>> attachments,) {
|
Message message,
|
||||||
|
Map<String, List<Attachment>> attachments,
|
||||||
|
) {
|
||||||
assert(debugAssertCanHandle(message, attachments), '');
|
assert(debugAssertCanHandle(message, attachments), '');
|
||||||
|
|
||||||
final urlPreviews = attachments[AttachmentType.urlPreview]!;
|
final urlPreviews = attachments[AttachmentType.urlPreview]!;
|
||||||
|
|
||||||
final client = StreamChat
|
final client = StreamChat.of(context).client;
|
||||||
.of(context)
|
|
||||||
.client;
|
|
||||||
final isMyMessage = message.user?.id == client.state.currentUser?.id;
|
final isMyMessage = message.user?.id == client.state.currentUser?.id;
|
||||||
|
|
||||||
final streamChatTheme = StreamChatTheme.of(context);
|
final streamChatTheme = StreamChatTheme.of(context);
|
||||||
@@ -60,9 +62,7 @@ class UrlAttachmentBuilder extends StreamAttachmentWidgetBuilder {
|
|||||||
onTap = () => onAttachmentTap!(message, urlPreview);
|
onTap = () => onAttachmentTap!(message, urlPreview);
|
||||||
}
|
}
|
||||||
|
|
||||||
final host = Uri
|
final host = Uri.parse(urlPreview.titleLink!).host;
|
||||||
.parse(urlPreview.titleLink!)
|
|
||||||
.host;
|
|
||||||
final splitList = host.split('.');
|
final splitList = host.split('.');
|
||||||
final hostName = splitList.length == 3 ? splitList[1] : splitList[0];
|
final hostName = splitList.length == 3 ? splitList[1] : splitList[0];
|
||||||
final hostDisplayName = urlPreview.authorName?.capitalize() ??
|
final hostDisplayName = urlPreview.authorName?.capitalize() ??
|
||||||
|
|||||||
Reference in New Issue
Block a user