From 581a9a2def432113fce2e866703f2f3fddeebe6b Mon Sep 17 00:00:00 2001 From: Neevash Ramdial Date: Sat, 14 Nov 2020 14:47:48 -0400 Subject: [PATCH 1/6] expose builder for empty state --- lib/src/channel_list_view.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index f88eefbe..b716fff6 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -63,6 +63,7 @@ class ChannelListView extends StatefulWidget { this.channelPreviewBuilder, this.separatorBuilder, this.errorBuilder, + this.emptyBuilder, this.onImageTap, this.pullToRefresh = true, }) : super(key: key); @@ -70,6 +71,9 @@ class ChannelListView extends StatefulWidget { /// The builder that will be used in case of error final Widget Function(Error error) errorBuilder; + /// The builder used when the channel list is empty. + final WidgetBuilder emptyBuilder; + /// The query filters to use. /// You can query on any of the custom fields you've defined on the [Channel]. /// You can also filter other built-in channel fields. @@ -231,7 +235,11 @@ class _ChannelListViewState extends State final channels = snapshot.data; - if (channels.isEmpty) { + if (channels.isEmpty && widget.emptyBuilder != null) { + return widget.emptyBuilder(context); + } + + if (channels.isEmpty && widget.emptyBuilder == null) { return LayoutBuilder( builder: (context, viewportConstraints) { return SingleChildScrollView( From 83787846c90673ca6d657b7021efdb5ca4a47a7c Mon Sep 17 00:00:00 2001 From: Neevash Ramdial Date: Sat, 14 Nov 2020 14:47:48 -0400 Subject: [PATCH 2/6] expose builder for empty state --- lib/src/channel_list_view.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index f88eefbe..b716fff6 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -63,6 +63,7 @@ class ChannelListView extends StatefulWidget { this.channelPreviewBuilder, this.separatorBuilder, this.errorBuilder, + this.emptyBuilder, this.onImageTap, this.pullToRefresh = true, }) : super(key: key); @@ -70,6 +71,9 @@ class ChannelListView extends StatefulWidget { /// The builder that will be used in case of error final Widget Function(Error error) errorBuilder; + /// The builder used when the channel list is empty. + final WidgetBuilder emptyBuilder; + /// The query filters to use. /// You can query on any of the custom fields you've defined on the [Channel]. /// You can also filter other built-in channel fields. @@ -231,7 +235,11 @@ class _ChannelListViewState extends State final channels = snapshot.data; - if (channels.isEmpty) { + if (channels.isEmpty && widget.emptyBuilder != null) { + return widget.emptyBuilder(context); + } + + if (channels.isEmpty && widget.emptyBuilder == null) { return LayoutBuilder( builder: (context, viewportConstraints) { return SingleChildScrollView( From 13604cee386afcb31dd2b6fd061d2dfcba00b0e1 Mon Sep 17 00:00:00 2001 From: Neevash Ramdial Date: Sun, 15 Nov 2020 21:32:53 -0400 Subject: [PATCH 3/6] Change material type to transparent --- lib/src/message_input.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 13f8291c..78833c8c 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -605,10 +605,10 @@ class MessageInputState extends State { Material _buildAttachmentButton() { return Material( clipBehavior: Clip.hardEdge, + type: MaterialType.transparency, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(32), ), - color: Colors.transparent, child: IconButton( onPressed: () { showAttachmentModal(); From 78e23bc256f7ddb6f369559c59ae66e42d611ec5 Mon Sep 17 00:00:00 2001 From: Neevash Ramdial Date: Sun, 15 Nov 2020 21:33:51 -0400 Subject: [PATCH 4/6] expose input text style --- lib/src/message_input.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 78833c8c..729866ee 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -93,6 +93,7 @@ class MessageInput extends StatefulWidget { this.actions, this.actionsLocation = ActionsLocation.left, this.attachmentThumbnailBuilders, + this.inputTextStyle, }) : super(key: key); /// Message to edit @@ -138,6 +139,10 @@ class MessageInput extends StatefulWidget { /// Map that defines a thumbnail builder for an attachment type final Map attachmentThumbnailBuilders; + /// Text style used in message text field. If null, [MessageInput] uses + /// `Theme.of(context).textTheme.bodyText2`. + final TextStyle inputTextStyle; + @override MessageInputState createState() => MessageInputState(); @@ -276,10 +281,12 @@ class MessageInputState extends State { _typingStarted = true; }); }, - style: Theme.of(context).textTheme.bodyText2, + style: widget.inputTextStyle ?? Theme.of(context).textTheme.bodyText2, autofocus: false, decoration: InputDecoration( hintText: 'Write a message', + hintStyle: widget.inputTextStyle ?? + Theme.of(context).textTheme.bodyText2, prefixText: ' ', border: InputBorder.none, ), From 77d62eefddc14813461d9e2a2ce963bee6613667 Mon Sep 17 00:00:00 2001 From: Neevash Ramdial Date: Sun, 15 Nov 2020 21:34:14 -0400 Subject: [PATCH 5/6] expose style option for attachment icon --- lib/src/message_input.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 729866ee..20a2bdf6 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -94,6 +94,7 @@ class MessageInput extends StatefulWidget { this.actionsLocation = ActionsLocation.left, this.attachmentThumbnailBuilders, this.inputTextStyle, + this.attachmentIconColor }) : super(key: key); /// Message to edit @@ -143,6 +144,9 @@ class MessageInput extends StatefulWidget { /// `Theme.of(context).textTheme.bodyText2`. final TextStyle inputTextStyle; + /// Color used for attachment icon. + final Color attachmentIconColor; + @override MessageInputState createState() => MessageInputState(); @@ -622,6 +626,7 @@ class MessageInputState extends State { }, icon: Icon( Icons.add_circle_outline, + color: widget.attachmentIconColor, ), ), ); From bb243d7c7acf055c082c040f59e475ff792ada72 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 16 Nov 2020 17:18:57 +0100 Subject: [PATCH 6/6] bump version (#137) --- CHANGELOG.md | 7 ++++++ lib/src/channel_list_view.dart | 6 ++--- lib/src/message_input.dart | 46 ++++++++++++++++++---------------- pubspec.yaml | 4 +-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03db8a6d..945199b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.2.13 + +- Update llc dependency +- Send parent_id in typing events +- Expose addition input styling options +- Expose builder for empty channel state + ## 0.2.12 - Upgrade dependencies diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index b716fff6..121a7d10 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -72,7 +72,7 @@ class ChannelListView extends StatefulWidget { final Widget Function(Error error) errorBuilder; /// The builder used when the channel list is empty. - final WidgetBuilder emptyBuilder; + final WidgetBuilder emptyBuilder; /// The query filters to use. /// You can query on any of the custom fields you've defined on the [Channel]. @@ -236,8 +236,8 @@ class _ChannelListViewState extends State final channels = snapshot.data; if (channels.isEmpty && widget.emptyBuilder != null) { - return widget.emptyBuilder(context); - } + return widget.emptyBuilder(context); + } if (channels.isEmpty && widget.emptyBuilder == null) { return LayoutBuilder( diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 20a2bdf6..02fbbd8f 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -77,25 +77,25 @@ enum DefaultAttachmentTypes { /// Modify it to change the widget appearance. class MessageInput extends StatefulWidget { /// Instantiate a new MessageInput - MessageInput({ - Key key, - this.onMessageSent, - this.preMessageSending, - this.parentMessage, - this.editMessage, - this.maxHeight = 150, - this.keyboardType = TextInputType.multiline, - this.disableAttachments = false, - this.doImageUploadRequest, - this.doFileUploadRequest, - this.initialMessage, - this.textEditingController, - this.actions, - this.actionsLocation = ActionsLocation.left, - this.attachmentThumbnailBuilders, - this.inputTextStyle, - this.attachmentIconColor - }) : super(key: key); + MessageInput( + {Key key, + this.onMessageSent, + this.preMessageSending, + this.parentMessage, + this.editMessage, + this.maxHeight = 150, + this.keyboardType = TextInputType.multiline, + this.disableAttachments = false, + this.doImageUploadRequest, + this.doFileUploadRequest, + this.initialMessage, + this.textEditingController, + this.actions, + this.actionsLocation = ActionsLocation.left, + this.attachmentThumbnailBuilders, + this.inputTextStyle, + this.attachmentIconColor}) + : super(key: key); /// Message to edit final Message editMessage; @@ -253,7 +253,9 @@ class MessageInputState extends State { controller: textEditingController, focusNode: _focusNode, onChanged: (s) { - StreamChannel.of(context).channel.keyStroke(); + StreamChannel.of(context).channel.keyStroke( + widget.parentMessage?.id, + ); setState(() { _messageIsPresent = s.trim().isNotEmpty; @@ -289,8 +291,8 @@ class MessageInputState extends State { autofocus: false, decoration: InputDecoration( hintText: 'Write a message', - hintStyle: widget.inputTextStyle ?? - Theme.of(context).textTheme.bodyText2, + hintStyle: + widget.inputTextStyle ?? Theme.of(context).textTheme.bodyText2, prefixText: ' ', border: InputBorder.none, ), diff --git a/pubspec.yaml b/pubspec.yaml index 7733d25b..00be2548 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.12 +version: 0.2.13 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -23,7 +23,7 @@ dependencies: file_picker: ^2.0.12 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^3.3.0 - stream_chat: ^0.2.10 + stream_chat: ^0.2.13 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4