From 0d6362e5d55536c878c6f987f58a4170acc34da7 Mon Sep 17 00:00:00 2001 From: Gordon Hayes Date: Thu, 17 Nov 2022 16:19:04 +0100 Subject: [PATCH 1/4] fix: cached attachment image not showing on web --- .../lib/src/attachment/image_attachment.dart | 47 +++++++++++++------ .../stream_chat_flutter_core/CHANGELOG.md | 5 ++ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart index 93bf2926..6a6ee780 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -56,22 +56,33 @@ class StreamImageAttachment extends StreamAttachmentWidget { Widget build(BuildContext context) { return source.when( local: () { - if (attachment.localUri == null || attachment.file?.bytes == null) { - return AttachmentError(constraints: constraints); - } - return _buildImageAttachment( - context, - Image.memory( - attachment.file!.bytes!, - height: constraints?.maxHeight, - width: constraints?.maxWidth, - fit: BoxFit.cover, - errorBuilder: (context, _, __) => Image.asset( - 'images/placeholder.png', - package: 'stream_chat_flutter', + if (attachment.file?.bytes != null) { + return _buildImageAttachment( + context, + Image.memory( + attachment.file!.bytes!, + height: constraints?.maxHeight, + width: constraints?.maxWidth, + fit: BoxFit.cover, + errorBuilder: _imageErrorBuilder, ), - ), - ); + ); + } else if (attachment.localUri != null) { + return _buildImageAttachment( + context, + Image.asset( + attachment.localUri!.path, + height: constraints?.maxHeight, + width: constraints?.maxWidth, + fit: BoxFit.cover, + errorBuilder: _imageErrorBuilder, + ), + ); + } else { + return AttachmentError( + constraints: constraints, + ); + } }, network: () { var imageUrl = @@ -116,6 +127,12 @@ class StreamImageAttachment extends StreamAttachmentWidget { ); } + Widget _imageErrorBuilder(BuildContext _, Object __, StackTrace? ___) => + Image.asset( + 'images/placeholder.png', + package: 'stream_chat_flutter', + ); + Widget _buildImageAttachment(BuildContext context, Widget imageWidget) { return Container( constraints: constraints, diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index f5a993c5..7b511f69 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,3 +1,8 @@ +## Upcomming + +🐞 Fixed +- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web", where the cached image attachment would not render while uploading. +- ## 5.1.0 - Deprecated the `sort` parameter in the `StreamChannelListController` in favor of `channelStateSort`. From 48e7adaba04ecb1850978bcbd5aa40a9696f4cec Mon Sep 17 00:00:00 2001 From: Gordon Hayes Date: Thu, 17 Nov 2022 16:55:45 +0100 Subject: [PATCH 2/4] fix: render overflow using richtext instead of row --- packages/stream_chat_flutter/CHANGELOG.md | 4 ++ .../stream_message_search_list_tile.dart | 42 ++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 61782c02..74b0bf10 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## Upcomming + +🐞 Fixed +- Fix render overflow issue with `MessageSearchListTileTitle`. It now uses `Text.rich` instead of `Row`. Better default behaviour and allows `TextOverflow`. ## 5.1.0 🐞 Fixed diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart index bebe3a74..5aab3b2d 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart @@ -122,7 +122,8 @@ class StreamMessageSearchListTile extends StatelessWidget { final title = this.title ?? MessageSearchListTileTitle( messageResponse: messageResponse, - textStyle: channelPreviewTheme.titleStyle, + textStyle: channelPreviewTheme.titleStyle + ?.copyWith(overflow: TextOverflow.ellipsis), ); final subtitle = this.subtitle ?? @@ -177,27 +178,28 @@ class MessageSearchListTileTitle extends StatelessWidget { final channel = messageResponse.channel; final channelName = channel?.extraData['name']; - return Row( - children: [ - Text( - user.id == StreamChat.of(context).currentUser?.id - ? context.translations.youText - : user.name, - style: textStyle, - ), - if (channelName != null) ...[ - Text( - ' ${context.translations.inText} ', - style: textStyle?.copyWith( - fontWeight: FontWeight.normal, + return Text.rich( + TextSpan( + children: [ + TextSpan( + text: user.id == StreamChat.of(context).currentUser?.id + ? context.translations.youText + : user.name, + ), + if (channelName != null) ...[ + TextSpan( + text: ' ${context.translations.inText} ', + style: textStyle?.copyWith( + fontWeight: FontWeight.normal, + ), ), - ), - Text( - channelName as String, - style: textStyle, - ), + TextSpan( + text: channelName as String, + ), + ], ], - ], + ), + style: textStyle, ); } } From 41f20f7895d4f552236be1b04eacf6d8de122876 Mon Sep 17 00:00:00 2001 From: Gordon Hayes Date: Thu, 17 Nov 2022 17:24:01 +0100 Subject: [PATCH 3/4] docs: update changelog --- packages/stream_chat_flutter/CHANGELOG.md | 5 +++++ packages/stream_chat_flutter_core/CHANGELOG.md | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 61782c02..7336fac8 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,8 @@ +## Upcomming + +🐞 Fixed +- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web", where the cached image attachment would not render while uploading. + ## 5.1.0 🐞 Fixed diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index 7b511f69..f5a993c5 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,8 +1,3 @@ -## Upcomming - -🐞 Fixed -- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web", where the cached image attachment would not render while uploading. -- ## 5.1.0 - Deprecated the `sort` parameter in the `StreamChannelListController` in favor of `channelStateSort`. From 8f17a10814b7b60261d8cf2c4c2d37453ee3258e Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Fri, 18 Nov 2022 14:11:23 +0100 Subject: [PATCH 4/4] Fix broken links. --- .../stream_channel_list_controller.mdx | 2 +- .../stream_member_list_controller.mdx | 2 +- .../stream_message_search_list_controller.mdx | 2 +- .../stream_user_list_controller.mdx | 2 +- .../05-guides/09-initialize_stream_chat_widget_tree.mdx | 4 ++-- .../stream_channel_list_controller.mdx | 2 +- .../stream_message_search_list_controller.mdx | 2 +- .../stream_chat_flutter_core/stream_user_list_controller.mdx | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_channel_list_controller.mdx b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_channel_list_controller.mdx index 2bf2de33..6775ec02 100644 --- a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_channel_list_controller.mdx +++ b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_channel_list_controller.mdx @@ -58,7 +58,7 @@ void dispose() { } ``` -The `StreamChannelListController` is basically a [`PagedValueNotifier`](./paged_value_notifier.mdx) that notifies you when the list of channels has changed. +The `StreamChannelListController` is basically a [`PagedValueNotifier`](./paged_value_listenable_builder.mdx) that notifies you when the list of channels has changed. You can use a [`PagedValueListenableBuilder`](./paged_value_listenable_builder.mdx) to build your UI depending on the latest channels. ```dart diff --git a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_member_list_controller.mdx b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_member_list_controller.mdx index a27d42c8..a811d77e 100644 --- a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_member_list_controller.mdx +++ b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_member_list_controller.mdx @@ -46,7 +46,7 @@ void dispose() { } ``` -The `StreamMemberListController` is basically a [`PagedValueNotifier`](./paged_value_notifier.mdx) that notifies you when the list of members has changed. +The `StreamMemberListController` is basically a [`PagedValueNotifier`](./paged_value_listenable_builder.mdx) that notifies you when the list of members has changed. You can use a [`PagedValueListenableBuilder`](./paged_value_listenable_builder.mdx) to build your UI depending on the latest members. ```dart diff --git a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_message_search_list_controller.mdx b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_message_search_list_controller.mdx index dc2608bc..00b9e7e9 100644 --- a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_message_search_list_controller.mdx +++ b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_message_search_list_controller.mdx @@ -46,7 +46,7 @@ void dispose() { } ``` -The `StreamMessageSearchListController` is basically a [`PagedValueNotifier`](./paged_value_notifier.mdx) that notifies you when the list of responses has changed. +The `StreamMessageSearchListController` is basically a [`PagedValueNotifier`](./paged_value_listenable_builder.mdx) that notifies you when the list of responses has changed. You can use a [`PagedValueListenableBuilder`](./paged_value_listenable_builder.mdx) to build your UI depending on the latest responses. ```dart diff --git a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_user_list_controller.mdx b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_user_list_controller.mdx index 0eba9d35..84705d49 100644 --- a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_user_list_controller.mdx +++ b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_user_list_controller.mdx @@ -46,7 +46,7 @@ void dispose() { } ``` -The `StreamUserListController` is basically a [`PagedValueNotifier`](./paged_value_notifier.mdx) that notifies you when the list of users has changed. +The `StreamUserListController` is basically a [`PagedValueNotifier`](./paged_value_listenable_builder.mdx) that notifies you when the list of users has changed. You can use a [`PagedValueListenableBuilder`](./paged_value_listenable_builder.mdx) to build your UI depending on the latest users. ```dart diff --git a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx index 3bb421ab..17476d21 100644 --- a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx +++ b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx @@ -12,9 +12,9 @@ This guide demonstrates three alternative ways for you to initialize Stream Chat Before investigating potential solutions, let’s first take a look at the relevant Stream Chat widgets and classes. -Most of the Stream Chat Flutter UI widgets rely on having a [StreamChat](https://getstream.io/chat/docs/sdk/flutter/stream_chat_flutter/stream_chat_and_theming/) ancestor in the widget tree. +Most of the Stream Chat Flutter UI widgets rely on having a [StreamChat](../../customization/stream_chat_and_theming/) ancestor in the widget tree. The **StreamChat** widget is an [InheritedWidget](https://api.flutter.dev/flutter/widgets/InheritedWidget-class.html) that exposes the **StreamChatClient** through **BuildContext**. -This widget also initializes the [StreamChatCore](../stream_chat_flutter_core/stream_chat_core.mdx) widget and the **StreamChatTheme**. +This widget also initializes the [StreamChatCore](../../stream_chat_flutter_core/stream_chat_core.mdx) widget and the **StreamChatTheme**. **StreamChatCore** is a **StatefulWidget** used to react to life cycle changes and system updates. When the app goes into the background, the WebSocket connection is closed. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_channel_list_controller.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_channel_list_controller.mdx index c37eeedd..ca1eb3e7 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_channel_list_controller.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_channel_list_controller.mdx @@ -58,7 +58,7 @@ void dispose() { } ``` -The `StreamChannelListController` is basically a [`PagedValueNotifier`](./paged_value_notifier.mdx) that notifies you when the list of channels has changed. +The `StreamChannelListController` is basically a [`PagedValueNotifier`](./paged_value_listenable_builder.mdx) that notifies you when the list of channels has changed. You can use a [`PagedValueListenableBuilder`](./paged_value_listenable_builder.mdx) to build your UI depending on the latest channels. ```dart diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_message_search_list_controller.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_message_search_list_controller.mdx index f4546331..b3e09379 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_message_search_list_controller.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_message_search_list_controller.mdx @@ -46,7 +46,7 @@ void dispose() { } ``` -The `StreamMessageSearchListController` is basically a [`PagedValueNotifier`](./paged_value_notifier.mdx) that notifies you when the list of responses has changed. +The `StreamMessageSearchListController` is basically a [`PagedValueNotifier`](./paged_value_listenable_builder.mdx) that notifies you when the list of responses has changed. You can use a [`PagedValueListenableBuilder`](./paged_value_listenable_builder.mdx) to build your UI depending on the latest responses. ```dart diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_user_list_controller.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_user_list_controller.mdx index 0bee29ed..b7504ab6 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_user_list_controller.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_user_list_controller.mdx @@ -46,7 +46,7 @@ void dispose() { } ``` -The `StreamUserListController` is basically a [`PagedValueNotifier`](./paged_value_notifier.mdx) that notifies you when the list of users has changed. +The `StreamUserListController` is basically a [`PagedValueNotifier`](./paged_value_listenable_builder.mdx) that notifies you when the list of users has changed. You can use a [`PagedValueListenableBuilder`](./paged_value_listenable_builder.mdx) to build your UI depending on the latest users. ```dart