diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index d1a45786..9af64b38 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -200,6 +200,7 @@ class MessageInput extends StatefulWidget { this.customOverlays = const [], this.mentionAllAppUsers = false, this.shouldKeepFocusAfterMessage, + this.autocorrectEnabled, }) : assert( initialMessage == null || editMessage == null, "Can't provide both `initialMessage` and `editMessage`", @@ -322,6 +323,8 @@ class MessageInput extends StatefulWidget { /// The default behaviour keeps focus until a command is enabled. final bool? shouldKeepFocusAfterMessage; + final bool? autocorrectEnabled; + @override MessageInputState createState() => MessageInputState(); @@ -707,6 +710,7 @@ class MessageInputState extends State { textAlignVertical: TextAlignVertical.center, decoration: _getInputDecoration(context), textCapitalization: TextCapitalization.sentences, + autocorrect: widget.autocorrectEnabled ?? true, ), ), ], diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index c6e269b9..edd76327 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -170,6 +170,7 @@ class MessageListView extends StatefulWidget { const MessageListView({ Key? key, this.showScrollToBottom = true, + this.scrollToBottomBuilder, this.messageBuilder, this.parentMessageBuilder, this.parentMessage, @@ -242,6 +243,11 @@ class MessageListView extends StatefulWidget { /// messages and the scroll offset is not zero final bool showScrollToBottom; + final Widget Function( + int unreadCount, + Future Function(int) scrollToBottomDefaultTapAction, + )? scrollToBottomBuilder; + /// Parent message in case of a thread final Message? parentMessage; @@ -846,6 +852,29 @@ class _MessageListViewState extends State { .index; } + Future scrollToBottomDefaultTapAction(int unreadCount) async { + if (unreadCount > 0) { + streamChannel!.channel.markRead(); + } + if (!_upToDate) { + _bottomPaginationActive = false; + initialAlignment = 0; + initialIndex = 0; + await streamChannel!.reloadChannel(); + + WidgetsBinding.instance?.addPostFrameCallback((_) { + _scrollController!.jumpTo(index: 0); + }); + } else { + _showScrollToBottom.value = false; + _scrollController!.scrollTo( + index: 0, + duration: const Duration(seconds: 1), + curve: Curves.easeInOut, + ); + } + } + Widget _buildScrollToBottom() => StreamBuilder( stream: streamChannel!.channel.state!.unreadCountStream, builder: (_, snapshot) { @@ -855,6 +884,12 @@ class _MessageListViewState extends State { return const Offstage(); } final unreadCount = snapshot.data!; + if (widget.scrollToBottomBuilder != null) { + return widget.scrollToBottomBuilder!( + unreadCount, + scrollToBottomDefaultTapAction, + ); + } final showUnreadCount = unreadCount > 0 && streamChannel!.channel.state!.members.any((e) => e.userId == @@ -869,28 +904,7 @@ class _MessageListViewState extends State { children: [ FloatingActionButton( backgroundColor: _streamTheme.colorTheme.barsBg, - onPressed: () async { - if (unreadCount > 0) { - streamChannel!.channel.markRead(); - } - if (!_upToDate) { - _bottomPaginationActive = false; - initialAlignment = 0; - initialIndex = 0; - await streamChannel!.reloadChannel(); - - WidgetsBinding.instance?.addPostFrameCallback((_) { - _scrollController!.jumpTo(index: 0); - }); - } else { - _showScrollToBottom.value = false; - _scrollController!.scrollTo( - index: 0, - duration: const Duration(seconds: 1), - curve: Curves.easeInOut, - ); - } - }, + onPressed: () => scrollToBottomDefaultTapAction(unreadCount), child: widget.reverse ? StreamSvgIcon.down( color: _streamTheme.colorTheme.textHighEmphasis,