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/24] 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/24] 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 7f8f4a91c78d7e9a51affa6dcc37c21b212bd0da Mon Sep 17 00:00:00 2001 From: geweald Date: Wed, 10 Nov 2021 18:22:16 +0100 Subject: [PATCH 03/24] 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 04/24] 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 05/24] 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 3a04e4f390631fb24f487ac26217572ea6ee77ab Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 17:18:30 +0530 Subject: [PATCH 06/24] added customisation options for attachment actions modal and related widgets --- .../lib/src/attachment_actions_modal.dart | 164 ++++++++++-------- .../lib/src/full_screen_media.dart | 20 +++ .../lib/src/gallery_header.dart | 20 +++ 3 files changed, 132 insertions(+), 72 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index f49561aa..96e040fd 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -24,6 +24,10 @@ class AttachmentActionsModal extends StatelessWidget { this.onShowMessage, this.imageDownloader, this.fileDownloader, + this.showReply = true, + this.showShowInChat = true, + this.showSave = true, + this.showDelete = true, }) : super(key: key); /// The message containing the attachments @@ -41,6 +45,18 @@ class AttachmentActionsModal extends StatelessWidget { /// Callback to provide download files final AttachmentDownloader? fileDownloader; + /// Show reply option + final bool showReply; + + /// Show show in chat option + final bool showShowInChat; + + /// Show save option + final bool showSave; + + /// Show delete option + final bool showDelete; + @override Widget build(BuildContext context) => GestureDetector( behavior: HitTestBehavior.translucent, @@ -67,82 +83,86 @@ class AttachmentActionsModal extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, mainAxisSize: MainAxisSize.min, children: [ - _buildButton( - context, - context.translations.replyLabel, - StreamSvgIcon.iconCurveLineLeftUp( - size: 24, - color: theme.colorTheme.textLowEmphasis, + if (showReply) + _buildButton( + context, + context.translations.replyLabel, + StreamSvgIcon.iconCurveLineLeftUp( + size: 24, + color: theme.colorTheme.textLowEmphasis, + ), + () { + Navigator.pop(context, ReturnActionType.reply); + }, ), - () { - Navigator.pop(context, ReturnActionType.reply); - }, - ), - _buildButton( - context, - context.translations.showInChatLabel, - StreamSvgIcon.eye( - size: 24, - color: theme.colorTheme.textHighEmphasis, + if (showShowInChat) + _buildButton( + context, + context.translations.showInChatLabel, + StreamSvgIcon.eye( + size: 24, + color: theme.colorTheme.textHighEmphasis, + ), + onShowMessage, ), - onShowMessage, - ), - _buildButton( - context, - message.attachments[currentIndex].type == 'video' - ? context.translations.saveVideoLabel - : context.translations.saveImageLabel, - StreamSvgIcon.iconSave( - size: 24, - color: theme.colorTheme.textLowEmphasis, + if (showSave) + _buildButton( + context, + message.attachments[currentIndex].type == 'video' + ? context.translations.saveVideoLabel + : context.translations.saveImageLabel, + StreamSvgIcon.iconSave( + size: 24, + color: theme.colorTheme.textLowEmphasis, + ), + () { + final attachment = message.attachments[currentIndex]; + final isImage = attachment.type == 'image'; + final Future Function( + Attachment, { + void Function(int, int) progressCallback, + }) saveFile = fileDownloader ?? _downloadAttachment; + final Future Function( + Attachment, { + void Function(int, int) progressCallback, + }) saveImage = imageDownloader ?? _downloadAttachment; + final downloader = isImage ? saveImage : saveFile; + + final progressNotifier = + ValueNotifier<_DownloadProgress?>( + _DownloadProgress.initial(), + ); + + downloader( + attachment, + progressCallback: (received, total) { + progressNotifier.value = _DownloadProgress( + total, + received, + ); + }, + ).catchError((e, stk) { + progressNotifier.value = null; + }); + + // Closing attachment actions modal before opening + // attachment download dialog + Navigator.pop(context); + + showDialog( + barrierDismissible: false, + context: context, + barrierColor: theme.colorTheme.overlay, + builder: (context) => _buildDownloadProgressDialog( + context, + progressNotifier, + ), + ); + }, ), - () { - final attachment = message.attachments[currentIndex]; - final isImage = attachment.type == 'image'; - final Future Function( - Attachment, { - void Function(int, int) progressCallback, - }) saveFile = fileDownloader ?? _downloadAttachment; - final Future Function( - Attachment, { - void Function(int, int) progressCallback, - }) saveImage = imageDownloader ?? _downloadAttachment; - final downloader = isImage ? saveImage : saveFile; - - final progressNotifier = - ValueNotifier<_DownloadProgress?>( - _DownloadProgress.initial(), - ); - - downloader( - attachment, - progressCallback: (received, total) { - progressNotifier.value = _DownloadProgress( - total, - received, - ); - }, - ).catchError((e, stk) { - progressNotifier.value = null; - }); - - // Closing attachment actions modal before opening - // attachment download dialog - Navigator.pop(context); - - showDialog( - barrierDismissible: false, - context: context, - barrierColor: theme.colorTheme.overlay, - builder: (context) => _buildDownloadProgressDialog( - context, - progressNotifier, - ), - ); - }, - ), if (StreamChat.of(context).currentUser?.id == - message.user?.id) + message.user?.id && + showDelete) _buildButton( context, context.translations.deleteLabel.capitalize(), diff --git a/packages/stream_chat_flutter/lib/src/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/full_screen_media.dart index 0c47383c..6fe2b2a4 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -33,6 +33,10 @@ class FullScreenMedia extends StatefulWidget { this.startIndex = 0, String? userName, this.onShowMessage, + this.showReply = true, + this.showShowInChat = true, + this.showSave = true, + this.showDelete = true, }) : userName = userName ?? '', super(key: key); @@ -51,6 +55,18 @@ class FullScreenMedia extends StatefulWidget { /// Callback for when show message is tapped final ShowMessageCallback? onShowMessage; + /// Show reply option + final bool showReply; + + /// Show show in chat option + final bool showShowInChat; + + /// Show save option + final bool showSave; + + /// Show delete option + final bool showDelete; + @override _FullScreenMediaState createState() => _FullScreenMediaState(); } @@ -196,6 +212,10 @@ class _FullScreenMediaState extends State StreamChannel.of(context).channel, ); }, + showReply: widget.showReply, + showShowInChat: widget.showShowInChat, + showSave: widget.showSave, + showDelete: widget.showDelete, ), if (!widget.message.isEphemeral) GalleryFooter( diff --git a/packages/stream_chat_flutter/lib/src/gallery_header.dart b/packages/stream_chat_flutter/lib/src/gallery_header.dart index fc5f67b4..638375eb 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_header.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_header.dart @@ -21,6 +21,10 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { this.userName = '', this.sentAt = '', this.backgroundColor, + this.showReply = true, + this.showShowInChat = true, + this.showSave = true, + this.showDelete = true, }) : preferredSize = const Size.fromHeight(kToolbarHeight), super(key: key); @@ -55,6 +59,18 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { /// The background color of this [GalleryHeader]. final Color? backgroundColor; + /// Show reply option + final bool showReply; + + /// Show show in chat option + final bool showShowInChat; + + /// Show save option + final bool showSave; + + /// Show delete option + final bool showDelete; + @override Widget build(BuildContext context) { final galleryHeaderThemeData = GalleryHeaderTheme.of(context); @@ -133,6 +149,10 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { message: message, currentIndex: currentIndex, onShowMessage: onShowMessage, + showReply: showReply, + showShowInChat: showShowInChat, + showSave: showSave, + showDelete: showDelete, ), ), ); From 81508ac8baa54139edddc1949cadb139f5ba5a86 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 17:20:40 +0530 Subject: [PATCH 07/24] 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..c9880c1e 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🐞 Fixed + +- [[#766]]`AttachmentActionsModal` now has customisation options for actions. + ## 3.2.0 - Updated Dart SDK constraints to `>=2.14.0 <3.0.0` From 5740e53adad7392a45590f59ae1f20fb1d1d1e0e Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:00:45 +0530 Subject: [PATCH 08/24] added attachment actions modal builder --- .../lib/src/attachment/giphy_attachment.dart | 4 ++ .../lib/src/attachment/image_attachment.dart | 5 ++ .../lib/src/attachment/video_attachment.dart | 5 ++ .../lib/src/attachment_actions_modal.dart | 26 +++++++++++ .../lib/src/full_screen_media.dart | 23 ++-------- .../lib/src/gallery_header.dart | 46 +++++++++---------- .../lib/src/image_group.dart | 5 ++ 7 files changed, 71 insertions(+), 43 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart index fc0fb586..215ada51 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -18,6 +18,7 @@ class GiphyAttachment extends AttachmentWidget { this.onShowMessage, this.onReturnAction, this.onAttachmentTap, + this.attachmentActionsModalBuilder, }) : super( key: key, message: message, @@ -34,6 +35,8 @@ class GiphyAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) { final imageUrl = @@ -250,6 +253,7 @@ class GiphyAttachment extends AttachmentWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, + attachmentActionsModalBuilder: attachmentActionsModalBuilder, ), ); }, 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 41b8d039..239cf2a2 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -21,6 +21,7 @@ class ImageAttachment extends AttachmentWidget { this.onShowMessage, this.onReturnAction, this.onAttachmentTap, + this.attachmentActionsModalBuilder, }) : super( key: key, message: message, @@ -43,6 +44,8 @@ class ImageAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) => source.when( local: () { @@ -145,6 +148,8 @@ class ImageAttachment extends AttachmentWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, + attachmentActionsModalBuilder: + attachmentActionsModalBuilder, ), ); }, diff --git a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart index ce4ac804..40a1bff3 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -18,6 +18,7 @@ class VideoAttachment extends AttachmentWidget { this.onShowMessage, this.onReturnAction, this.onAttachmentTap, + this.attachmentActionsModalBuilder, }) : super( key: key, message: message, @@ -37,6 +38,8 @@ class VideoAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) => source.when( local: () { @@ -91,6 +94,8 @@ class VideoAttachment extends AttachmentWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, + attachmentActionsModalBuilder: + attachmentActionsModalBuilder, ), ), ), diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index 96e040fd..89527a48 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -57,6 +57,32 @@ class AttachmentActionsModal extends StatelessWidget { /// Show delete option final bool showDelete; + /// Creates a copy of [MessageWidget] with specified attributes overridden. + AttachmentActionsModal copyWith({ + Key? key, + int? currentIndex, + Message? message, + VoidCallback? onShowMessage, + AttachmentDownloader? imageDownloader, + AttachmentDownloader? fileDownloader, + bool? showReply, + bool? showShowInChat, + bool? showSave, + bool? showDelete, + }) => + AttachmentActionsModal( + key: key ?? this.key, + currentIndex: currentIndex ?? this.currentIndex, + message: message ?? this.message, + onShowMessage: onShowMessage ?? this.onShowMessage, + imageDownloader: imageDownloader ?? this.imageDownloader, + fileDownloader: fileDownloader ?? this.fileDownloader, + showReply: showReply ?? this.showReply, + showShowInChat: showShowInChat ?? this.showShowInChat, + showSave: showSave ?? this.showSave, + showDelete: showDelete ?? this.showDelete, + ); + @override Widget build(BuildContext context) => GestureDetector( behavior: HitTestBehavior.translucent, diff --git a/packages/stream_chat_flutter/lib/src/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/full_screen_media.dart index 6fe2b2a4..566f8f3f 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -33,10 +33,7 @@ class FullScreenMedia extends StatefulWidget { this.startIndex = 0, String? userName, this.onShowMessage, - this.showReply = true, - this.showShowInChat = true, - this.showSave = true, - this.showDelete = true, + this.attachmentActionsModalBuilder, }) : userName = userName ?? '', super(key: key); @@ -55,17 +52,7 @@ class FullScreenMedia extends StatefulWidget { /// Callback for when show message is tapped final ShowMessageCallback? onShowMessage; - /// Show reply option - final bool showReply; - - /// Show show in chat option - final bool showShowInChat; - - /// Show save option - final bool showSave; - - /// Show delete option - final bool showDelete; + final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override _FullScreenMediaState createState() => _FullScreenMediaState(); @@ -212,10 +199,8 @@ class _FullScreenMediaState extends State StreamChannel.of(context).channel, ); }, - showReply: widget.showReply, - showShowInChat: widget.showShowInChat, - showSave: widget.showSave, - showDelete: widget.showDelete, + attachmentActionsModalBuilder: + widget.attachmentActionsModalBuilder, ), if (!widget.message.isEphemeral) GalleryFooter( diff --git a/packages/stream_chat_flutter/lib/src/gallery_header.dart b/packages/stream_chat_flutter/lib/src/gallery_header.dart index 638375eb..bc19979e 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_header.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_header.dart @@ -6,6 +6,12 @@ import 'package:stream_chat_flutter/src/stream_svg_icon.dart'; import 'package:stream_chat_flutter/src/theme/themes.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; +typedef AttachmentActionsBuilder = Widget Function( + BuildContext context, + Attachment attachment, + AttachmentActionsModal defaultActionsModal, +); + /// Header/AppBar widget for media display screen class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { /// Creates a channel header @@ -21,10 +27,7 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { this.userName = '', this.sentAt = '', this.backgroundColor, - this.showReply = true, - this.showShowInChat = true, - this.showSave = true, - this.showDelete = true, + this.attachmentActionsModalBuilder, }) : preferredSize = const Size.fromHeight(kToolbarHeight), super(key: key); @@ -59,17 +62,7 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { /// The background color of this [GalleryHeader]. final Color? backgroundColor; - /// Show reply option - final bool showReply; - - /// Show show in chat option - final bool showShowInChat; - - /// Show save option - final bool showSave; - - /// Show delete option - final bool showDelete; + final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override Widget build(BuildContext context) { @@ -139,21 +132,26 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { final galleryHeaderThemeData = StreamChatTheme.of(context).galleryHeaderTheme; + final defaultModal = AttachmentActionsModal( + message: message, + currentIndex: currentIndex, + onShowMessage: onShowMessage, + ); + + final effectiveModal = attachmentActionsModalBuilder?.call( + context, + message.attachments[currentIndex], + defaultModal, + ) ?? + defaultModal; + final result = await showDialog( useRootNavigator: false, context: context, barrierColor: galleryHeaderThemeData.bottomSheetBarrierColor, builder: (context) => StreamChannel( channel: channel, - child: AttachmentActionsModal( - message: message, - currentIndex: currentIndex, - onShowMessage: onShowMessage, - showReply: showReply, - showShowInChat: showShowInChat, - showSave: showSave, - showDelete: showDelete, - ), + child: effectiveModal, ), ); diff --git a/packages/stream_chat_flutter/lib/src/image_group.dart b/packages/stream_chat_flutter/lib/src/image_group.dart index 88b309fe..04fe8032 100644 --- a/packages/stream_chat_flutter/lib/src/image_group.dart +++ b/packages/stream_chat_flutter/lib/src/image_group.dart @@ -16,6 +16,7 @@ class ImageGroup extends StatelessWidget { this.onReturnAction, this.onShowMessage, this.onAttachmentTap, + this.attachmentActionsModalBuilder, }) : super(key: key); /// List of attachments to show @@ -39,6 +40,8 @@ class ImageGroup extends StatelessWidget { /// Callback for when show message is tapped final ShowMessageCallback? onShowMessage; + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) => ConstrainedBox( constraints: BoxConstraints.loose(size), @@ -138,6 +141,7 @@ class ImageGroup extends StatelessWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, + attachmentActionsModalBuilder: attachmentActionsModalBuilder, ), ), ), @@ -151,5 +155,6 @@ class ImageGroup extends StatelessWidget { message: message, messageTheme: messageTheme, onAttachmentTap: () => _onTap(context, index), + attachmentActionsModalBuilder: attachmentActionsModalBuilder, ); } From 5223aa6b4a52776255e53e6f25e8e95fea3726dc Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:04:49 +0530 Subject: [PATCH 09/24] added docs --- .../lib/src/attachment/giphy_attachment.dart | 4 ++++ .../lib/src/attachment/image_attachment.dart | 3 +++ .../lib/src/attachment/video_attachment.dart | 3 +++ packages/stream_chat_flutter/lib/src/full_screen_media.dart | 3 +++ packages/stream_chat_flutter/lib/src/gallery_header.dart | 6 ++++++ packages/stream_chat_flutter/lib/src/image_group.dart | 3 +++ 6 files changed, 22 insertions(+) diff --git a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart index 215ada51..7c8ad684 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart'; +import 'package:stream_chat_flutter/src/attachment_actions_modal.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/visible_footnote.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -35,6 +36,9 @@ class GiphyAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; + /// Widget builder for attachment actions modal + /// [defaultActionsModal] is the default [AttachmentActionsModal] config + /// Use [defaultActionsModal.copyWith] to easily customize it final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override 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 239cf2a2..7711ad1f 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -44,6 +44,9 @@ class ImageAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; + /// Widget builder for attachment actions modal + /// [defaultActionsModal] is the default [AttachmentActionsModal] config + /// Use [defaultActionsModal.copyWith] to easily customize it final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override diff --git a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart index 40a1bff3..a712b40b 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -38,6 +38,9 @@ class VideoAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; + /// Widget builder for attachment actions modal + /// [defaultActionsModal] is the default [AttachmentActionsModal] config + /// Use [defaultActionsModal.copyWith] to easily customize it final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override diff --git a/packages/stream_chat_flutter/lib/src/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/full_screen_media.dart index 566f8f3f..6547a93d 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -52,6 +52,9 @@ class FullScreenMedia extends StatefulWidget { /// Callback for when show message is tapped final ShowMessageCallback? onShowMessage; + /// Widget builder for attachment actions modal + /// [defaultActionsModal] is the default [AttachmentActionsModal] config + /// Use [defaultActionsModal.copyWith] to easily customize it final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override diff --git a/packages/stream_chat_flutter/lib/src/gallery_header.dart b/packages/stream_chat_flutter/lib/src/gallery_header.dart index bc19979e..2325af69 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_header.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_header.dart @@ -6,6 +6,9 @@ import 'package:stream_chat_flutter/src/stream_svg_icon.dart'; import 'package:stream_chat_flutter/src/theme/themes.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; +/// Widget builder for attachment actions modal +/// [defaultActionsModal] is the default [AttachmentActionsModal] config +/// Use [defaultActionsModal.copyWith] to easily customize it typedef AttachmentActionsBuilder = Widget Function( BuildContext context, Attachment attachment, @@ -62,6 +65,9 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { /// The background color of this [GalleryHeader]. final Color? backgroundColor; + /// Widget builder for attachment actions modal + /// [defaultActionsModal] is the default [AttachmentActionsModal] config + /// Use [defaultActionsModal.copyWith] to easily customize it final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override diff --git a/packages/stream_chat_flutter/lib/src/image_group.dart b/packages/stream_chat_flutter/lib/src/image_group.dart index 04fe8032..851b82e4 100644 --- a/packages/stream_chat_flutter/lib/src/image_group.dart +++ b/packages/stream_chat_flutter/lib/src/image_group.dart @@ -40,6 +40,9 @@ class ImageGroup extends StatelessWidget { /// Callback for when show message is tapped final ShowMessageCallback? onShowMessage; + /// Widget builder for attachment actions modal + /// [defaultActionsModal] is the default [AttachmentActionsModal] config + /// Use [defaultActionsModal.copyWith] to easily customize it final AttachmentActionsBuilder? attachmentActionsModalBuilder; @override From 9884c0452df8beb9cd1e4cbec8ff02ead20da94a Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:47:32 +0530 Subject: [PATCH 10/24] 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 11/24] 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 12/24] 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 13/24] 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 8acc3b9d85fb5486a50c4d1504954182f18321d2 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 18:57:37 +0530 Subject: [PATCH 14/24] 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 ba91a0f019a7f65205a89016a13cf7e23193f7cf Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 19:11:54 +0530 Subject: [PATCH 15/24] 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 687fa6cfce4494416a201170526349c8a64e0c59 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 15 Nov 2021 19:13:07 +0530 Subject: [PATCH 16/24] 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/24] 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/24] 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/24] 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 f3d4eab1a003bcae3d461c0b300ba54f4c957ac7 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 17 Nov 2021 13:53:58 +0530 Subject: [PATCH 20/24] removed builders --- .../lib/src/attachment/giphy_attachment.dart | 8 -------- .../lib/src/attachment/image_attachment.dart | 8 -------- .../lib/src/attachment/video_attachment.dart | 8 -------- packages/stream_chat_flutter/lib/src/image_group.dart | 8 -------- 4 files changed, 32 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart index 7c8ad684..fc0fb586 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -2,7 +2,6 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart'; -import 'package:stream_chat_flutter/src/attachment_actions_modal.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/visible_footnote.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -19,7 +18,6 @@ class GiphyAttachment extends AttachmentWidget { this.onShowMessage, this.onReturnAction, this.onAttachmentTap, - this.attachmentActionsModalBuilder, }) : super( key: key, message: message, @@ -36,11 +34,6 @@ class GiphyAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; - /// Widget builder for attachment actions modal - /// [defaultActionsModal] is the default [AttachmentActionsModal] config - /// Use [defaultActionsModal.copyWith] to easily customize it - final AttachmentActionsBuilder? attachmentActionsModalBuilder; - @override Widget build(BuildContext context) { final imageUrl = @@ -257,7 +250,6 @@ class GiphyAttachment extends AttachmentWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, - attachmentActionsModalBuilder: attachmentActionsModalBuilder, ), ); }, 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 7711ad1f..41b8d039 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -21,7 +21,6 @@ class ImageAttachment extends AttachmentWidget { this.onShowMessage, this.onReturnAction, this.onAttachmentTap, - this.attachmentActionsModalBuilder, }) : super( key: key, message: message, @@ -44,11 +43,6 @@ class ImageAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; - /// Widget builder for attachment actions modal - /// [defaultActionsModal] is the default [AttachmentActionsModal] config - /// Use [defaultActionsModal.copyWith] to easily customize it - final AttachmentActionsBuilder? attachmentActionsModalBuilder; - @override Widget build(BuildContext context) => source.when( local: () { @@ -151,8 +145,6 @@ class ImageAttachment extends AttachmentWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, - attachmentActionsModalBuilder: - attachmentActionsModalBuilder, ), ); }, diff --git a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart index a712b40b..ce4ac804 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -18,7 +18,6 @@ class VideoAttachment extends AttachmentWidget { this.onShowMessage, this.onReturnAction, this.onAttachmentTap, - this.attachmentActionsModalBuilder, }) : super( key: key, message: message, @@ -38,11 +37,6 @@ class VideoAttachment extends AttachmentWidget { /// Callback when attachment is tapped final VoidCallback? onAttachmentTap; - /// Widget builder for attachment actions modal - /// [defaultActionsModal] is the default [AttachmentActionsModal] config - /// Use [defaultActionsModal.copyWith] to easily customize it - final AttachmentActionsBuilder? attachmentActionsModalBuilder; - @override Widget build(BuildContext context) => source.when( local: () { @@ -97,8 +91,6 @@ class VideoAttachment extends AttachmentWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, - attachmentActionsModalBuilder: - attachmentActionsModalBuilder, ), ), ), diff --git a/packages/stream_chat_flutter/lib/src/image_group.dart b/packages/stream_chat_flutter/lib/src/image_group.dart index 851b82e4..88b309fe 100644 --- a/packages/stream_chat_flutter/lib/src/image_group.dart +++ b/packages/stream_chat_flutter/lib/src/image_group.dart @@ -16,7 +16,6 @@ class ImageGroup extends StatelessWidget { this.onReturnAction, this.onShowMessage, this.onAttachmentTap, - this.attachmentActionsModalBuilder, }) : super(key: key); /// List of attachments to show @@ -40,11 +39,6 @@ class ImageGroup extends StatelessWidget { /// Callback for when show message is tapped final ShowMessageCallback? onShowMessage; - /// Widget builder for attachment actions modal - /// [defaultActionsModal] is the default [AttachmentActionsModal] config - /// Use [defaultActionsModal.copyWith] to easily customize it - final AttachmentActionsBuilder? attachmentActionsModalBuilder; - @override Widget build(BuildContext context) => ConstrainedBox( constraints: BoxConstraints.loose(size), @@ -144,7 +138,6 @@ class ImageGroup extends StatelessWidget { userName: message.user?.name, message: message, onShowMessage: onShowMessage, - attachmentActionsModalBuilder: attachmentActionsModalBuilder, ), ), ), @@ -158,6 +151,5 @@ class ImageGroup extends StatelessWidget { message: message, messageTheme: messageTheme, onAttachmentTap: () => _onTap(context, index), - attachmentActionsModalBuilder: attachmentActionsModalBuilder, ); } From 4f1dc72d3a50d27584596756eea9231faaf0d4eb Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 17 Nov 2021 14:03:03 +0530 Subject: [PATCH 21/24] added custom actions --- .../lib/src/attachment_actions_modal.dart | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index 89527a48..7b9f0d51 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -28,6 +28,7 @@ class AttachmentActionsModal extends StatelessWidget { this.showShowInChat = true, this.showSave = true, this.showDelete = true, + this.customActions = const [], }) : super(key: key); /// The message containing the attachments @@ -57,6 +58,9 @@ class AttachmentActionsModal extends StatelessWidget { /// Show delete option final bool showDelete; + /// List of custom actions + final List customActions; + /// Creates a copy of [MessageWidget] with specified attributes overridden. AttachmentActionsModal copyWith({ Key? key, @@ -69,6 +73,7 @@ class AttachmentActionsModal extends StatelessWidget { bool? showShowInChat, bool? showSave, bool? showDelete, + List? customActions, }) => AttachmentActionsModal( key: key ?? this.key, @@ -81,6 +86,7 @@ class AttachmentActionsModal extends StatelessWidget { showShowInChat: showShowInChat ?? this.showShowInChat, showSave: showSave ?? this.showSave, showDelete: showDelete ?? this.showDelete, + customActions: customActions ?? this.customActions, ); @override @@ -217,6 +223,16 @@ class AttachmentActionsModal extends StatelessWidget { }, color: theme.colorTheme.accentError, ), + ...customActions + .map( + (e) => _buildButton( + context, + e.actionTitle, + e.icon, + e.onTap, + ), + ) + .toList(), ] .map((e) => Align( alignment: Alignment.centerRight, @@ -239,7 +255,7 @@ class AttachmentActionsModal extends StatelessWidget { Widget _buildButton( context, String title, - StreamSvgIcon icon, + Widget icon, VoidCallback? onTap, { Color? color, Key? key, @@ -377,3 +393,15 @@ class _DownloadProgress { int get toPercentage => (received * 100) ~/ total; } + +class AttachmentAction { + String actionTitle; + Widget icon; + VoidCallback onTap; + + AttachmentAction({ + required this.actionTitle, + required this.icon, + required this.onTap, + }); +} From ecaba6ebb98b32023cff3b6cf650e9ec2a9984dd Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 17 Nov 2021 14:04:39 +0530 Subject: [PATCH 22/24] added custom actions --- .../lib/src/attachment_actions_modal.dart | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index 7b9f0d51..0c10ae46 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -394,14 +394,21 @@ class _DownloadProgress { int get toPercentage => (received * 100) ~/ total; } +/// Class for custom attachment action class AttachmentAction { - String actionTitle; - Widget icon; - VoidCallback onTap; - + /// Constructor for custom attachment action AttachmentAction({ required this.actionTitle, required this.icon, required this.onTap, }); + + /// Title for the attachment action + String actionTitle; + + /// Icon for the attachment action + Widget icon; + + /// Callback for when the action is tapped + VoidCallback onTap; } From 1c25d415d6e6c1a3a5bd80e8524269da0c335395 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 17 Nov 2021 11:31:51 +0100 Subject: [PATCH 23/24] 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 24/24] 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`.