From 42d2fdfacace780722fc71019a29bb1eca751ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Badst=C3=BCbner?= Date: Mon, 17 Jun 2024 23:09:33 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8C=9F=20listen=20to=20typing=20i?= =?UTF-8?q?ndicator=20changes=20better?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/widgets/chat_groupedlist_widget.dart | 56 ++++++++------------ lib/src/widgets/chat_list_widget.dart | 7 --- lib/src/widgets/chat_view.dart | 4 -- 3 files changed, 21 insertions(+), 46 deletions(-) diff --git a/lib/src/widgets/chat_groupedlist_widget.dart b/lib/src/widgets/chat_groupedlist_widget.dart index 3b6314b5..bcbdd7e6 100644 --- a/lib/src/widgets/chat_groupedlist_widget.dart +++ b/lib/src/widgets/chat_groupedlist_widget.dart @@ -33,7 +33,6 @@ class ChatGroupedListWidget extends StatefulWidget { const ChatGroupedListWidget({ Key? key, required this.showPopUp, - required this.showTypingIndicator, required this.scrollController, required this.chatBackgroundConfig, required this.replyMessage, @@ -52,8 +51,7 @@ class ChatGroupedListWidget extends StatefulWidget { /// Allow user to swipe to see time while reaction pop is not open. final bool showPopUp; - /// Allow user to show typing indicator. - final bool showTypingIndicator; + /// Pass scroll controller final ScrollController scrollController; /// Allow user to give customisation to background of chat @@ -103,8 +101,6 @@ class _ChatGroupedListWidgetState extends State bool get showPopUp => widget.showPopUp; - bool get showTypingIndicator => widget.showTypingIndicator; - bool highlightMessage = false; final ValueNotifier _replyId = ValueNotifier(null); @@ -184,7 +180,6 @@ class _ChatGroupedListWidgetState extends State reverse: true, // When reaction popup is being appeared at that user should not scroll. physics: showPopUp ? const NeverScrollableScrollPhysics() : null, - padding: EdgeInsets.only(bottom: showTypingIndicator ? 50 : 0), controller: widget.scrollController, child: Column( mainAxisSize: MainAxisSize.min, @@ -210,38 +205,29 @@ class _ChatGroupedListWidgetState extends State ) : _chatStreamBuilder, ), - widget.showTypingIndicator - ? TypingIndicator( - typeIndicatorConfig: widget.typeIndicatorConfig, - chatBubbleConfig: chatBubbleConfig?.inComingChatBubbleConfig, - showIndicator: widget.showTypingIndicator, - ) - : ValueListenableBuilder( - valueListenable: ChatViewInheritedWidget.of(context)! - .chatController - .typingIndicatorNotifier, - builder: (context, value, child) => TypingIndicator( - typeIndicatorConfig: widget.typeIndicatorConfig, - chatBubbleConfig: - chatBubbleConfig?.inComingChatBubbleConfig, - showIndicator: value, - ), + if (chatController != null) + ValueListenableBuilder( + valueListenable: chatController!.typingIndicatorNotifier, + builder: (context, value, child) => TypingIndicator( + typeIndicatorConfig: widget.typeIndicatorConfig, + chatBubbleConfig: chatBubbleConfig?.inComingChatBubbleConfig, + showIndicator: value, + ), + ), + if (chatController != null) + Flexible( + child: Align( + alignment: suggestionsListConfig.axisAlignment.alignment, + child: ValueListenableBuilder( + valueListenable: chatController!.newSuggestions, + builder: (context, value, child) { + return SuggestionList( + suggestions: value, + ); + }, ), - Flexible( - child: Align( - alignment: suggestionsListConfig.axisAlignment.alignment, - child: ValueListenableBuilder( - valueListenable: ChatViewInheritedWidget.of(context)! - .chatController - .newSuggestions, - builder: (context, value, child) { - return SuggestionList( - suggestions: value, - ); - }, ), ), - ), // Adds bottom space to the message list, ensuring it is displayed // above the message text field. diff --git a/lib/src/widgets/chat_list_widget.dart b/lib/src/widgets/chat_list_widget.dart index add38e78..e19c92d0 100644 --- a/lib/src/widgets/chat_list_widget.dart +++ b/lib/src/widgets/chat_list_widget.dart @@ -36,7 +36,6 @@ class ChatListWidget extends StatefulWidget { Key? key, required this.chatController, required this.chatBackgroundConfig, - required this.showTypingIndicator, required this.assignReplyMessage, required this.replyMessage, this.loadingWidget, @@ -63,9 +62,6 @@ class ChatListWidget extends StatefulWidget { /// Provides widget for loading view while pagination is enabled. final Widget? loadingWidget; - /// Provides flag for turn on/off typing indicator. - final bool showTypingIndicator; - /// Provides configuration for reaction pop up appearance. final ReactionPopupConfiguration? reactionPopupConfig; @@ -128,8 +124,6 @@ class _ChatListWidgetState extends State ScrollController get scrollController => chatController.scrollController; - bool get showTypingIndicator => widget.showTypingIndicator; - ChatBackgroundConfiguration get chatBackgroundConfig => widget.chatBackgroundConfig; @@ -193,7 +187,6 @@ class _ChatListWidgetState extends State children: [ ChatGroupedListWidget( showPopUp: showPopupValue, - showTypingIndicator: showTypingIndicator, scrollController: scrollController, isEnableSwipeToSeeTime: featureActiveConfig?.enableSwipeToSeeTime ?? true, diff --git a/lib/src/widgets/chat_view.dart b/lib/src/widgets/chat_view.dart index c62723fb..22696ff7 100644 --- a/lib/src/widgets/chat_view.dart +++ b/lib/src/widgets/chat_view.dart @@ -160,8 +160,6 @@ class _ChatViewState extends State ChatController get chatController => widget.chatController; - // bool get showTypingIndicator => widget.showTypingIndicator; - ChatBackgroundConfiguration get chatBackgroundConfig => widget.chatBackgroundConfig; @@ -242,8 +240,6 @@ class _ChatViewState extends State valueListenable: replyMessage, builder: (_, state, child) { return ChatListWidget( - showTypingIndicator: - chatController.showTypingIndicator, replyMessage: state, chatController: widget.chatController, chatBackgroundConfig: widget.chatBackgroundConfig,