From 5a45454ac89b30c4d64ea436945a948d5ebf6fc7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 24 Nov 2020 16:02:02 +0100 Subject: [PATCH 01/54] add debounce to mentions overlay --- lib/src/message_input.dart | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index a4bfcd18..5d36fd99 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -380,11 +380,19 @@ class MessageInputState extends State { Future> queryMembers; if (query.isNotEmpty) { - queryMembers = StreamChannel.of(context).channel.queryMembers(filter: { - 'name': { - '\$autocomplete': query, + queryMembers = StreamChannel.of(context).channel.queryMembers( + filter: { + 'name': { + '\$autocomplete': query, + }, }, - }).then((res) => res.members); + sort: [ + SortOption( + 'name', + direction: SortOption.ASC, + ), + ], + ).then((res) => res.members); } final members = StreamChannel.of(context).channel.state.members?.where((m) { @@ -952,6 +960,7 @@ class MessageInputState extends State { } } + Timer _debounce; void _onChange() { final s = textEditingController.text; StreamChannel.of(context).channel.keyStroke( @@ -980,8 +989,14 @@ class MessageInputState extends State { .split(' ') .last .contains('@')) { - _mentionsOverlay = _buildMentionsOverlayEntry(); - Overlay.of(context).insert(_mentionsOverlay); + if (_debounce?.isActive == true) _debounce.cancel(); + _debounce = Timer( + const Duration(milliseconds: 350), + () { + _mentionsOverlay = _buildMentionsOverlayEntry(); + Overlay.of(context).insert(_mentionsOverlay); + }, + ); } } From 897ef850506b06991b45fb94c30d9fbf5de87cd9 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 24 Nov 2020 16:05:21 +0100 Subject: [PATCH 02/54] use offline list if error --- lib/src/message_input.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 5d36fd99..a3956481 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -429,7 +429,7 @@ class MessageInputState extends State { return ListView( padding: const EdgeInsets.all(0), shrinkWrap: true, - children: snapshot.data + children: (snapshot.data ?? members) .map((m) => ListTile( leading: UserAvatar( user: m.user, @@ -991,7 +991,7 @@ class MessageInputState extends State { .contains('@')) { if (_debounce?.isActive == true) _debounce.cancel(); _debounce = Timer( - const Duration(milliseconds: 350), + const Duration(milliseconds: 500), () { _mentionsOverlay = _buildMentionsOverlayEntry(); Overlay.of(context).insert(_mentionsOverlay); From 0c875ab68e9fa08c2e437365e22f1f906b0f6b59 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 24 Nov 2020 16:17:53 +0100 Subject: [PATCH 03/54] update dependencies --- lib/src/message_input.dart | 63 +++++++++++++++++++------------------- pubspec.yaml | 4 +-- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index a3956481..0df0c670 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -938,7 +938,8 @@ class MessageInputState extends State { super.initState(); if (!kIsWeb) { - _keyboardListener = KeyboardVisibility.onChange.listen((visible) { + _keyboardListener = + KeyboardVisibilityController().onChange.listen((visible) { if (visible) { _onChange(); } else { @@ -962,42 +963,42 @@ class MessageInputState extends State { Timer _debounce; void _onChange() { - final s = textEditingController.text; - StreamChannel.of(context).channel.keyStroke( - widget.parentMessage?.id, - ); + if (_debounce?.isActive == true) _debounce.cancel(); + _debounce = Timer( + const Duration(milliseconds: 350), + () { + final s = textEditingController.text; + StreamChannel.of(context).channel.keyStroke( + widget.parentMessage?.id, + ); - setState(() { - _messageIsPresent = s.trim().isNotEmpty; - }); + setState(() { + _messageIsPresent = s.trim().isNotEmpty; + }); - _commandsOverlay?.remove(); - _commandsOverlay = null; - _mentionsOverlay?.remove(); - _mentionsOverlay = null; + _commandsOverlay?.remove(); + _commandsOverlay = null; + _mentionsOverlay?.remove(); + _mentionsOverlay = null; - if (s.trim().startsWith('/')) { - _commandsOverlay = _buildCommandsOverlayEntry(); - Overlay.of(context).insert(_commandsOverlay); - } + if (s.trim().startsWith('/')) { + _commandsOverlay = _buildCommandsOverlayEntry(); + Overlay.of(context).insert(_commandsOverlay); + } - if (_messageIsPresent && - textEditingController.selection.isCollapsed && - textEditingController.selection.baseOffset > 0 && - textEditingController.text - .substring(0, textEditingController.selection.baseOffset) - .split(' ') - .last - .contains('@')) { - if (_debounce?.isActive == true) _debounce.cancel(); - _debounce = Timer( - const Duration(milliseconds: 500), - () { + if (_messageIsPresent && + textEditingController.selection.isCollapsed && + textEditingController.selection.baseOffset > 0 && + textEditingController.text + .substring(0, textEditingController.selection.baseOffset) + .split(' ') + .last + .contains('@')) { _mentionsOverlay = _buildMentionsOverlayEntry(); Overlay.of(context).insert(_mentionsOverlay); - }, - ); - } + } + }, + ); } void _parseExistingMessage(Message message) { diff --git a/pubspec.yaml b/pubspec.yaml index f667acfb..ac5f99e6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,10 +19,10 @@ dependencies: flutter_markdown: ^0.5.0 url_launcher: ^5.4.11 video_player: ^1.0.0 - chewie: ^0.10.4 + chewie: ^0.12.0 file_picker: ^2.0.12 image_picker: ^0.6.7+2 - flutter_keyboard_visibility: ^3.3.0 + flutter_keyboard_visibility: ^4.0.1 stream_chat: ^0.2.13 mime: ^0.9.6+3 visibility_detector: ^0.1.5 From 7ce3e00bb78e27d984ff0bb6f9778959c319a865 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 24 Nov 2020 16:19:56 +0100 Subject: [PATCH 04/54] bump version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5b93f3..15164d4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.13+2 + +- Add debounce to on change messageinput listener + ## 0.2.13+1 - Use TextEditingController.addListener instead of TextField.onChanged diff --git a/pubspec.yaml b/pubspec.yaml index ac5f99e6..c7ebaba9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.13+1 +version: 0.2.13+2 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 9525db4dc3d03fd940810e9bc1b6cf54afc97497 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 24 Nov 2020 16:41:32 +0100 Subject: [PATCH 05/54] add if(mounted) check --- lib/src/message_input.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 0df0c670..db39345f 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -967,6 +967,9 @@ class MessageInputState extends State { _debounce = Timer( const Duration(milliseconds: 350), () { + if (!mounted) { + return; + } final s = textEditingController.text; StreamChannel.of(context).channel.keyStroke( widget.parentMessage?.id, From 362be0b704b5ae3042dedf2d1be06bc04918e245 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 25 Nov 2020 10:19:45 +0100 Subject: [PATCH 06/54] add message tap callbacks --- lib/src/message_list_view.dart | 15 ++ lib/src/message_widget.dart | 310 +++++++++++++++++---------------- lib/src/system_message.dart | 104 ++++++----- 3 files changed, 237 insertions(+), 192 deletions(-) diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 51b26c2a..296656e6 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -103,6 +103,9 @@ class MessageListView extends StatefulWidget { this.threadBuilder, this.onThreadTap, this.dateDividerBuilder, + this.onMessageTap, + this.onSystemMessageTap, + this.onParentMessageTap, this.scrollPhysics = const AlwaysScrollableScrollPhysics(), this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, }) : super(key: key); @@ -120,6 +123,15 @@ class MessageListView extends StatefulWidget { /// By default it calls [Navigator.push] using the widget built using [threadBuilder] final ThreadTapCallback onThreadTap; + /// The function called when tapping on the message when the message is not failed + final Function(Message) onMessageTap; + + /// The function called when tapping on a system message + final Function(Message) onSystemMessageTap; + + /// The function called when tapping on the parent message when the message is not failed + final Function(Message) onParentMessageTap; + /// Parent message in case of a thread final Message parentMessage; @@ -412,6 +424,7 @@ class _MessageListViewState extends State { topRight: Radius.circular(16), bottomRight: Radius.circular(16), ), + onMessageTap: widget.onParentMessageTap, borderSide: isMyMessage ? BorderSide.none : null, showUserAvatar: DisplayWidget.show, messageTheme: isMyMessage @@ -427,6 +440,7 @@ class _MessageListViewState extends State { ) { if (message.type == 'system' && message.text?.isNotEmpty == true) { return SystemMessage( + onMessageTap: widget.onSystemMessageTap, message: message, ); } @@ -464,6 +478,7 @@ class _MessageListViewState extends State { (index == 0 || message.status != MessageSendingStatus.SENT) ? DisplayWidget.show : DisplayWidget.hide, + onMessageTap: widget.onMessageTap, showTimestamp: !isNextUser || readList?.isNotEmpty == true, showEditMessage: isMyMessage, showDeleteMessage: isMyMessage, diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 056e433a..d634b0b8 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -40,7 +40,14 @@ class MessageWidget extends StatefulWidget { /// The function called when tapping on replies final void Function(Message) onThreadTap; + + /// The function called when tapping on the message when the message is not failed + final void Function(Message) onMessageTap; + + /// The builder of MessageInput used while editing this message final Widget Function(BuildContext, Message) editMessageInputBuilder; + + /// The builder of the text of the message final Widget Function(BuildContext, Message) textBuilder; /// Function called on long press @@ -113,6 +120,7 @@ class MessageWidget extends StatefulWidget { Key key, @required this.message, @required this.messageTheme, + this.onMessageTap, this.reverse = false, this.shape, this.attachmentShape, @@ -210,97 +218,108 @@ class _MessageWidgetState extends State { if (widget.showSendingIndicator == DisplayWidget.gone) { leftPadding -= 7; } - return Portal( - child: Padding( - padding: widget.padding ?? EdgeInsets.all(8), - child: Transform( - alignment: Alignment.center, - transform: Matrix4.rotationY(widget.reverse ? pi : 0), - child: FractionallySizedBox( - alignment: Alignment.centerLeft, - widthFactor: 0.75, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Column( + return GestureDetector( + onTap: () => onMessageTap(context), + onLongPress: () => onLongPress(context), + behavior: HitTestBehavior.opaque, + child: Container( + width: double.infinity, + child: Portal( + child: Padding( + padding: widget.padding ?? EdgeInsets.all(8), + child: Transform( + alignment: Alignment.center, + transform: Matrix4.rotationY(widget.reverse ? pi : 0), + child: FractionallySizedBox( + alignment: Alignment.centerLeft, + widthFactor: 0.75, + child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.end, + Column( + crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - if (widget.showSendingIndicator == DisplayWidget.show) - _buildSendingIndicator(), - SizedBox( - width: 2, - ), - if (widget.showSendingIndicator == DisplayWidget.hide) - SizedBox( - width: 8, - ), - if (widget.showUserAvatar == DisplayWidget.show) - _buildUserAvatar(), - SizedBox( - width: 6, - ), - if (widget.showUserAvatar == DisplayWidget.hide) - SizedBox( - width: widget.messageTheme.avatarTheme.constraints - .maxWidth + - 8, - ), - Flexible( - child: Padding( - padding: widget.showReactions - ? EdgeInsets.only( - top: _reactionPadding, - ) - : EdgeInsets.zero, - child: PortalEntry( - portalAnchor: Alignment(0, 1), - childAnchor: Alignment.topRight, - portal: _buildReactionIndicator(context), - child: (widget.message.isDeleted && - widget.message.status != - MessageSendingStatus.FAILED_DELETE) - ? Transform( - alignment: Alignment.center, - transform: Matrix4.rotationY( - widget.reverse ? pi : 0), - child: DeletedMessage( - messageTheme: widget.messageTheme, - ), - ) - : Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - ..._parseAttachments(context), - if (widget.message.text - .trim() - .isNotEmpty) - _buildTextBubble(context), - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + if (widget.showSendingIndicator == + DisplayWidget.show) + _buildSendingIndicator(), + SizedBox( + width: 2, ), - ), + if (widget.showSendingIndicator == + DisplayWidget.hide) + SizedBox( + width: 8, + ), + if (widget.showUserAvatar == DisplayWidget.show) + _buildUserAvatar(), + SizedBox( + width: 6, + ), + if (widget.showUserAvatar == DisplayWidget.hide) + SizedBox( + width: widget.messageTheme.avatarTheme + .constraints.maxWidth + + 8, + ), + Flexible( + child: Padding( + padding: widget.showReactions + ? EdgeInsets.only( + top: _reactionPadding, + ) + : EdgeInsets.zero, + child: PortalEntry( + portalAnchor: Alignment(0, 1), + childAnchor: Alignment.topRight, + portal: _buildReactionIndicator(context), + child: (widget.message.isDeleted && + widget.message.status != + MessageSendingStatus + .FAILED_DELETE) + ? Transform( + alignment: Alignment.center, + transform: Matrix4.rotationY( + widget.reverse ? pi : 0), + child: DeletedMessage( + messageTheme: widget.messageTheme, + ), + ) + : Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + ..._parseAttachments(context), + if (widget.message.text + .trim() + .isNotEmpty) + _buildTextBubble(context), + ], + ), + ), + ), + ), + ], ), + if (widget.showReplyIndicator && + widget.message.replyCount > 0) + _buildReplyIndicator(leftPadding), ], ), - if (widget.showReplyIndicator && - widget.message.replyCount > 0) - _buildReplyIndicator(leftPadding), + if ((widget.message.createdAt != null && + widget.showTimestamp) || + widget.showUsername || + widget.readList?.isNotEmpty == true) + _buildBottomRow(leftPadding), ], ), - if ((widget.message.createdAt != null && - widget.showTimestamp) || - widget.showUsername || - widget.readList?.isNotEmpty == true) - _buildBottomRow(leftPadding), - ], + ), ), ), ), @@ -531,47 +550,42 @@ class _MessageWidgetState extends State { padding: EdgeInsets.only( bottom: 4, ), - child: GestureDetector( - onTap: () => retryMessage(context), - onLongPress: () => onLongPress(context), - child: Material( - color: _getBackgroundColor(), - clipBehavior: Clip.hardEdge, - shape: widget.attachmentShape ?? - widget.shape ?? - ContinuousRectangleBorder( - side: widget.attachmentBorderSide ?? - widget.borderSide ?? - BorderSide( - color: - Theme.of(context).brightness == Brightness.dark - ? Colors.white.withAlpha(24) - : Colors.black.withAlpha(24), - ), - borderRadius: widget.attachmentBorderRadiusGeometry ?? - widget.borderRadiusGeometry ?? - BorderRadius.zero, - ), - child: Padding( - padding: widget.attachmentPadding, - child: Transform( - transform: Matrix4.rotationY(widget.reverse ? pi : 0), - alignment: Alignment.center, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - getFailedMessageWidget( - context, - padding: const EdgeInsets.all(8.0), + child: Material( + color: _getBackgroundColor(), + clipBehavior: Clip.hardEdge, + shape: widget.attachmentShape ?? + widget.shape ?? + ContinuousRectangleBorder( + side: widget.attachmentBorderSide ?? + widget.borderSide ?? + BorderSide( + color: Theme.of(context).brightness == Brightness.dark + ? Colors.white.withAlpha(24) + : Colors.black.withAlpha(24), ), - attachmentBuilder( - context, - widget.message, - attachment, - ), - ], - ), + borderRadius: widget.attachmentBorderRadiusGeometry ?? + widget.borderRadiusGeometry ?? + BorderRadius.zero, + ), + child: Padding( + padding: widget.attachmentPadding, + child: Transform( + transform: Matrix4.rotationY(widget.reverse ? pi : 0), + alignment: Alignment.center, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + getFailedMessageWidget( + context, + padding: const EdgeInsets.all(8.0), + ), + attachmentBuilder( + context, + widget.message, + attachment, + ), + ], ), ), ), @@ -700,33 +714,29 @@ class _MessageWidgetState extends State { } Widget _buildTextBubble(BuildContext context) { - return GestureDetector( - onTap: () => retryMessage(context), - onLongPress: () => onLongPress(context), - child: Material( - shape: widget.shape ?? - ContinuousRectangleBorder( - side: widget.borderSide ?? - BorderSide( - color: Theme.of(context).brightness == Brightness.dark - ? Colors.white.withAlpha(24) - : Colors.black.withAlpha(24), - ), - borderRadius: widget.borderRadiusGeometry ?? BorderRadius.zero, - ), - color: _getBackgroundColor(), - child: Transform( - transform: Matrix4.rotationY(widget.reverse ? pi : 0), - alignment: Alignment.center, - child: Padding( - padding: widget.textPadding, - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - getFailedMessageWidget(context), - _buildText(context), - ], - ), + return Material( + shape: widget.shape ?? + ContinuousRectangleBorder( + side: widget.borderSide ?? + BorderSide( + color: Theme.of(context).brightness == Brightness.dark + ? Colors.white.withAlpha(24) + : Colors.black.withAlpha(24), + ), + borderRadius: widget.borderRadiusGeometry ?? BorderRadius.zero, + ), + color: _getBackgroundColor(), + child: Transform( + transform: Matrix4.rotationY(widget.reverse ? pi : 0), + alignment: Alignment.center, + child: Padding( + padding: widget.textPadding, + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + getFailedMessageWidget(context), + _buildText(context), + ], ), ), ), @@ -741,7 +751,7 @@ class _MessageWidgetState extends State { : widget.messageTheme.messageBackgroundColor; } - void retryMessage(BuildContext context) { + void onMessageTap(BuildContext context) { final channel = StreamChannel.of(context).channel; if (widget.message.status == MessageSendingStatus.FAILED) { channel.sendMessage(widget.message); @@ -762,6 +772,10 @@ class _MessageWidgetState extends State { ); return; } + + if (widget.onMessageTap != null) { + widget.onMessageTap(widget.message); + } } Widget _buildText(BuildContext context) { diff --git a/lib/src/system_message.dart b/lib/src/system_message.dart index 7454b0ee..7b4dc243 100644 --- a/lib/src/system_message.dart +++ b/lib/src/system_message.dart @@ -4,11 +4,16 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// It shows a date divider depending on the date difference class SystemMessage extends StatelessWidget { + /// This message final Message message; + /// The function called when tapping on the message when the message is not failed + final void Function(Message) onMessageTap; + const SystemMessage({ Key key, @required this.message, + this.onMessageTap, }) : super(key: key); @override @@ -44,57 +49,68 @@ class SystemMessage extends StatelessWidget { dayInfo = createdAt.format('dd/MM/yyyy').toUpperCase(); } - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - divider, - Padding( - padding: const EdgeInsets.symmetric(horizontal: 32.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - message.text, - style: TextStyle( - fontSize: 10, - color: Theme.of(context) - .textTheme - .headline6 - .color - .withOpacity(.5), - fontWeight: FontWeight.bold, - ), - ), - Text.rich( - TextSpan( - children: [ + return GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + if (onMessageTap != null) { + onMessageTap(message); + } + }, + child: Container( + width: double.infinity, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + divider, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 32.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + message.text, + style: TextStyle( + fontSize: 10, + color: Theme.of(context) + .textTheme + .headline6 + .color + .withOpacity(.5), + fontWeight: FontWeight.bold, + ), + ), + Text.rich( TextSpan( - text: dayInfo, + children: [ + TextSpan( + text: dayInfo, + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + TextSpan(text: ' AT'), + TextSpan(text: ' $hourInfo'), + ], style: TextStyle( - fontWeight: FontWeight.bold, + fontWeight: FontWeight.normal, ), ), - TextSpan(text: ' AT'), - TextSpan(text: ' $hourInfo'), - ], - style: TextStyle( - fontWeight: FontWeight.normal, + style: TextStyle( + fontSize: 10, + color: Theme.of(context) + .textTheme + .headline6 + .color + .withOpacity(.5), + ), ), - ), - style: TextStyle( - fontSize: 10, - color: Theme.of(context) - .textTheme - .headline6 - .color - .withOpacity(.5), - ), + ], ), - ], - ), + ), + divider, + ], ), - divider, - ], + ), ); } } From 026edeb4805157e62c83813c6394aefa18c4602f Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 25 Nov 2020 10:23:36 +0100 Subject: [PATCH 07/54] bump mp version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15164d4f..672b3da6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.14 + +- Add onMessageTap callbacks + ## 0.2.13+2 - Add debounce to on change messageinput listener diff --git a/pubspec.yaml b/pubspec.yaml index c7ebaba9..069a6b99 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.13+2 +version: 0.2.14 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 18477bf2b6d344504fdc56d4f4655c7ae3a14ffd Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 30 Nov 2020 09:43:12 +0100 Subject: [PATCH 08/54] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ba5de4c1..c5e4c9e7 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ ![](https://img.shields.io/badge/platform-flutter%20%7C%20flutter%20web-ff69b4.svg?style=flat-square) [![Gitter](https://badges.gitter.im/GetStream/stream-chat-flutter.svg)](https://gitter.im/GetStream/stream-chat-flutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) ![CI](https://github.com/GetStream/stream-chat-flutter/workflows/CI/badge.svg?branch=master) -[![codecov](https://codecov.io/gh/GetStream/stream-chat-flutter/branch/master/graph/badge.svg)](https://codecov.io/gh/GetStream/stream-chat-flutter) - **Quick Links** @@ -32,10 +30,10 @@ This repo includes a fully functional example app with setup instructions. The example is available under the [example](https://github.com/GetStream/stream-chat-flutter/tree/master/example) folder. ## Add dependency - +Add this to your package's pubspec.yaml file, use the latest version [![Pub](https://img.shields.io/pub/v/stream_chat_flutter.svg)](https://pub.dartlang.org/packages/stream_chat_flutter) ```yaml dependencies: - stream_chat_flutter: ^0.2.1 + stream_chat_flutter: ^latest_version ``` You should then run `flutter packages get` From 6ce25700d08843595558642ffaa2c1771399876b Mon Sep 17 00:00:00 2001 From: vhubskyi Date: Wed, 2 Dec 2020 10:54:18 +0200 Subject: [PATCH 09/54] add onLongPress on channel when using custom channel builder --- lib/src/channel_list_view.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 121a7d10..12e07dee 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -329,6 +329,9 @@ class _ChannelListViewState extends State onTap: () { onTap(channel, widget.channelWidget); }, + onLongPress: () { + widget.onChannelLongPress(channel); + }, ), ), ), From 9068f386596ebbb2d11e9686a493ce484cc1caeb Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 2 Dec 2020 17:14:33 +0100 Subject: [PATCH 10/54] bump version (#162) --- CHANGELOG.md | 4 ++++ lib/src/channel_list_view.dart | 8 +++++--- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 672b3da6..c7281206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.15 + +- Add onLongPress on channel when using custom channel builder + ## 0.2.14 - Add onMessageTap callbacks diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 12e07dee..d6621d51 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -329,9 +329,11 @@ class _ChannelListViewState extends State onTap: () { onTap(channel, widget.channelWidget); }, - onLongPress: () { - widget.onChannelLongPress(channel); - }, + onLongPress: widget.onChannelLongPress != null + ? () { + widget.onChannelLongPress(channel); + } + : null, ), ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 069a6b99..2fe6110b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.14 +version: 0.2.15 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 0520470f46661f99c9019a717a1ce480c2ac4007 Mon Sep 17 00:00:00 2001 From: "Neevash Ramdial (Nash)" Date: Wed, 2 Dec 2020 12:24:54 -0400 Subject: [PATCH 11/54] Add dart analyser action (#163) * Add dart analyser action * Update flutter-analyze.yml --- .github/workflows/flutter-analyze.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/flutter-analyze.yml diff --git a/.github/workflows/flutter-analyze.yml b/.github/workflows/flutter-analyze.yml new file mode 100644 index 00000000..dc65c8bb --- /dev/null +++ b/.github/workflows/flutter-analyze.yml @@ -0,0 +1,20 @@ +name: Flutter Analyze +on: + push: + branches: + - master + + pull_request: + branches: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + with: + channel: 'beta' + - run: flutter pub get + - run: flutter analyze From 2e846c0f9f916b42cfe381c0d56ec33b63ee7a25 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 3 Dec 2020 17:03:52 +0100 Subject: [PATCH 12/54] do not call markread if channel does not support it --- lib/src/message_list_view.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 296656e6..2bbf4b82 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -532,7 +532,8 @@ class _MessageListViewState extends State { newMessages.first.id != _messages.first.id) { if (!_scrollController.hasClients || _scrollController.offset < _newMessageLoadingOffset) { - if (streamChannel.channel.state.unreadCount > 0) { + if (streamChannel.channel.state.unreadCount > 0 && + streamChannel.channel.config?.readEvents == true) { streamChannel.channel.markRead(); } setState(() { From 5d35551a007565f468f11f7b1532e5946ddb9578 Mon Sep 17 00:00:00 2001 From: Oleksandr Bezpalchuk Date: Mon, 7 Dec 2020 12:21:11 +0200 Subject: [PATCH 13/54] Make public autofocus field of the TextField of message_input --- lib/src/message_input.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index db39345f..fefb5209 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -95,6 +95,7 @@ class MessageInput extends StatefulWidget { this.attachmentThumbnailBuilders, this.inputTextStyle, this.attachmentIconColor, + this.autofocus, }) : super(key: key); /// Message to edit @@ -103,6 +104,9 @@ class MessageInput extends StatefulWidget { /// Message to start with final Message initialMessage; + /// If set true TextField will be active by default. Default is false. + final bool autofocus; + /// Function called after sending the message final void Function(Message) onMessageSent; @@ -258,7 +262,7 @@ class MessageInputState extends State { }); }, style: widget.inputTextStyle ?? Theme.of(context).textTheme.bodyText2, - autofocus: false, + autofocus: widget.autofocus ?? false, decoration: InputDecoration( hintText: 'Write a message', hintStyle: From ac4a60ebb75d52f57fabb1efad324c1a74609f09 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 7 Dec 2020 13:02:10 +0100 Subject: [PATCH 14/54] do not wrap custom channel preview builder to avoid weird behaviour --- lib/src/channel_list_view.dart | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index d6621d51..33988b92 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -316,28 +316,9 @@ class _ChannelListViewState extends State builder: (context) { Widget child; if (widget.channelPreviewBuilder != null) { - child = Stack( - children: [ - widget.channelPreviewBuilder( - context, - channel, - ), - Positioned.fill( - child: Material( - color: Colors.transparent, - child: InkWell( - onTap: () { - onTap(channel, widget.channelWidget); - }, - onLongPress: widget.onChannelLongPress != null - ? () { - widget.onChannelLongPress(channel); - } - : null, - ), - ), - ), - ], + child = widget.channelPreviewBuilder( + context, + channel, ); } else { child = ChannelPreview( From b5b35031d9aa5455598dc3ed704bec196ce15efa Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 7 Dec 2020 13:08:11 +0100 Subject: [PATCH 15/54] fix messageinput autofocus --- .vscode/launch.json | 19 +++++++++++++++++++ lib/src/message_input.dart | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..eb658d4d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "stream-chat-flutter", + "request": "launch", + "type": "dart" + }, + { + "name": "example", + "cwd": "example", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index fefb5209..6836d466 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -95,7 +95,7 @@ class MessageInput extends StatefulWidget { this.attachmentThumbnailBuilders, this.inputTextStyle, this.attachmentIconColor, - this.autofocus, + this.autofocus = false, }) : super(key: key); /// Message to edit @@ -262,7 +262,7 @@ class MessageInputState extends State { }); }, style: widget.inputTextStyle ?? Theme.of(context).textTheme.bodyText2, - autofocus: widget.autofocus ?? false, + autofocus: widget.autofocus, decoration: InputDecoration( hintText: 'Write a message', hintStyle: From c51ebd12dda1b265aea8f58a2899ab8035eb6468 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 7 Dec 2020 13:09:53 +0100 Subject: [PATCH 16/54] version bp --- CHANGELOG.md | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7281206..4778f4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.16 + +- Do not wrap channel preview builder. Users will have to implement they're custom onTap/onLongPress implementation +- Make public autofocus field of the TextField of message_input + ## 0.2.15 - Add onLongPress on channel when using custom channel builder diff --git a/pubspec.yaml b/pubspec.yaml index 2fe6110b..583874c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.15 +version: 0.2.16 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 1339f878dcc9f7b0adcae0c998685d1b38faefaf Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 7 Dec 2020 17:12:18 +0100 Subject: [PATCH 17/54] fix mention tap --- lib/src/message_text.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/message_text.dart b/lib/src/message_text.dart index a043c53a..64fc855d 100644 --- a/lib/src/message_text.dart +++ b/lib/src/message_text.dart @@ -31,7 +31,7 @@ class MessageText extends StatelessWidget { ) { if (link.startsWith('@')) { final mentionedUser = message.mentionedUsers.firstWhere( - (u) => '@${u.name.replaceAll(' ', '')}' == link, + (u) => '@${u.name}' == link, orElse: () => null, ); From d6a6bdff67677c816e6558f0d3ba81873ea84323 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 9 Dec 2020 14:45:24 +0100 Subject: [PATCH 18/54] expose messageInputDecoration --- example/ios/Flutter/.last_build_id | 2 +- example/ios/Podfile.lock | 8 ++++---- example/pubspec.yaml | 2 +- lib/src/message_input.dart | 16 +++++++++------- lib/src/stream_chat.dart | 1 + lib/src/stream_chat_theme.dart | 15 +++++++++++++++ 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id index 8aba7787..20c7c514 100644 --- a/example/ios/Flutter/.last_build_id +++ b/example/ios/Flutter/.last_build_id @@ -1 +1 @@ -bb5f9103d9045cd6244bcae1f5f343e5 \ No newline at end of file +c3e639ccf9b069e37a7d1345194e6b99 \ No newline at end of file diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f17b1bc2..c8b16a2b 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -38,7 +38,7 @@ PODS: - Firebase/Messaging (6.33.0): - Firebase/CoreOnly - FirebaseMessaging (~> 4.7.0) - - firebase_core (0.5.1): + - firebase_core (0.5.2-1): - Firebase/CoreOnly (~> 6.33.0) - Flutter - firebase_messaging (7.0.3): @@ -227,7 +227,7 @@ SPEC CHECKSUMS: DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1 Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5 - firebase_core: aa25a5dc6b492ecab37587c53d8420135f0cac90 + firebase_core: 7423d688a1c6f2f2d859d64ae26991be39989781 firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75 FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1 @@ -256,8 +256,8 @@ SPEC CHECKSUMS: SwiftyGif: e466e86c660d343357ab944a819a101c4127cb40 url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e - wakelock: 0d4a70faf8950410735e3f61fb15d517c8a6efc4 + wakelock: bfc7955c418d0db797614075aabbc58a39ab5107 PODFILE CHECKSUM: eb001256612a59f8f9e4d083ad8b9671e69dd184 -COCOAPODS: 1.10.0.rc.1 +COCOAPODS: 1.10.0 diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0ba6b827..ca750779 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.26+27 +version: 1.0.27+28 environment: sdk: ">=2.2.2 <3.0.0" diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 6836d466..b30028e8 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -263,13 +263,15 @@ class MessageInputState extends State { }, style: widget.inputTextStyle ?? Theme.of(context).textTheme.bodyText2, autofocus: widget.autofocus, - decoration: InputDecoration( - hintText: 'Write a message', - hintStyle: - widget.inputTextStyle ?? Theme.of(context).textTheme.bodyText2, - prefixText: ' ', - border: InputBorder.none, - ), + decoration: + StreamChatTheme.of(context).channelTheme.messageInputDecoration ?? + InputDecoration( + hintText: 'Write a message', + hintStyle: widget.inputTextStyle ?? + Theme.of(context).textTheme.bodyText2, + prefixText: ' ', + border: InputBorder.none, + ), textCapitalization: TextCapitalization.sentences, ), ), diff --git a/lib/src/stream_chat.dart b/lib/src/stream_chat.dart index bff3c9f7..f5b91349 100644 --- a/lib/src/stream_chat.dart +++ b/lib/src/stream_chat.dart @@ -116,6 +116,7 @@ class StreamChatState extends State with WidgetsBindingObserver { inputGradient: themeData?.channelTheme?.inputGradient, messageInputButtonTheme: themeData?.channelTheme?.messageInputButtonTheme, + messageInputDecoration: themeData?.channelTheme?.messageInputDecoration, ), ownMessageTheme: defaultTheme.ownMessageTheme.copyWith( replies: themeData?.ownMessageTheme?.replies, diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index 851e4a9c..5af16cab 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -167,6 +167,8 @@ class StreamChatThemeData { channelTheme.inputGradient ?? this.channelTheme.inputGradient, inputBackground: channelTheme.inputBackground ?? this.channelTheme.inputBackground, + messageInputDecoration: channelTheme.messageInputDecoration ?? + this.channelTheme.messageInputDecoration, ) ?? this.channelTheme, ownMessageTheme: ownMessageTheme?.copyWith( @@ -247,6 +249,12 @@ class StreamChatThemeData { ), ), channelTheme: ChannelTheme( + messageInputDecoration: InputDecoration( + hintText: 'Write a message', + hintStyle: theme.textTheme.bodyText2, + prefixText: ' ', + border: InputBorder.none, + ), messageInputButtonIconTheme: theme.iconTheme.copyWith( color: accentColor, ), @@ -354,12 +362,16 @@ class ChannelTheme { /// Background color of [MessageInput] final Color inputBackground; + /// InputDecoration of [MessageInput] + final InputDecoration messageInputDecoration; + ChannelTheme({ this.channelHeaderTheme, this.messageInputButtonIconTheme, this.messageInputButtonTheme, this.inputBackground, this.inputGradient, + this.messageInputDecoration, }); /// Creates a copy of [ChannelTheme] with specified attributes overridden. @@ -369,6 +381,7 @@ class ChannelTheme { ButtonThemeData messageInputButtonTheme, Gradient inputGradient, Color inputBackground, + InputDecoration messageInputDecoration, }) => ChannelTheme( channelHeaderTheme: channelHeaderTheme?.copyWith( @@ -386,6 +399,8 @@ class ChannelTheme { messageInputButtonTheme ?? this.messageInputButtonTheme, inputGradient: inputGradient ?? this.inputGradient, inputBackground: inputBackground ?? this.inputBackground, + messageInputDecoration: + messageInputDecoration ?? this.messageInputDecoration, ); } From 0ca0fd18148639ea02aa1d62e9d59696cbc0b00b Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 9 Dec 2020 14:55:58 +0100 Subject: [PATCH 19/54] version bp --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4778f4c2..1e9b9642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.17 + +- Expose messageInputDecoration as part of the theme + ## 0.2.16 - Do not wrap channel preview builder. Users will have to implement they're custom onTap/onLongPress implementation diff --git a/pubspec.yaml b/pubspec.yaml index 583874c2..5304c039 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.16 +version: 0.2.17 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 1a1dd7e3c51f19fee7df92f7532d47c55e742f03 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 9 Dec 2020 15:24:41 +0100 Subject: [PATCH 20/54] version bp --- CHANGELOG.md | 2 ++ pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e9b9642..3df4143f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.2.17+1 + ## 0.2.17 - Expose messageInputDecoration as part of the theme diff --git a/pubspec.yaml b/pubspec.yaml index 5304c039..a400260e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.17 +version: 0.2.17+1 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From ec01c6c1dbafb578af4dc102ee52b1d37e2b4a4e Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 9 Dec 2020 15:25:03 +0100 Subject: [PATCH 21/54] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3df4143f..62efc4ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.2.17+1 +- Fix mention tap bug + ## 0.2.17 - Expose messageInputDecoration as part of the theme From 3a8f8a32648ad9408a9df4487415b4b7df35fd94 Mon Sep 17 00:00:00 2001 From: Ayush P Gupta Date: Wed, 9 Dec 2020 23:08:37 +0530 Subject: [PATCH 22/54] Add code formatting check Signed-off-by: Ayush P Gupta --- .github/workflows/flutter-analyze.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/flutter-analyze.yml b/.github/workflows/flutter-analyze.yml index dc65c8bb..312a65ba 100644 --- a/.github/workflows/flutter-analyze.yml +++ b/.github/workflows/flutter-analyze.yml @@ -17,4 +17,8 @@ jobs: with: channel: 'beta' - run: flutter pub get + + - name: 'Flutter Format Check' + run: flutter format --set-exit-if-changed --dry-run . + - run: flutter analyze From f79d49ce89516c713dfc04d707b78ab090a5c309 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Dec 2020 10:13:39 +0100 Subject: [PATCH 23/54] expose channels setter --- lib/src/channels_bloc.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 3af2300d..2312ff12 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -58,6 +58,11 @@ class ChannelsBlocState extends State final BehaviorSubject> _channelsController = BehaviorSubject(); + /// Set the current channel list + set channels(List newChannels) { + _channelsController.add(newChannels); + } + /// The stream notifying the state of queryChannel call Stream get queryChannelsLoading => _queryChannelsLoadingController.stream; From 4b88627457ca5d1dc76dea5c8d24bb3fe3b76674 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Dec 2020 10:14:31 +0100 Subject: [PATCH 24/54] version bp --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62efc4ac..fcf6bcf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.17+2 + +- Expose ChannelsBloc.channels setter + ## 0.2.17+1 - Fix mention tap bug diff --git a/pubspec.yaml b/pubspec.yaml index a400260e..dd5273b7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.17+1 +version: 0.2.17+2 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 7310a905beb44822c59ad3c678b9d10ab7d75c75 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Dec 2020 10:33:47 +0100 Subject: [PATCH 25/54] add change it to a function called at the end of the message.new event handler --- lib/src/channels_bloc.dart | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 2312ff12..1d5d3f92 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -14,11 +14,15 @@ class ChannelsBloc extends StatefulWidget { /// Set this to true to prevent channels to be brought to the top of the list when a new message arrives final bool lockChannelsOrder; + /// Function used to sort the channels when a message.new event is received + final List Function(List) sortChannels; + /// Instantiate a new ChannelsBloc const ChannelsBloc({ Key key, this.child, this.lockChannelsOrder = false, + this.sortChannels, }) : super(key: key); @override @@ -58,11 +62,6 @@ class ChannelsBlocState extends State final BehaviorSubject> _channelsController = BehaviorSubject(); - /// Set the current channel list - set channels(List newChannels) { - _channelsController.add(newChannels); - } - /// The stream notifying the state of queryChannel call Stream get queryChannelsLoading => _queryChannelsLoadingController.stream; @@ -146,7 +145,13 @@ class ChannelsBlocState extends State } } } - _channelsController.add(newChannels); + + if (widget.sortChannels != null) { + final sortedChannels = widget.sortChannels(newChannels); + _channelsController.add(sortedChannels); + } else { + _channelsController.add(newChannels); + } })); } From 422df24e9f36b7aec818a2292c2bae2d325f4f23 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Dec 2020 11:15:25 +0100 Subject: [PATCH 26/54] use comparator --- lib/src/channels_bloc.dart | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 1d5d3f92..59dd6335 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -14,15 +14,15 @@ class ChannelsBloc extends StatefulWidget { /// Set this to true to prevent channels to be brought to the top of the list when a new message arrives final bool lockChannelsOrder; - /// Function used to sort the channels when a message.new event is received - final List Function(List) sortChannels; + /// Comparator used to sort the channels when a message.new event is received + final Comparator channelsComparator; /// Instantiate a new ChannelsBloc const ChannelsBloc({ Key key, this.child, this.lockChannelsOrder = false, - this.sortChannels, + this.channelsComparator, }) : super(key: key); @override @@ -146,12 +146,10 @@ class ChannelsBlocState extends State } } - if (widget.sortChannels != null) { - final sortedChannels = widget.sortChannels(newChannels); - _channelsController.add(sortedChannels); - } else { - _channelsController.add(newChannels); + if (widget.channelsComparator != null) { + newChannels.sort(widget.channelsComparator); } + _channelsController.add(newChannels); })); } From 0883728a2efa272149341f64af97095d133c333b Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Dec 2020 11:19:55 +0100 Subject: [PATCH 27/54] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcf6bcf6..c91502be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.2.17+2 -- Expose ChannelsBloc.channels setter +- Expose ChannelsBloc.channelsComparator to sort channels on message.new event ## 0.2.17+1 From 7cceb59f0a9942b6d41865cade3d1e5f499c078d Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 18 Dec 2020 11:58:45 +0100 Subject: [PATCH 28/54] implement shadowban --- lib/src/channel_preview.dart | 2 +- lib/src/message_list_view.dart | 3 ++- lib/src/stream_chat.dart | 1 + pubspec.yaml | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 95fa4a3d..c01ccd5d 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -128,7 +128,7 @@ class ChannelPreview extends StatelessWidget { stream: channel.state.messagesStream, initialData: channel.state.messages, builder: (context, snapshot) { - final lastMessage = channel.state.lastMessage; + final lastMessage = snapshot.data.lastWhere((m) => m.shadowed != true); if (lastMessage == null) { return SizedBox(); } diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 2bbf4b82..f1d1a2ce 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -522,7 +522,8 @@ class _MessageListViewState extends State { .map((messages) => messages ?.where((m) => - !(m.status == MessageSendingStatus.FAILED && m.isDeleted)) + !(m.status == MessageSendingStatus.FAILED && m.isDeleted) && + m.shadowed != true) ?.toList() ?? []) .listen((newMessages) { diff --git a/lib/src/stream_chat.dart b/lib/src/stream_chat.dart index f5b91349..040409db 100644 --- a/lib/src/stream_chat.dart +++ b/lib/src/stream_chat.dart @@ -184,6 +184,7 @@ class StreamChatState extends State with WidgetsBindingObserver { .on(EventType.messageNew) .where((e) => e.user?.id != user.id) .where((e) => e.message.silent != true) + .where((e) => e.message.shadowed != true) .listen((event) async { final channel = client.channel( event.channelType, diff --git a/pubspec.yaml b/pubspec.yaml index dd5273b7..d3a0993c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: file_picker: ^2.0.12 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^4.0.1 - stream_chat: ^0.2.13 + stream_chat: ^0.2.19 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4 From c0d7936f57e268f47744fe92ab01a1e0b3467c8f Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 18 Dec 2020 11:59:23 +0100 Subject: [PATCH 29/54] version bp --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c91502be..327807a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.18 + +- Implement shadowban + ## 0.2.17+2 - Expose ChannelsBloc.channelsComparator to sort channels on message.new event diff --git a/pubspec.yaml b/pubspec.yaml index d3a0993c..a50abbf3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.17+2 +version: 0.2.18 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From cc41d5380fd4d797bf80673386cfc1b599f5e4d1 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 11:57:50 +0100 Subject: [PATCH 30/54] update dependencies --- lib/src/channels_bloc.dart | 8 ++++---- pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 59dd6335..c0bc9716 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -97,19 +97,19 @@ class ChannelsBlocState extends State paginationParams: paginationParams, onlyOffline: onlyOffline, ) - .listen((channels) { + .then((channels) { if (clear) { _channelsController.add(channels); } else { final l = oldChannels + channels; _channelsController.add(l); } - }, onDone: () { - _queryChannelsLoadingController.sink.add(false); - }, onError: (err, stackTrace) { + }).catchError((err, stackTrace) { print(err); print(stackTrace); _queryChannelsLoadingController.addError(err, stackTrace); + }).whenComplete(() { + _queryChannelsLoadingController.sink.add(false); }); } catch (err, stackTrace) { _queryChannelsLoadingController.addError(err, stackTrace); diff --git a/pubspec.yaml b/pubspec.yaml index dd5273b7..5499b4f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: file_picker: ^2.0.12 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^4.0.1 - stream_chat: ^0.2.13 + stream_chat: ^0.2.20 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4 From 3315b810591f3f7fd86265e3dd4322b2010ec6c8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 11:58:22 +0100 Subject: [PATCH 31/54] version bp --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c91502be..ea6d0989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.18 + +- Updatede llc dependency + ## 0.2.17+2 - Expose ChannelsBloc.channelsComparator to sort channels on message.new event diff --git a/pubspec.yaml b/pubspec.yaml index 5499b4f1..0da226b7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.17+2 +version: 0.2.18 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From cfad93eb19627e84e9fc1ae726eceb18f9e6e112 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 12:06:55 +0100 Subject: [PATCH 32/54] fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea6d0989..3b81cbe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.2.18 -- Updatede llc dependency +- Updated llc dependency ## 0.2.17+2 From 12f0bb1d940dc7c500242b7679f2d5a103888163 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 12:13:36 +0100 Subject: [PATCH 33/54] fix loading --- lib/src/channels_bloc.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index c0bc9716..cd5c5481 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -104,12 +104,11 @@ class ChannelsBlocState extends State final l = oldChannels + channels; _channelsController.add(l); } + _queryChannelsLoadingController.sink.add(false); }).catchError((err, stackTrace) { print(err); print(stackTrace); _queryChannelsLoadingController.addError(err, stackTrace); - }).whenComplete(() { - _queryChannelsLoadingController.sink.add(false); }); } catch (err, stackTrace) { _queryChannelsLoadingController.addError(err, stackTrace); From d63c876c1c278c76146d06cda716754d51dc2624 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 12:14:58 +0100 Subject: [PATCH 34/54] add await --- lib/src/channels_bloc.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index cd5c5481..b666c39b 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -89,7 +89,7 @@ class ChannelsBlocState extends State paginationParams.offset == null || paginationParams.offset == 0; final oldChannels = List.from(channels ?? []); - client + await client .queryChannels( filter: filter, sort: sortOptions, From 27ab376e81b2a7eb634aa38b9f47fe06434e9de2 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 12:19:57 +0100 Subject: [PATCH 35/54] remove unnecessary .catchError --- lib/src/channels_bloc.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index b666c39b..04ceede7 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -105,12 +105,10 @@ class ChannelsBlocState extends State _channelsController.add(l); } _queryChannelsLoadingController.sink.add(false); - }).catchError((err, stackTrace) { - print(err); - print(stackTrace); - _queryChannelsLoadingController.addError(err, stackTrace); }); } catch (err, stackTrace) { + print(err); + print(stackTrace); _queryChannelsLoadingController.addError(err, stackTrace); } } From 9b6c03ee5ce17ca29ce85b816334b3a9bbc71dd7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 12:24:03 +0100 Subject: [PATCH 36/54] use async await --- lib/src/channels_bloc.dart | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 04ceede7..0784cb30 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -89,23 +89,21 @@ class ChannelsBlocState extends State paginationParams.offset == null || paginationParams.offset == 0; final oldChannels = List.from(channels ?? []); - await client - .queryChannels( + final _channels = await client.queryChannels( filter: filter, sort: sortOptions, options: options, paginationParams: paginationParams, onlyOffline: onlyOffline, - ) - .then((channels) { - if (clear) { - _channelsController.add(channels); - } else { - final l = oldChannels + channels; - _channelsController.add(l); - } - _queryChannelsLoadingController.sink.add(false); - }); + ); + + if (clear) { + _channelsController.add(_channels); + } else { + final l = oldChannels + _channels; + _channelsController.add(l); + } + _queryChannelsLoadingController.sink.add(false); } catch (err, stackTrace) { print(err); print(stackTrace); From b7495bb16a87d76fcb44e76a73fc951375d7f11f Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 22 Dec 2020 14:15:58 +0100 Subject: [PATCH 37/54] add loading builder in channellistview; add sendButtonLocation and animationduration to messageinput --- lib/src/channel_list_view.dart | 15 ++++++-- lib/src/message_input.dart | 62 ++++++++++++++++++++++++---------- pubspec.yaml | 2 +- 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 33988b92..51c02611 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -65,6 +65,7 @@ class ChannelListView extends StatefulWidget { this.errorBuilder, this.emptyBuilder, this.onImageTap, + this.loadingBuilder, this.pullToRefresh = true, }) : super(key: key); @@ -79,6 +80,9 @@ class ChannelListView extends StatefulWidget { /// You can also filter other built-in channel fields. final Map filter; + /// The builder used while loading. + final WidgetBuilder loadingBuilder; + /// Query channels options. /// /// state: if true returns the Channel state @@ -224,9 +228,11 @@ class _ChannelListViewState extends State constraints: BoxConstraints( minHeight: viewportConstraints.maxHeight, ), - child: Center( - child: CircularProgressIndicator(), - ), + child: widget.loadingBuilder != null + ? widget.loadingBuilder(context) + : Center( + child: CircularProgressIndicator(), + ), ), ); }, @@ -339,6 +345,9 @@ class _ChannelListViewState extends State ), ); } else { + if (widget.loadingBuilder != null) { + return widget.loadingBuilder(context); + } return _buildQueryProgressIndicator(context, channelsProvider); } } diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index b30028e8..c8d089f1 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -27,6 +27,11 @@ enum ActionsLocation { right, } +enum SendButtonLocation { + inside, + outside, +} + enum DefaultAttachmentTypes { image, video, @@ -96,6 +101,8 @@ class MessageInput extends StatefulWidget { this.inputTextStyle, this.attachmentIconColor, this.autofocus = false, + this.sendButtonLocation = SendButtonLocation.inside, + this.animationDuration = const Duration(milliseconds: 300), }) : super(key: key); /// Message to edit @@ -141,6 +148,9 @@ class MessageInput extends StatefulWidget { /// The location of the custom actions final ActionsLocation actionsLocation; + /// The location of the send button + final SendButtonLocation sendButtonLocation; + /// Map that defines a thumbnail builder for an attachment type final Map attachmentThumbnailBuilders; @@ -148,6 +158,9 @@ class MessageInput extends StatefulWidget { /// `Theme.of(context).textTheme.bodyText2`. final TextStyle inputTextStyle; + /// The duration of the send button animation + final Duration animationDuration; + /// Color used for attachment icon. final Color attachmentIconColor; @@ -194,17 +207,26 @@ class MessageInputState extends State { }, child: Padding( padding: const EdgeInsets.all(8.0), - child: Stack( - clipBehavior: Clip.none, - children: [ - _buildBorder(context), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildAttachments(), - _buildTextField(context), - ], + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: Stack( + clipBehavior: Clip.none, + children: [ + _buildBorder(context), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildAttachments(), + _buildTextField(context), + ], + ), + ], + ), ), + if (widget.sendButtonLocation == SendButtonLocation.outside) + _animateSendButton(context), ], ), ), @@ -221,14 +243,18 @@ class MessageInputState extends State { if (widget.actionsLocation == ActionsLocation.left) ...widget.actions ?? [], _buildTextInput(context), - _animateSendButton(context), if (widget.actionsLocation == ActionsLocation.right) ...widget.actions ?? [], + if (widget.sendButtonLocation == SendButtonLocation.inside) + _animateSendButton(context), ], ); } - AnimatedCrossFade _animateSendButton(BuildContext context) { + Widget _animateSendButton(BuildContext context) { + if (widget.animationDuration == Duration.zero) { + return _buildSendButton(context); + } return AnimatedCrossFade( crossFadeState: ((_messageIsPresent || _attachments.isNotEmpty) && _attachments.every((a) => a.uploaded == true)) @@ -236,7 +262,7 @@ class MessageInputState extends State { : CrossFadeState.showSecond, firstChild: _buildSendButton(context), secondChild: SizedBox(), - duration: Duration(milliseconds: 300), + duration: widget.animationDuration, alignment: Alignment.center, ); } @@ -851,12 +877,14 @@ class MessageInputState extends State { color: Colors.transparent, child: IconButton( key: Key('sendButton'), - onPressed: () { - sendMessage(); - }, + onPressed: (textEditingController.text.trim().isEmpty && + _attachments.isEmpty) + ? null + : () { + sendMessage(); + }, icon: Icon( Icons.send, - color: StreamChatTheme.of(context).accentColor, ), ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 0da226b7..dd637568 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: file_picker: ^2.0.12 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^4.0.1 - stream_chat: ^0.2.20 + stream_chat: ^0.2.21 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4 From d703755343bb64e2c3c795c697bc2940e31a2046 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 22 Dec 2020 15:08:06 +0100 Subject: [PATCH 38/54] version bp --- CHANGELOG.md | 6 ++++++ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b81cbe3..64ab144d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.2.19 + +- Updated llc dependency +- Added loading builder in channellistview +- Added sendButtonLocation and animationduration to messageinput + ## 0.2.18 - Updated llc dependency diff --git a/pubspec.yaml b/pubspec.yaml index dd637568..4a585a92 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.18 +version: 0.2.19 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From b56fe4729b8447e4069af110d59dfc1e6eefed1f Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 23 Dec 2020 12:33:03 +0100 Subject: [PATCH 39/54] fix tests --- lib/src/channel_preview.dart | 2 +- test/src/channel_preview_test.dart | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index c01ccd5d..58557180 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -128,7 +128,7 @@ class ChannelPreview extends StatelessWidget { stream: channel.state.messagesStream, initialData: channel.state.messages, builder: (context, snapshot) { - final lastMessage = snapshot.data.lastWhere((m) => m.shadowed != true); + final lastMessage = snapshot.data?.lastWhere((m) => m.shadowed != true); if (lastMessage == null) { return SizedBox(); } diff --git a/test/src/channel_preview_test.dart b/test/src/channel_preview_test.dart index f5e0fbd0..a7173628 100644 --- a/test/src/channel_preview_test.dart +++ b/test/src/channel_preview_test.dart @@ -24,6 +24,11 @@ void main() { 'name': 'test name', }); when(channelState.unreadCount).thenReturn(1); + when(channelState.messages).thenReturn([ + Message( + text: 'hello', + ) + ]); when(channelState.lastMessage).thenReturn(Message( text: 'hello', )); From f891061eb9ee6fe8fe4739d919442b24ef0900b6 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 24 Dec 2020 12:45:28 +0100 Subject: [PATCH 40/54] use key in attachments to fix cideo preview bug --- lib/src/message_widget.dart | 1 + pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index d634b0b8..eb13e2ad 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -547,6 +547,7 @@ class _MessageWidgetState extends State { } return Padding( + key: Key(attachment.hashCode.toString()), padding: EdgeInsets.only( bottom: 4, ), diff --git a/pubspec.yaml b/pubspec.yaml index 40053962..494eb32d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: file_picker: ^2.0.12 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^4.0.1 - stream_chat: ^0.2.21 + stream_chat: ^0.2.21+1 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4 From a0cb8f045d0c650fe4cdf897fc052a38c496d57e Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 24 Dec 2020 12:46:20 +0100 Subject: [PATCH 41/54] version bump --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2e26db..a84842c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.20+1 + +- Fixed bug that caused video attachment to show the same preview + ## 0.2.20 - Implement shadowban diff --git a/pubspec.yaml b/pubspec.yaml index 494eb32d..381830f5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.20 +version: 0.2.20+1 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From c9543ab644701b6913daf05b74d6aa6aa921308c Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 28 Dec 2020 13:24:28 +0100 Subject: [PATCH 42/54] add shouldAddChannel to ChannelsBloc --- lib/src/channels_bloc.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 0784cb30..81081051 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -17,12 +17,16 @@ class ChannelsBloc extends StatefulWidget { /// Comparator used to sort the channels when a message.new event is received final Comparator channelsComparator; + /// Function used to evaluate if a channel should be added to the list when a message.new event is received + final bool Function(Event) shouldAddChannel; + /// Instantiate a new ChannelsBloc const ChannelsBloc({ Key key, this.child, this.lockChannelsOrder = false, this.channelsComparator, + this.shouldAddChannel, }) : super(key: key); @override @@ -128,7 +132,8 @@ class ChannelsBlocState extends State final channel = newChannels.removeAt(index); newChannels.insert(0, channel); } - } else { + } else if (widget.shouldAddChannel != null && + widget.shouldAddChannel(e)) { final hiddenIndex = _hiddenChannels.indexWhere((c) => c.cid == e.cid); if (hiddenIndex > -1) { newChannels.insert(0, _hiddenChannels[hiddenIndex]); From 9d4a72217859549d6dca6203ae532110a91ba96b Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 28 Dec 2020 13:25:41 +0100 Subject: [PATCH 43/54] version bump --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a84842c6..8ca3aa04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.20+2 + +- Added `shouldAddChannel` to ChannelsBloc in order to check if a channel has to be added to the list when a new message arrives + ## 0.2.20+1 - Fixed bug that caused video attachment to show the same preview diff --git a/pubspec.yaml b/pubspec.yaml index 381830f5..7aac0211 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.20+1 +version: 0.2.20+2 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From ade6050a6543895b9ad3808378fd124c3f0f0403 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 18 Jan 2021 10:16:50 +0100 Subject: [PATCH 44/54] Refs #217: add missing configuration point of flutter_apns --- example/ios/Flutter/.last_build_id | 2 +- example/ios/Podfile.lock | 16 ++++++++-------- example/ios/Runner/AppDelegate.swift | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id index 20c7c514..e72273c3 100644 --- a/example/ios/Flutter/.last_build_id +++ b/example/ios/Flutter/.last_build_id @@ -1 +1 @@ -c3e639ccf9b069e37a7d1345194e6b99 \ No newline at end of file +13a41b8138c4868054e44b5158f3bdd6 \ No newline at end of file diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index c8b16a2b..47b68109 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -38,7 +38,7 @@ PODS: - Firebase/Messaging (6.33.0): - Firebase/CoreOnly - FirebaseMessaging (~> 4.7.0) - - firebase_core (0.5.2-1): + - firebase_core (0.5.3): - Firebase/CoreOnly (~> 6.33.0) - Flutter - firebase_messaging (7.0.3): @@ -113,9 +113,9 @@ PODS: - Flutter - PromisesObjC (1.2.11) - Protobuf (3.13.0) - - SDWebImage (5.9.4): - - SDWebImage/Core (= 5.9.4) - - SDWebImage/Core (5.9.4) + - SDWebImage (5.10.0): + - SDWebImage/Core (= 5.10.0) + - SDWebImage/Core (5.10.0) - shared_preferences (0.0.1): - Flutter - sqflite (0.0.2): @@ -140,7 +140,7 @@ PODS: - sqlite3/perf-threadsafe - sqlite3/rtree - Starscream (4.0.4) - - StreamChatClient (2.4.1): + - StreamChatClient (2.4.2): - Starscream (~> 4.0) - SwiftyGif (5.3.0) - url_launcher (0.0.1): @@ -227,7 +227,7 @@ SPEC CHECKSUMS: DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1 Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5 - firebase_core: 7423d688a1c6f2f2d859d64ae26991be39989781 + firebase_core: 5d6a02f3d85acd5f8321c2d6d62877626a670659 firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75 FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1 @@ -246,13 +246,13 @@ SPEC CHECKSUMS: path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c PromisesObjC: 8c196f5a328c2cba3e74624585467a557dcb482f Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748 - SDWebImage: b69257f4ab14e9b6a2ef53e910fdf914d8f757c1 + SDWebImage: 9169792e9eec3e45bba2a0c02f74bf8bd922d1ee shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 sqlite3: 8f7d2078ae27778699a622a94b853285793422a2 sqlite3_flutter_libs: 5651f8ff48e3b44d910863c4ea5916085b1b245f Starscream: 5178aed56b316f13fa3bc55694e583d35dd414d9 - StreamChatClient: d061cf52babcd9df930aee9cf864ab0379427eff + StreamChatClient: fc6419fa7ceda9c048188bb7c8e9f07755ced05f SwiftyGif: e466e86c660d343357ab944a819a101c4127cb40 url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 3f549155..12b4b519 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -9,6 +9,10 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + + if #available(iOS 10.0, *) { + UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate + } if let messageQueue = sharedDefaults?.stringArray(forKey: "messageQueue") { UserDefaults.standard.setValue(messageQueue, forKey: "flutter.messageQueue") sharedDefaults?.removeObject(forKey: "messageQueue") From 85a103c5fc8785698a56e6a9b83e5fc4447cea87 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 18 Jan 2021 15:06:43 +0530 Subject: [PATCH 45/54] fix: get reaction by user and reaction type --- lib/src/reaction_picker.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index bdbcc669..8d1c6d7b 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -31,8 +31,11 @@ class ReactionPicker extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: reactionToEmoji.keys.map((reactionType) { - final ownReactionIndex = message.latestReactions - ?.indexWhere((reaction) => reaction.type == reactionType) ?? + var user = StreamChat.of(context).user; + final ownReactionIndex = message.latestReactions?.indexWhere( + (reaction) => + reaction.type == reactionType && + reaction.userId == user.id) ?? -1; return Column( mainAxisSize: MainAxisSize.min, From 835c73204a3c7324dc4082ea8314808fd44b8e67 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 18 Jan 2021 11:10:40 +0100 Subject: [PATCH 46/54] fix reaction picker score indicator --- lib/src/reaction_picker.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index 8d1c6d7b..94bd9162 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -37,6 +37,10 @@ class ReactionPicker extends StatelessWidget { reaction.type == reactionType && reaction.userId == user.id) ?? -1; + final totalScore = message.latestReactions + .where((r) => r.type == reactionType) + .map((r) => r.score) + .reduce((tot, s) => tot + s); return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, @@ -58,12 +62,11 @@ class ReactionPicker extends StatelessWidget { } }, ), - ownReactionIndex != -1 + totalScore > 0 ? Padding( padding: const EdgeInsets.only(bottom: 4.0), child: Text( - message.latestReactions[ownReactionIndex].score - .toString(), + totalScore.toString(), style: TextStyle(color: Colors.white), ), ) From 8ddd75707fb8deb4589d604cd9dc4e4ad4c754f5 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 18 Jan 2021 16:12:20 +0530 Subject: [PATCH 47/54] fix: removed bad state --- lib/src/reaction_picker.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index 94bd9162..8e2d8b10 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -40,7 +40,8 @@ class ReactionPicker extends StatelessWidget { final totalScore = message.latestReactions .where((r) => r.type == reactionType) .map((r) => r.score) - .reduce((tot, s) => tot + s); + .fold(0, (tot, s) => tot + s); + return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, From b5fd401df6ddccad61a4e76c82bd57341dfcd4d9 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 18 Jan 2021 11:58:36 +0100 Subject: [PATCH 48/54] version bp --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ca3aa04..af482426 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.20+3 + +- Fix reaction picker score indicator + ## 0.2.20+2 - Added `shouldAddChannel` to ChannelsBloc in order to check if a channel has to be added to the list when a new message arrives diff --git a/pubspec.yaml b/pubspec.yaml index 7aac0211..1b14a71c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.20+2 +version: 0.2.20+3 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 2931fb2d4c723bde993c9266ebc2e80a8c2184fb Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 19 Jan 2021 12:09:50 +0100 Subject: [PATCH 49/54] fix channelpreview with messagelistempty --- example/ios/Flutter/.last_build_id | 2 +- example/lib/main.dart | 2 +- lib/src/channel_preview.dart | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id index e72273c3..f57e1e1f 100644 --- a/example/ios/Flutter/.last_build_id +++ b/example/ios/Flutter/.last_build_id @@ -1 +1 @@ -13a41b8138c4868054e44b5158f3bdd6 \ No newline at end of file +c770358a10272b4ee1cdc2eb432445f6 \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 9eee4db0..f048f584 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -127,7 +127,7 @@ class ChannelListPage extends StatelessWidget { '\$in': [StreamChat.of(context).user.id], } }, - sort: [SortOption('last_message_at')], + // sort: [SortOption('last_message_at')], pagination: PaginationParams( limit: 20, ), diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 58557180..61603055 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -128,7 +128,10 @@ class ChannelPreview extends StatelessWidget { stream: channel.state.messagesStream, initialData: channel.state.messages, builder: (context, snapshot) { - final lastMessage = snapshot.data?.lastWhere((m) => m.shadowed != true); + final lastMessage = snapshot.data?.lastWhere( + (m) => m.shadowed != true, + orElse: () => null, + ); if (lastMessage == null) { return SizedBox(); } From 7fce7ebf3858bde6fbe610de6e3647fad0f8a2bf Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 19 Jan 2021 12:12:28 +0100 Subject: [PATCH 50/54] fix customize_channel_preview example --- example/ios/Flutter/.last_build_id | 2 +- example/lib/customize_channel_preview.dart | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id index f57e1e1f..1e10204b 100644 --- a/example/ios/Flutter/.last_build_id +++ b/example/ios/Flutter/.last_build_id @@ -1 +1 @@ -c770358a10272b4ee1cdc2eb432445f6 \ No newline at end of file +c1153e968f5d6bcc19c41ac2592825f6 \ No newline at end of file diff --git a/example/lib/customize_channel_preview.dart b/example/lib/customize_channel_preview.dart index 3809f780..503987ae 100644 --- a/example/lib/customize_channel_preview.dart +++ b/example/lib/customize_channel_preview.dart @@ -62,7 +62,7 @@ class ChannelListPage extends StatelessWidget { } }, channelPreviewBuilder: _channelPreviewBuilder, - sort: [SortOption('last_message_at')], + // sort: [SortOption('last_message_at')], pagination: PaginationParams( limit: 20, ), @@ -73,8 +73,10 @@ class ChannelListPage extends StatelessWidget { } Widget _channelPreviewBuilder(BuildContext context, Channel channel) { - final lastMessage = channel.state.messages.reversed - .firstWhere((message) => !message.isDeleted); + final lastMessage = channel.state.messages.reversed.firstWhere( + (message) => !message.isDeleted, + orElse: () => null, + ); final subtitle = (lastMessage == null ? "nothing yet" : lastMessage.text); final opacity = channel.state.unreadCount > .0 ? 1.0 : 0.5; From 113c969465baf898a109bc70639a354a00032560 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 19 Jan 2021 12:13:19 +0100 Subject: [PATCH 51/54] version bp --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af482426..e30a47f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.20+4 + +- Fix channelPreview when the message list is empty + ## 0.2.20+3 - Fix reaction picker score indicator diff --git a/pubspec.yaml b/pubspec.yaml index 1b14a71c..09380ccc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.20+3 +version: 0.2.20+4 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From e0c8068fbdc9a8fdba1ce696d198f17870391232 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 25 Jan 2021 09:54:16 +0100 Subject: [PATCH 52/54] add messageFilter property in messageListView --- example/lib/main.dart | 4 ++-- lib/src/message_list_view.dart | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index f048f584..4b8418e9 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -59,7 +59,7 @@ void _initNotifications(Client client) { if (connector.token.value != null) { client.addDevice( connector.token.value, - Platform.isAndroid ? 'firebase' : 'apn', + Platform.isAndroid ? PushProvider.firebase : PushProvider.apn, ); } }); @@ -127,7 +127,7 @@ class ChannelListPage extends StatelessWidget { '\$in': [StreamChat.of(context).user.id], } }, - // sort: [SortOption('last_message_at')], + sort: [SortOption('last_message_at')], pagination: PaginationParams( limit: 20, ), diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index f1d1a2ce..8b6876d2 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -108,6 +108,7 @@ class MessageListView extends StatefulWidget { this.onParentMessageTap, this.scrollPhysics = const AlwaysScrollableScrollPhysics(), this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, + this.messageFilter, }) : super(key: key); /// Function used to build a custom message widget @@ -119,6 +120,9 @@ class MessageListView extends StatefulWidget { /// Function used to build a custom thread widget final ThreadBuilder threadBuilder; + /// Filter applied to the message list before rendering + final bool Function(Message) messageFilter; + /// Function called when tapping on a thread /// By default it calls [Navigator.push] using the widget built using [threadBuilder] final ThreadTapCallback onThreadTap; @@ -518,15 +522,20 @@ class _MessageListViewState extends State { .map((threads) => threads[widget.parentMessage.id]); } - _streamListener = stream - .map((messages) => - messages - ?.where((m) => - !(m.status == MessageSendingStatus.FAILED && m.isDeleted) && - m.shadowed != true) - ?.toList() ?? - []) - .listen((newMessages) { + _streamListener = stream.map((messages) { + final filteredMessages = messages + ?.where((m) => + !(m.status == MessageSendingStatus.FAILED && m.isDeleted) && + m.shadowed != true) + ?.toList() ?? + []; + + if (widget.messageFilter != null) { + return messages.where(widget.messageFilter).toList(); + } + + return filteredMessages; + }).listen((newMessages) { newMessages = newMessages.reversed.toList(); if (_messages.isEmpty || newMessages.isEmpty || From 0ef454acc63f41fdf38103034195dfd00194c0e7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 25 Jan 2021 09:56:38 +0100 Subject: [PATCH 53/54] add loadingbuilder in messagelistview --- lib/src/message_list_view.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 8b6876d2..f968d850 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -109,6 +109,7 @@ class MessageListView extends StatefulWidget { this.scrollPhysics = const AlwaysScrollableScrollPhysics(), this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.messageFilter, + this.loadingBuilder, }) : super(key: key); /// Function used to build a custom message widget @@ -120,6 +121,9 @@ class MessageListView extends StatefulWidget { /// Function used to build a custom thread widget final ThreadBuilder threadBuilder; + /// The builder used while loading. + final WidgetBuilder loadingBuilder; + /// Filter applied to the message list before rendering final bool Function(Message) messageFilter; @@ -308,6 +312,11 @@ class _MessageListViewState extends State { if (!snapshot.data) { return Container(); } + + if (widget.loadingBuilder != null) { + return widget.loadingBuilder(context); + } + return Center( child: Padding( padding: const EdgeInsets.all(8.0), From 9635e2cda212be232b7e49420857acec51cbacde Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 25 Jan 2021 09:58:31 +0100 Subject: [PATCH 54/54] bump version --- CHANGELOG.md | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e30a47f3..578265ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.21 + +- Add `loadingBuilder` in `MessageListView` +- Add `messageFilter` property in `MessageListView` + ## 0.2.20+4 - Fix channelPreview when the message list is empty diff --git a/pubspec.yaml b/pubspec.yaml index 09380ccc..849339b8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.20+4 +version: 0.2.21 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues