From 914c9cc1371a4cc16c57b7e3961afbd547ea3998 Mon Sep 17 00:00:00 2001 From: Dawid <16155640+geweald@users.noreply.github.com> Date: Tue, 9 Nov 2021 13:21:50 +0100 Subject: [PATCH 01/21] Update extension.dart --- packages/stream_chat_flutter/lib/src/extension.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/extension.dart b/packages/stream_chat_flutter/lib/src/extension.dart index 92590de1..6086b8b7 100644 --- a/packages/stream_chat_flutter/lib/src/extension.dart +++ b/packages/stream_chat_flutter/lib/src/extension.dart @@ -46,7 +46,7 @@ extension IterableX on Iterable { extension PlatformFileX on PlatformFile { /// Converts the [PlatformFile] into [AttachmentFile] AttachmentFile get toAttachmentFile => AttachmentFile( - path: path, + path: kIsWeb ? null : path, name: name, bytes: bytes, size: size, From d5d92cfcca8e588c6d412d37e8f57c1d5b04b7a4 Mon Sep 17 00:00:00 2001 From: Dawid <16155640+geweald@users.noreply.github.com> Date: Tue, 9 Nov 2021 13:43:07 +0100 Subject: [PATCH 02/21] Update extension.dart --- packages/stream_chat_flutter/lib/src/extension.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat_flutter/lib/src/extension.dart b/packages/stream_chat_flutter/lib/src/extension.dart index 6086b8b7..73956da6 100644 --- a/packages/stream_chat_flutter/lib/src/extension.dart +++ b/packages/stream_chat_flutter/lib/src/extension.dart @@ -1,6 +1,7 @@ import 'package:characters/characters.dart'; import 'package:diacritic/diacritic.dart'; import 'package:file_picker/file_picker.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/emoji/emoji.dart'; import 'package:stream_chat_flutter/src/localization/translations.dart'; From afc8026547ef91cdd233cd75ade60b30b2957e8f Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 10 Nov 2021 17:56:35 +0530 Subject: [PATCH 03/21] feat: Added a queryAround implementation --- .../lib/src/core/api/requests.dart | 22 ++++++++++++++++ .../lib/src/core/api/requests.g.dart | 6 +++++ .../lib/src/stream_channel.dart | 26 ++++++++++++++----- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/requests.dart b/packages/stream_chat/lib/src/core/api/requests.dart index 14995b10..76272241 100644 --- a/packages/stream_chat/lib/src/core/api/requests.dart +++ b/packages/stream_chat/lib/src/core/api/requests.dart @@ -60,8 +60,11 @@ class PaginationParams extends Equatable { /// ``` const PaginationParams({ this.limit = 10, + this.before = 10, + this.after = 10, this.offset, this.next, + this.aroundId, this.greaterThan, this.greaterThanOrEqual, this.lessThan, @@ -78,12 +81,22 @@ class PaginationParams extends Equatable { /// The amount of items requested from the APIs. final int limit; + /// The amount of items requested before message ID from the APIs. + final int before; + + /// The amount of items requested after message ID from the APIs. + final int after; + /// The offset of requesting items. final int? offset; /// A key used to paginate. final String? next; + /// Message ID to fetch messages around + @JsonKey(name: 'around_id') + final String? aroundId; + /// Filter on ids greater than the given value. @JsonKey(name: 'id_gt') final String? greaterThan; @@ -106,7 +119,10 @@ class PaginationParams extends Equatable { /// Creates a copy of [PaginationParams] with specified attributes overridden. PaginationParams copyWith({ int? limit, + int? before, + int? after, int? offset, + String? aroundId, String? next, String? greaterThan, String? greaterThanOrEqual, @@ -115,7 +131,10 @@ class PaginationParams extends Equatable { }) => PaginationParams( limit: limit ?? this.limit, + before: before ?? this.before, + after: limit ?? this.after, offset: offset ?? this.offset, + aroundId: aroundId ?? this.aroundId, next: next ?? this.next, greaterThan: greaterThan ?? this.greaterThan, greaterThanOrEqual: greaterThanOrEqual ?? this.greaterThanOrEqual, @@ -126,8 +145,11 @@ class PaginationParams extends Equatable { @override List get props => [ limit, + before, + after, offset, next, + aroundId, greaterThan, greaterThanOrEqual, lessThan, diff --git a/packages/stream_chat/lib/src/core/api/requests.g.dart b/packages/stream_chat/lib/src/core/api/requests.g.dart index ef995997..5a9e67bd 100644 --- a/packages/stream_chat/lib/src/core/api/requests.g.dart +++ b/packages/stream_chat/lib/src/core/api/requests.g.dart @@ -21,8 +21,11 @@ Map _$SortOptionToJson(SortOption instance) => PaginationParams _$PaginationParamsFromJson(Map json) => PaginationParams( limit: json['limit'] as int? ?? 10, + before: json['before'] as int? ?? 10, + after: json['after'] as int? ?? 10, offset: json['offset'] as int?, next: json['next'] as String?, + aroundId: json['around_id'] as String?, greaterThan: json['id_gt'] as String?, greaterThanOrEqual: json['id_gte'] as String?, lessThan: json['id_lt'] as String?, @@ -32,6 +35,8 @@ PaginationParams _$PaginationParamsFromJson(Map json) => Map _$PaginationParamsToJson(PaginationParams instance) { final val = { 'limit': instance.limit, + 'before': instance.before, + 'after': instance.after, }; void writeNotNull(String key, dynamic value) { @@ -42,6 +47,7 @@ Map _$PaginationParamsToJson(PaginationParams instance) { writeNotNull('offset', instance.offset); writeNotNull('next', instance.next); + writeNotNull('around_id', instance.aroundId); writeNotNull('id_gt', instance.greaterThan); writeNotNull('id_gte', instance.greaterThanOrEqual); writeNotNull('id_lt', instance.lessThan); diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index 8117a26e..62dc8a4a 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -249,19 +249,31 @@ class StreamChannelState extends State { } return Future.wait([ - queryBeforeMessage( + queryAroundMessage( messageId, - limit: before, - preferOffline: preferOffline, - ), - queryAfterMessage( - messageId, - limit: after, + before: before, + after: after, preferOffline: preferOffline, ), ]); } + /// + Future queryAroundMessage( + String messageId, { + int before = 20, + int after = 20, + bool preferOffline = false, + }) => + channel.query( + messagesPagination: PaginationParams( + aroundId: messageId, + before: before, + after: after, + ), + preferOffline: preferOffline, + ); + /// Future queryBeforeMessage( String messageId, { From 013316af73d642a27df7f00876fc3e8b3adabab1 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 10 Nov 2021 18:07:42 +0530 Subject: [PATCH 04/21] feat: Added a queryAround implementation --- .../stream_chat_flutter_core/lib/src/stream_channel.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index 62dc8a4a..26d67642 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -264,8 +264,10 @@ class StreamChannelState extends State { int before = 20, int after = 20, bool preferOffline = false, - }) => - channel.query( + }) { + // TODO: REMOVE (TEMP FOR TEST HERE) + print('CALLED AROUND'); + return channel.query( messagesPagination: PaginationParams( aroundId: messageId, before: before, @@ -273,6 +275,7 @@ class StreamChannelState extends State { ), preferOffline: preferOffline, ); + } /// Future queryBeforeMessage( From 085d8cf344b3655235012e91275240d1b3ad33f7 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 10 Nov 2021 18:12:27 +0530 Subject: [PATCH 05/21] feat: Added a queryAround implementation --- .../stream_chat_flutter_core/lib/src/stream_channel.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index 26d67642..fc4160e8 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -219,13 +219,16 @@ class StreamChannelState extends State { int before = 20, int after = 20, bool preferOffline = false, - }) => - _queryAtMessage( + }) { + // TODO: REMOVE (TEMP FOR TEST HERE) + print('CALLED AROUND'); + return _queryAtMessage( messageId: messageId, before: before, after: after, preferOffline: preferOffline, ); + } Future> _queryAtMessage({ String? messageId, From bfacbaa1adf75506048cc00a8f5d7f4705e12a59 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 10 Nov 2021 18:16:16 +0530 Subject: [PATCH 06/21] feat: Added a queryAround implementation --- .../lib/src/stream_channel.dart | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index fc4160e8..62dc8a4a 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -219,16 +219,13 @@ class StreamChannelState extends State { int before = 20, int after = 20, bool preferOffline = false, - }) { - // TODO: REMOVE (TEMP FOR TEST HERE) - print('CALLED AROUND'); - return _queryAtMessage( + }) => + _queryAtMessage( messageId: messageId, before: before, after: after, preferOffline: preferOffline, ); - } Future> _queryAtMessage({ String? messageId, @@ -267,10 +264,8 @@ class StreamChannelState extends State { int before = 20, int after = 20, bool preferOffline = false, - }) { - // TODO: REMOVE (TEMP FOR TEST HERE) - print('CALLED AROUND'); - return channel.query( + }) => + channel.query( messagesPagination: PaginationParams( aroundId: messageId, before: before, @@ -278,7 +273,6 @@ class StreamChannelState extends State { ), preferOffline: preferOffline, ); - } /// Future queryBeforeMessage( From 9f9f0f510d62b2fbb77ce9ebf6c0083947bc5bfa Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 10 Nov 2021 18:34:15 +0530 Subject: [PATCH 07/21] added changelog --- packages/stream_chat/CHANGELOG.md | 6 ++++++ packages/stream_chat_flutter/CHANGELOG.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 4b409536..5b8641b9 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +✅ Added + +- Extra properties added to `PaginationParams` to aid in fetching messages. + ## 3.2.0 🐞 Fixed diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 00f8412b..2dc2de1c 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +✅ Added + +- `StreamChannel` can now fetch messages around a message ID with the `queryAroundMessage` call. + ## 3.2.0 - Updated Dart SDK constraints to `>=2.14.0 <3.0.0` From be8b319691c641757c951793c8c68da0845bd055 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 10 Nov 2021 20:01:02 +0530 Subject: [PATCH 08/21] fixes name --- .../lib/src/core/api/requests.dart | 12 +++++----- .../lib/src/core/api/requests.g.dart | 4 ++-- .../lib/src/stream_channel.dart | 22 +++++++++---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/requests.dart b/packages/stream_chat/lib/src/core/api/requests.dart index 76272241..6f00b374 100644 --- a/packages/stream_chat/lib/src/core/api/requests.dart +++ b/packages/stream_chat/lib/src/core/api/requests.dart @@ -64,7 +64,7 @@ class PaginationParams extends Equatable { this.after = 10, this.offset, this.next, - this.aroundId, + this.idAround, this.greaterThan, this.greaterThanOrEqual, this.lessThan, @@ -94,8 +94,8 @@ class PaginationParams extends Equatable { final String? next; /// Message ID to fetch messages around - @JsonKey(name: 'around_id') - final String? aroundId; + @JsonKey(name: 'id_around') + final String? idAround; /// Filter on ids greater than the given value. @JsonKey(name: 'id_gt') @@ -122,7 +122,7 @@ class PaginationParams extends Equatable { int? before, int? after, int? offset, - String? aroundId, + String? idAround, String? next, String? greaterThan, String? greaterThanOrEqual, @@ -134,7 +134,7 @@ class PaginationParams extends Equatable { before: before ?? this.before, after: limit ?? this.after, offset: offset ?? this.offset, - aroundId: aroundId ?? this.aroundId, + idAround: idAround ?? this.idAround, next: next ?? this.next, greaterThan: greaterThan ?? this.greaterThan, greaterThanOrEqual: greaterThanOrEqual ?? this.greaterThanOrEqual, @@ -149,7 +149,7 @@ class PaginationParams extends Equatable { after, offset, next, - aroundId, + idAround, greaterThan, greaterThanOrEqual, lessThan, diff --git a/packages/stream_chat/lib/src/core/api/requests.g.dart b/packages/stream_chat/lib/src/core/api/requests.g.dart index 5a9e67bd..7d45ee86 100644 --- a/packages/stream_chat/lib/src/core/api/requests.g.dart +++ b/packages/stream_chat/lib/src/core/api/requests.g.dart @@ -25,7 +25,7 @@ PaginationParams _$PaginationParamsFromJson(Map json) => after: json['after'] as int? ?? 10, offset: json['offset'] as int?, next: json['next'] as String?, - aroundId: json['around_id'] as String?, + idAround: json['id_around'] as String?, greaterThan: json['id_gt'] as String?, greaterThanOrEqual: json['id_gte'] as String?, lessThan: json['id_lt'] as String?, @@ -47,7 +47,7 @@ Map _$PaginationParamsToJson(PaginationParams instance) { writeNotNull('offset', instance.offset); writeNotNull('next', instance.next); - writeNotNull('around_id', instance.aroundId); + writeNotNull('id_around', instance.idAround); writeNotNull('id_gt', instance.greaterThan); writeNotNull('id_gte', instance.greaterThanOrEqual); writeNotNull('id_lt', instance.lessThan); diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index 62dc8a4a..633c3137 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -227,13 +227,13 @@ class StreamChannelState extends State { preferOffline: preferOffline, ); - Future> _queryAtMessage({ + Future _queryAtMessage({ String? messageId, int before = 20, int after = 20, bool preferOffline = false, }) async { - if (channel.state == null) return []; + if (channel.state == null) return null; channel.state!.isUpToDate = false; channel.state!.truncate(); @@ -245,17 +245,15 @@ class StreamChannelState extends State { preferOffline: preferOffline, ); channel.state!.isUpToDate = true; - return []; + return null; } - return Future.wait([ - queryAroundMessage( - messageId, - before: before, - after: after, - preferOffline: preferOffline, - ), - ]); + return queryAroundMessage( + messageId, + before: before, + after: after, + preferOffline: preferOffline, + ); } /// @@ -267,7 +265,7 @@ class StreamChannelState extends State { }) => channel.query( messagesPagination: PaginationParams( - aroundId: messageId, + idAround: messageId, before: before, after: after, ), From 7f8f4a91c78d7e9a51affa6dcc37c21b212bd0da Mon Sep 17 00:00:00 2001 From: geweald Date: Wed, 10 Nov 2021 18:22:16 +0100 Subject: [PATCH 09/21] fix web attachments and ws --- packages/stream_chat/lib/src/ws/websocket.dart | 3 ++- packages/stream_chat_flutter/lib/src/extension.dart | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat/lib/src/ws/websocket.dart b/packages/stream_chat/lib/src/ws/websocket.dart index 05382fb7..a95eae70 100644 --- a/packages/stream_chat/lib/src/ws/websocket.dart +++ b/packages/stream_chat/lib/src/ws/websocket.dart @@ -121,7 +121,8 @@ class WebSocket with TimerHelper { _logger?.info('Closing connection with $baseUrl'); if (_webSocketChannel != null) { _unsubscribeFromWebSocketChannel(); - _webSocketChannel?.sink.close(status.goingAway); + _webSocketChannel?.sink + .close(_manuallyClosed ? status.normalClosure : status.goingAway); _webSocketChannel = null; } } diff --git a/packages/stream_chat_flutter/lib/src/extension.dart b/packages/stream_chat_flutter/lib/src/extension.dart index 6086b8b7..73956da6 100644 --- a/packages/stream_chat_flutter/lib/src/extension.dart +++ b/packages/stream_chat_flutter/lib/src/extension.dart @@ -1,6 +1,7 @@ import 'package:characters/characters.dart'; import 'package:diacritic/diacritic.dart'; import 'package:file_picker/file_picker.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/emoji/emoji.dart'; import 'package:stream_chat_flutter/src/localization/translations.dart'; From 235cac600096cbb9d12c5dd8969734ae14d1ec99 Mon Sep 17 00:00:00 2001 From: geweald Date: Mon, 15 Nov 2021 11:24:05 +0100 Subject: [PATCH 10/21] update changelogs --- packages/stream_chat/CHANGELOG.md | 54 ++++---- packages/stream_chat_flutter/CHANGELOG.md | 154 +++++++++++----------- 2 files changed, 110 insertions(+), 98 deletions(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 4b409536..8617ba42 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🐞 Fixed + +- `closeConnection()` now uses `normalClosure` status when closing websocket. + ## 3.2.0 🐞 Fixed @@ -21,12 +27,12 @@ 🛑️ Breaking Changes from `2.2.1` - Added 6 new methods in `ChatPersistenceClient`. - - `bulkUpdateMessages` - - `bulkUpdatePinnedMessages` - - `bulkUpdateMembers` - - `bulkUpdateReads` - - `updatePinnedMessageReactions` - - `deletePinnedMessageReactionsByMessageId` + - `bulkUpdateMessages` + - `bulkUpdatePinnedMessages` + - `bulkUpdateMembers` + - `bulkUpdateReads` + - `updatePinnedMessageReactions` + - `deletePinnedMessageReactionsByMessageId` ✅ Added @@ -104,19 +110,19 @@ - migrate this package to null safety - `ConnectUserWithProvider` now requires `tokenProvider` as a required param. (Removed from the constructor) - `client.disconnect()` is now divided into two different functions - - `client.closeConnection()` -> for closing user websocket connection. - - `client.disconnectUser()` -> for disconnecting user and resetting client state. + - `client.closeConnection()` -> for closing user websocket connection. + - `client.disconnectUser()` -> for disconnecting user and resetting client state. - `client.devToken()` now returns a `Token` model instead of `String`. - `ApiError` is removed in favor of `StreamChatError` - - `StreamChatError` -> parent type for all the stream errors. - - `StreamWebSocketError` -> for user websocket related errors. - - `StreamChatNetworkError` -> for network related errors. + - `StreamChatError` -> parent type for all the stream errors. + - `StreamWebSocketError` -> for user websocket related errors. + - `StreamChatNetworkError` -> for network related errors. - `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params - - `option.state` -> bool state - - `option.watch` -> bool watch - - `option.presence` -> bool presence + - `option.state` -> bool state + - `option.watch` -> bool watch + - `option.presence` -> bool presence - `client.queryUsers()` options param is removed in favor of individual params - - `option.presence` -> bool presence + - `option.presence` -> bool presence - Migrate this package to null safety - Added typed filters @@ -150,19 +156,19 @@ - `ConnectUserWithProvider` now requires `tokenProvider` as a required param. (Removed from the constructor) - `client.disconnect()` is now divided into two different functions - - `client.closeConnection()` -> for closing user websocket connection. - - `client.disconnectUser()` -> for disconnecting user and resetting client state. + - `client.closeConnection()` -> for closing user websocket connection. + - `client.disconnectUser()` -> for disconnecting user and resetting client state. - `client.devToken()` now returns a `Token` model instead of `String`. - `ApiError` is removed in favor of `StreamChatError` - - `StreamChatError` -> parent type for all the stream errors. - - `StreamWebSocketError` -> for user websocket related errors. - - `StreamChatNetworkError` -> for network related errors. + - `StreamChatError` -> parent type for all the stream errors. + - `StreamWebSocketError` -> for user websocket related errors. + - `StreamChatNetworkError` -> for network related errors. - `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params - - `option.state` -> bool state - - `option.watch` -> bool watch - - `option.presence` -> bool presence + - `option.state` -> bool state + - `option.watch` -> bool watch + - `option.presence` -> bool presence - `client.queryUsers()` options param is removed in favor of individual params - - `option.presence` -> bool presence + - `option.presence` -> bool presence ✅ Added diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 00f8412b..fe52c849 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🐞 Fixed + +- Fixed adding attachments on web. + ## 3.2.0 - Updated Dart SDK constraints to `>=2.14.0 <3.0.0` @@ -70,36 +76,36 @@ ⚠️ Deprecated - `MessageSearchListView` `paginationParams` property is now deprecated in favor of `limit`. - ```dart - // previous - paginationParams = const PaginationParams(limit: 30) - - // new - limit = 30 - ``` + ```dart + // previous + paginationParams = const PaginationParams(limit: 30) + + // new + limit = 30 + ``` - `UserListView` `pagination` property is now deprecated in favor of `limit`. - ```dart - // previous - pagination = const PaginationParams(limit: 30) - - // new - limit = 30 - ``` + ```dart + // previous + pagination = const PaginationParams(limit: 30) + + // new + limit = 30 + ``` - `ChannelListView` `pagination` property is now deprecated in favor of `limit`. - ```dart - // previous - pagination = const PaginationParams(limit: 30) - - // new - limit = 30 - ``` + ```dart + // previous + pagination = const PaginationParams(limit: 30) + + // new + limit = 30 + ``` 🔄 Changed - `UserListViewCore` filter property now has a default value. - ```dart - filter = const Filter.empty() - ``` + ```dart + filter = const Filter.empty() + ``` 🐞 Fixed @@ -117,11 +123,11 @@ - [#516](https://github.com/GetStream/stream-chat-flutter/issues/516): Added `StreamChatThemeData.placeholderUserImage` for building a widget when the `UserAvatar` image is loading - Added a `backgroundColor` property to the following widgets: - - `ChannelHeader` - - `ChannelListHeader` - - `GalleryHeader` - - `GalleryFooter` - - `ThreadHeader` + - `ChannelHeader` + - `ChannelListHeader` + - `GalleryHeader` + - `GalleryFooter` + - `ThreadHeader` - Added `MessageInput.attachmentLimit` in order to limit the no. of attachments that can be sent with a single message. - Added `MessageInput.onAttachmentLimitExceed` callback which will be called when the `attachmentLimit` is exceeded. This will override the default error alert behaviour. @@ -135,7 +141,7 @@ typedef ActionButtonBuilder = Widget Function( ``` > **_NOTE:_** The last parameter is the default `ActionButton` -You can call `.copyWith` to customize just a subset of properties. +> You can call `.copyWith` to customize just a subset of properties. - Added slow mode which allows a cooldown period after a user sends a message. @@ -144,18 +150,18 @@ You can call `.copyWith` to customize just a subset of properties. Theming has been upgraded! Most theme classes now have `InheritedTheme` classes associated with them, and have been upgraded with some goodies like `lerp` functions. Here's the full naming breakdown: -* `AvatarTheme` is now `AvatarThemeData` -* `ChannelHeaderTheme` is now `ChannelHeaderThemeData` -* `ChannelListHeaderTheme` is now `ChannelListHeaderThemeData` -* `ChannelListViewTheme` is now `ChannelListViewThemeData` -* `ChannelPreviewTheme` is now `ChannelPreviewThemeData` -* `MessageInputTheme` is now `MessageInputThemeData` -* `MessageListViewTheme` is now `MessageListViewTheme` -* `MessageSearchListViewTheme` is now `MessageSearchListViewThemeData` -* `MessageTheme` is now `MessageThemeData` -* `UserListViewTheme` is now `UserListViewThemeData` +- `AvatarTheme` is now `AvatarThemeData` +- `ChannelHeaderTheme` is now `ChannelHeaderThemeData` +- `ChannelListHeaderTheme` is now `ChannelListHeaderThemeData` +- `ChannelListViewTheme` is now `ChannelListViewThemeData` +- `ChannelPreviewTheme` is now `ChannelPreviewThemeData` +- `MessageInputTheme` is now `MessageInputThemeData` +- `MessageListViewTheme` is now `MessageListViewTheme` +- `MessageSearchListViewTheme` is now `MessageSearchListViewThemeData` +- `MessageTheme` is now `MessageThemeData` +- `UserListViewTheme` is now `UserListViewThemeData` -- Updated core dependency. +* Updated core dependency. 🐞 Fixed @@ -202,24 +208,25 @@ upgraded with some goodies like `lerp` functions. Here's the full naming breakdo - Renamed `ChannelImage` to `ChannelAvatar` - Updated `StreamChatThemeData.reactionIcons` to accept custom builder - Renamed `ColorTheme` properties to reflect the purpose of the colors - - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` - - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` - - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` - - `ColorTheme.greyWhisper` -> `ColorTheme.borders` - - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` - - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` - - `ColorTheme.white` -> `ColorTheme.barsBg` - - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` - - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` - - `ColorTheme.accentRed` -> `ColorTheme.accentError` - - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` + + - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` + - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` + - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` + - `ColorTheme.greyWhisper` -> `ColorTheme.borders` + - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` + - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` + - `ColorTheme.white` -> `ColorTheme.barsBg` + - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` + - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` + - `ColorTheme.accentRed` -> `ColorTheme.accentError` + - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` - `ChannelListCore` options property is removed in favor of individual properties - - `options.state` -> bool state - - `options.watch` -> bool watch - - `options.presence` -> bool presence + - `options.state` -> bool state + - `options.watch` -> bool watch + - `options.presence` -> bool presence - `UserListView` options property is removed in favor of individual properties - - `options.presence` -> bool presence + - `options.presence` -> bool presence - Renamed `ImageHeader` to `GalleryHeader` - Renamed `ImageFooter` to `GalleryFooter` - `MessageBuilder` and `ParentMessageBuilder` signature is now @@ -234,8 +241,7 @@ typedef MessageBuilder = Widget Function( ``` > **_NOTE:_** the last parameter is the default `MessageWidget` -You can call `.copyWith` to customize just a subset of properties - +> You can call `.copyWith` to customize just a subset of properties ✅ Added @@ -263,17 +269,17 @@ You can call `.copyWith` to customize just a subset of properties 🛑️ Breaking Changes from `2.0.0-nullsafety.8` - Renamed `ColorTheme` properties to reflect the purpose of the colors - - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` - - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` - - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` - - `ColorTheme.greyWhisper` -> `ColorTheme.borders` - - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` - - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` - - `ColorTheme.white` -> `ColorTheme.barsBg` - - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` - - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` - - `ColorTheme.accentRed` -> `ColorTheme.accentError` - - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` + - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` + - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` + - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` + - `ColorTheme.greyWhisper` -> `ColorTheme.borders` + - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` + - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` + - `ColorTheme.white` -> `ColorTheme.barsBg` + - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` + - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` + - `ColorTheme.accentRed` -> `ColorTheme.accentError` + - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` ✅ Added @@ -284,11 +290,11 @@ You can call `.copyWith` to customize just a subset of properties 🛑️ Breaking Changes from `2.0.0-nullsafety.7` - `ChannelListCore` options property is removed in favor of individual properties - - `options.state` -> bool state - - `options.watch` -> bool watch - - `options.presence` -> bool presence + - `options.state` -> bool state + - `options.watch` -> bool watch + - `options.presence` -> bool presence - `UserListView` options property is removed in favor of individual properties - - `options.presence` -> bool presence + - `options.presence` -> bool presence - `MessageBuilder` and `ParentMessageBuilder` signature is now ```dart @@ -301,7 +307,7 @@ typedef MessageBuilder = Widget Function( ``` > **_NOTE:_** The last parameter is the default `MessageWidget` -You can call `.copyWith` to customize just a subset of properties. +> You can call `.copyWith` to customize just a subset of properties. ✅ Added From 5e33088b8b45c9900ff76002a0d9ee5b8f7f11b7 Mon Sep 17 00:00:00 2001 From: geweald Date: Mon, 15 Nov 2021 11:29:47 +0100 Subject: [PATCH 11/21] fix - revert changelog formatting --- packages/stream_chat/CHANGELOG.md | 50 ++++---- packages/stream_chat_flutter/CHANGELOG.md | 150 +++++++++++----------- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 8617ba42..46f60da0 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -27,12 +27,12 @@ 🛑️ Breaking Changes from `2.2.1` - Added 6 new methods in `ChatPersistenceClient`. - - `bulkUpdateMessages` - - `bulkUpdatePinnedMessages` - - `bulkUpdateMembers` - - `bulkUpdateReads` - - `updatePinnedMessageReactions` - - `deletePinnedMessageReactionsByMessageId` + - `bulkUpdateMessages` + - `bulkUpdatePinnedMessages` + - `bulkUpdateMembers` + - `bulkUpdateReads` + - `updatePinnedMessageReactions` + - `deletePinnedMessageReactionsByMessageId` ✅ Added @@ -110,19 +110,19 @@ - migrate this package to null safety - `ConnectUserWithProvider` now requires `tokenProvider` as a required param. (Removed from the constructor) - `client.disconnect()` is now divided into two different functions - - `client.closeConnection()` -> for closing user websocket connection. - - `client.disconnectUser()` -> for disconnecting user and resetting client state. + - `client.closeConnection()` -> for closing user websocket connection. + - `client.disconnectUser()` -> for disconnecting user and resetting client state. - `client.devToken()` now returns a `Token` model instead of `String`. - `ApiError` is removed in favor of `StreamChatError` - - `StreamChatError` -> parent type for all the stream errors. - - `StreamWebSocketError` -> for user websocket related errors. - - `StreamChatNetworkError` -> for network related errors. + - `StreamChatError` -> parent type for all the stream errors. + - `StreamWebSocketError` -> for user websocket related errors. + - `StreamChatNetworkError` -> for network related errors. - `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params - - `option.state` -> bool state - - `option.watch` -> bool watch - - `option.presence` -> bool presence + - `option.state` -> bool state + - `option.watch` -> bool watch + - `option.presence` -> bool presence - `client.queryUsers()` options param is removed in favor of individual params - - `option.presence` -> bool presence + - `option.presence` -> bool presence - Migrate this package to null safety - Added typed filters @@ -156,19 +156,19 @@ - `ConnectUserWithProvider` now requires `tokenProvider` as a required param. (Removed from the constructor) - `client.disconnect()` is now divided into two different functions - - `client.closeConnection()` -> for closing user websocket connection. - - `client.disconnectUser()` -> for disconnecting user and resetting client state. + - `client.closeConnection()` -> for closing user websocket connection. + - `client.disconnectUser()` -> for disconnecting user and resetting client state. - `client.devToken()` now returns a `Token` model instead of `String`. - `ApiError` is removed in favor of `StreamChatError` - - `StreamChatError` -> parent type for all the stream errors. - - `StreamWebSocketError` -> for user websocket related errors. - - `StreamChatNetworkError` -> for network related errors. + - `StreamChatError` -> parent type for all the stream errors. + - `StreamWebSocketError` -> for user websocket related errors. + - `StreamChatNetworkError` -> for network related errors. - `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params - - `option.state` -> bool state - - `option.watch` -> bool watch - - `option.presence` -> bool presence + - `option.state` -> bool state + - `option.watch` -> bool watch + - `option.presence` -> bool presence - `client.queryUsers()` options param is removed in favor of individual params - - `option.presence` -> bool presence + - `option.presence` -> bool presence ✅ Added @@ -726,4 +726,4 @@ ## 0.0.2 -- first beta version +- first beta version \ No newline at end of file diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index fe52c849..73d49806 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -76,36 +76,36 @@ ⚠️ Deprecated - `MessageSearchListView` `paginationParams` property is now deprecated in favor of `limit`. - ```dart - // previous - paginationParams = const PaginationParams(limit: 30) - - // new - limit = 30 - ``` + ```dart + // previous + paginationParams = const PaginationParams(limit: 30) + + // new + limit = 30 + ``` - `UserListView` `pagination` property is now deprecated in favor of `limit`. - ```dart - // previous - pagination = const PaginationParams(limit: 30) - - // new - limit = 30 - ``` + ```dart + // previous + pagination = const PaginationParams(limit: 30) + + // new + limit = 30 + ``` - `ChannelListView` `pagination` property is now deprecated in favor of `limit`. - ```dart - // previous - pagination = const PaginationParams(limit: 30) - - // new - limit = 30 - ``` + ```dart + // previous + pagination = const PaginationParams(limit: 30) + + // new + limit = 30 + ``` 🔄 Changed - `UserListViewCore` filter property now has a default value. - ```dart - filter = const Filter.empty() - ``` + ```dart + filter = const Filter.empty() + ``` 🐞 Fixed @@ -123,11 +123,11 @@ - [#516](https://github.com/GetStream/stream-chat-flutter/issues/516): Added `StreamChatThemeData.placeholderUserImage` for building a widget when the `UserAvatar` image is loading - Added a `backgroundColor` property to the following widgets: - - `ChannelHeader` - - `ChannelListHeader` - - `GalleryHeader` - - `GalleryFooter` - - `ThreadHeader` + - `ChannelHeader` + - `ChannelListHeader` + - `GalleryHeader` + - `GalleryFooter` + - `ThreadHeader` - Added `MessageInput.attachmentLimit` in order to limit the no. of attachments that can be sent with a single message. - Added `MessageInput.onAttachmentLimitExceed` callback which will be called when the `attachmentLimit` is exceeded. This will override the default error alert behaviour. @@ -141,7 +141,7 @@ typedef ActionButtonBuilder = Widget Function( ``` > **_NOTE:_** The last parameter is the default `ActionButton` -> You can call `.copyWith` to customize just a subset of properties. +You can call `.copyWith` to customize just a subset of properties. - Added slow mode which allows a cooldown period after a user sends a message. @@ -150,18 +150,18 @@ typedef ActionButtonBuilder = Widget Function( Theming has been upgraded! Most theme classes now have `InheritedTheme` classes associated with them, and have been upgraded with some goodies like `lerp` functions. Here's the full naming breakdown: -- `AvatarTheme` is now `AvatarThemeData` -- `ChannelHeaderTheme` is now `ChannelHeaderThemeData` -- `ChannelListHeaderTheme` is now `ChannelListHeaderThemeData` -- `ChannelListViewTheme` is now `ChannelListViewThemeData` -- `ChannelPreviewTheme` is now `ChannelPreviewThemeData` -- `MessageInputTheme` is now `MessageInputThemeData` -- `MessageListViewTheme` is now `MessageListViewTheme` -- `MessageSearchListViewTheme` is now `MessageSearchListViewThemeData` -- `MessageTheme` is now `MessageThemeData` -- `UserListViewTheme` is now `UserListViewThemeData` +* `AvatarTheme` is now `AvatarThemeData` +* `ChannelHeaderTheme` is now `ChannelHeaderThemeData` +* `ChannelListHeaderTheme` is now `ChannelListHeaderThemeData` +* `ChannelListViewTheme` is now `ChannelListViewThemeData` +* `ChannelPreviewTheme` is now `ChannelPreviewThemeData` +* `MessageInputTheme` is now `MessageInputThemeData` +* `MessageListViewTheme` is now `MessageListViewTheme` +* `MessageSearchListViewTheme` is now `MessageSearchListViewThemeData` +* `MessageTheme` is now `MessageThemeData` +* `UserListViewTheme` is now `UserListViewThemeData` -* Updated core dependency. +- Updated core dependency. 🐞 Fixed @@ -208,25 +208,24 @@ upgraded with some goodies like `lerp` functions. Here's the full naming breakdo - Renamed `ChannelImage` to `ChannelAvatar` - Updated `StreamChatThemeData.reactionIcons` to accept custom builder - Renamed `ColorTheme` properties to reflect the purpose of the colors - - - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` - - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` - - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` - - `ColorTheme.greyWhisper` -> `ColorTheme.borders` - - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` - - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` - - `ColorTheme.white` -> `ColorTheme.barsBg` - - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` - - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` - - `ColorTheme.accentRed` -> `ColorTheme.accentError` - - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` + - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` + - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` + - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` + - `ColorTheme.greyWhisper` -> `ColorTheme.borders` + - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` + - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` + - `ColorTheme.white` -> `ColorTheme.barsBg` + - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` + - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` + - `ColorTheme.accentRed` -> `ColorTheme.accentError` + - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` - `ChannelListCore` options property is removed in favor of individual properties - - `options.state` -> bool state - - `options.watch` -> bool watch - - `options.presence` -> bool presence + - `options.state` -> bool state + - `options.watch` -> bool watch + - `options.presence` -> bool presence - `UserListView` options property is removed in favor of individual properties - - `options.presence` -> bool presence + - `options.presence` -> bool presence - Renamed `ImageHeader` to `GalleryHeader` - Renamed `ImageFooter` to `GalleryFooter` - `MessageBuilder` and `ParentMessageBuilder` signature is now @@ -241,7 +240,8 @@ typedef MessageBuilder = Widget Function( ``` > **_NOTE:_** the last parameter is the default `MessageWidget` -> You can call `.copyWith` to customize just a subset of properties +You can call `.copyWith` to customize just a subset of properties + ✅ Added @@ -269,17 +269,17 @@ typedef MessageBuilder = Widget Function( 🛑️ Breaking Changes from `2.0.0-nullsafety.8` - Renamed `ColorTheme` properties to reflect the purpose of the colors - - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` - - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` - - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` - - `ColorTheme.greyWhisper` -> `ColorTheme.borders` - - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` - - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` - - `ColorTheme.white` -> `ColorTheme.barsBg` - - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` - - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` - - `ColorTheme.accentRed` -> `ColorTheme.accentError` - - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` + - `ColorTheme.black` -> `ColorTheme.textHighEmphasis` + - `ColorTheme.grey` -> `ColorTheme.textLowEmphasis` + - `ColorTheme.greyGainsboro` -> `ColorTheme.disabled` + - `ColorTheme.greyWhisper` -> `ColorTheme.borders` + - `ColorTheme.whiteSmoke` -> `ColorTheme.inputBg` + - `ColorTheme.whiteSnow` -> `ColorTheme.appBg` + - `ColorTheme.white` -> `ColorTheme.barsBg` + - `ColorTheme.blueAlice` -> `ColorTheme.linkBg` + - `ColorTheme.accentBlue` -> `ColorTheme.accentPrimary` + - `ColorTheme.accentRed` -> `ColorTheme.accentError` + - `ColorTheme.accentGreen` -> `ColorTheme.accentInfo` ✅ Added @@ -290,11 +290,11 @@ typedef MessageBuilder = Widget Function( 🛑️ Breaking Changes from `2.0.0-nullsafety.7` - `ChannelListCore` options property is removed in favor of individual properties - - `options.state` -> bool state - - `options.watch` -> bool watch - - `options.presence` -> bool presence + - `options.state` -> bool state + - `options.watch` -> bool watch + - `options.presence` -> bool presence - `UserListView` options property is removed in favor of individual properties - - `options.presence` -> bool presence + - `options.presence` -> bool presence - `MessageBuilder` and `ParentMessageBuilder` signature is now ```dart @@ -307,7 +307,7 @@ typedef MessageBuilder = Widget Function( ``` > **_NOTE:_** The last parameter is the default `MessageWidget` -> You can call `.copyWith` to customize just a subset of properties. +You can call `.copyWith` to customize just a subset of properties. ✅ Added @@ -866,4 +866,4 @@ The property showVideoFullScreen was added mainly because of this issue brianega ## 0.0.1 -- First release +- First release \ No newline at end of file From 9884c0452df8beb9cd1e4cbec8ff02ead20da94a Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:47:32 +0530 Subject: [PATCH 12/21] added spacing types --- .../lib/src/message_list_view.dart | 78 +++++++++++++++++-- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index 5424a1c2..8d4409bc 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -58,6 +58,44 @@ typedef OnMessageTap = void Function(Message); /// Callback on reply tapped typedef ReplyTapCallback = void Function(Message); +/// Spacing Types (These are properties of a message to help inform the decision +/// of how much space / which widget to build after it) +enum SpacingType { + /// Message is a thread + thread, + + /// There is a >1s time diff between current and last message + timeDiff, + + /// Next message is by a different user + otherUser, + + /// Message is deleted + deleted, + + /// No other conditions are valid, default spacing (This will likely be the + /// only rule in the list provided) + defaultSpacing, +} + +/// Builder for building certain spacing after widgets. +/// This spacing can be in form of any widgets you like. +/// A List of [SpacingType] is provided to help inform the decision of +/// what to build after the message. +/// +/// As an example: +/// MessageListView( +/// spacingWidgetBuilder: (context, list) { +/// if(list.contains(SpacingType.defaultSpacing)) { +/// return SizedBox(height: 2.0,); +/// } else { +/// return SizedBox(height: 8.0,); +/// } +/// }, +/// ), +typedef SpacingWidgetBuilder = Widget Function( + BuildContext context, List spacingTypes); + /// Class for message details // ignore: prefer-match-file-name class MessageDetails { @@ -171,6 +209,7 @@ class MessageListView extends StatefulWidget { this.reverse = true, this.paginationLimit = 20, this.paginationLoadingIndicatorBuilder, + this.spacingWidgetBuilder, }) : super(key: key); /// Function used to build a custom message widget @@ -289,6 +328,12 @@ class MessageListView extends StatefulWidget { /// Builder used to build the loading indicator shown while paginating. final WidgetBuilder? paginationLoadingIndicatorBuilder; + /// This allows a user to customise the space after a message + /// A List of [SpacingType] is provided to provide more data about the + /// type of message (thread, difference in time between current and last + /// message, default spacing, etc) + final SpacingWidgetBuilder? spacingWidgetBuilder; + @override _MessageListViewState createState() => _MessageListViewState(); } @@ -564,17 +609,38 @@ class _MessageListViewState extends State { Units.MINUTE, ); + final spacingRules = []; + final isNextUserSame = message.user!.id == nextMessage.user?.id; final isThread = message.replyCount! > 0; final isDeleted = message.isDeleted; - if (timeDiff >= 1 || - !isNextUserSame || - isThread || - isDeleted) { - return const SizedBox(height: 8); + final hasTimeDiff = timeDiff >= 1; + + if (hasTimeDiff) { + spacingRules.add(SpacingType.timeDiff); } - return const SizedBox(height: 2); + + if (!isNextUserSame) { + spacingRules.add(SpacingType.otherUser); + } + + if (isThread) { + spacingRules.add(SpacingType.thread); + } + + if (isDeleted) { + spacingRules.add(SpacingType.deleted); + } + + if (spacingRules.isNotEmpty) { + return widget.spacingWidgetBuilder + ?.call(context, spacingRules) ?? + const SizedBox(height: 8); + } + return widget.spacingWidgetBuilder + ?.call(context, [SpacingType.defaultSpacing]) ?? + const SizedBox(height: 2); }, itemBuilder: (context, i) { if (i == itemCount - 1) { From 3470ed0bf19be17896abde1444e4a12cefc83872 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:48:50 +0530 Subject: [PATCH 13/21] added changelog --- packages/stream_chat_flutter/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 00f8412b..d85d75e1 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +✅ Added + +- `MessageListView` now allows more better control over spacing after messages using `spacingWidgetBuilder`. + ## 3.2.0 - Updated Dart SDK constraints to `>=2.14.0 <3.0.0` From a6943ed00b1b155e823c536272b4e6842498b38b Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:50:58 +0530 Subject: [PATCH 14/21] fmt --- packages/stream_chat_flutter/lib/src/message_list_view.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index 8d4409bc..94824ef4 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -94,7 +94,9 @@ enum SpacingType { /// }, /// ), typedef SpacingWidgetBuilder = Widget Function( - BuildContext context, List spacingTypes); + BuildContext context, + List spacingTypes, +); /// Class for message details // ignore: prefer-match-file-name From 811a21079b820fe10dbedd3b119d2d5d7a18b620 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:57:05 +0530 Subject: [PATCH 15/21] analysis --- packages/stream_chat_flutter/lib/src/gallery_footer.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery_footer.dart index dcfa0e29..0acd9b02 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_footer.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; From 687fa6cfce4494416a201170526349c8a64e0c59 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 19:13:07 +0530 Subject: [PATCH 16/21] added back dio --- packages/stream_chat_flutter/lib/src/gallery_footer.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat_flutter/lib/src/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery_footer.dart index 0acd9b02..dcfa0e29 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_footer.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; From 643f809eba76db0af73dea029671de147f4e2699 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Tue, 16 Nov 2021 17:18:54 +0530 Subject: [PATCH 17/21] fixed membercount null error --- packages/stream_chat_flutter/CHANGELOG.md | 6 ++++++ packages/stream_chat_flutter/lib/src/message_widget.dart | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 00f8412b..413537fb 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🐞 Fixed + +- Fixed `MessageWidget` null errors associated with `channel.memberCount`. + ## 3.2.0 - Updated Dart SDK constraints to `>=2.14.0 <3.0.0` diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index f6ae52c6..cd2488c3 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -1230,6 +1230,7 @@ class _MessageWidgetState extends State Widget _buildSendingIndicator() { final style = widget.messageTheme.createdAtStyle; final message = widget.message; + final memberCount = StreamChannel.of(context).channel.memberCount ?? 0; if (hasNonUrlAttachments && (message.status == MessageSendingStatus.sending || @@ -1260,7 +1261,7 @@ class _MessageWidgetState extends State if (isMessageRead) { child = Row( children: [ - if (StreamChannel.of(context).channel.memberCount! > 2) + if (memberCount > 2) Text( widget.readList!.length.toString(), style: style.copyWith( From bd637caebfd980b6b789a1224e0ffaa79ef1ca60 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 16 Nov 2021 13:06:28 +0100 Subject: [PATCH 18/21] chore(repo): update melos in ci --- .github/workflows/dart_code_metrics.yaml | 2 +- .github/workflows/stream_flutter_workflow.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 0ae85b88..667ac2dd 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -33,7 +33,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" - run: flutter pub global activate melos 1.0.0-dev.6 + run: flutter pub global activate melos 1.0.0-dev.10 - name: "Bootstrap Workspace" run: melos bootstrap diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 65913a18..b91dcb85 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -31,7 +31,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | - flutter pub global activate melos 1.0.0-dev.6 + flutter pub global activate melos 1.0.0-dev.10 - name: "Bootstrap Workspace" run: melos bootstrap - name: "Dart Analyze" From 2f5b3a444cf5aa60e76f126f923336116d1ac955 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 16 Nov 2021 17:16:33 +0100 Subject: [PATCH 19/21] chore(ui): remove dependecy --- packages/stream_chat_flutter/lib/src/gallery_footer.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery_footer.dart index dcfa0e29..0acd9b02 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_footer.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; From 1c25d415d6e6c1a3a5bd80e8524269da0c335395 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 17 Nov 2021 11:31:51 +0100 Subject: [PATCH 20/21] fix(ui): export attachment_actions_modal --- packages/stream_chat_flutter/lib/stream_chat_flutter.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart index 0447fc68..cd0d93a0 100644 --- a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart +++ b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart @@ -2,6 +2,7 @@ export 'package:jiffy/jiffy.dart'; export 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; export 'src/attachment/attachment.dart'; +export 'src/attachment_actions_modal.dart'; export 'src/back_button.dart'; export 'src/channel_avatar.dart'; export 'src/channel_header.dart'; From ebd6b45efdc340a39c09567877ba872bd08059f8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 18 Nov 2021 17:08:16 +0100 Subject: [PATCH 21/21] chore(ui): update changelog --- packages/stream_chat_flutter/CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 4a92c76f..5d119e8c 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -4,8 +4,6 @@ - `MessageListView` now allows more better control over spacing after messages using `spacingWidgetBuilder`. -## Upcoming - 🐞 Fixed - Fixed `MessageWidget` null errors associated with `channel.memberCount`.