From cc41d5380fd4d797bf80673386cfc1b599f5e4d1 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Dec 2020 11:57:50 +0100 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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