Skip to content

Commit

Permalink
feat: 🌟 listen to typing indicator changes better
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbadstuebner committed Jun 17, 2024
1 parent 232214c commit 800871f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
29 changes: 10 additions & 19 deletions lib/src/widgets/chat_groupedlist_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -103,8 +101,6 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>

bool get showPopUp => widget.showPopUp;

bool get showTypingIndicator => widget.showTypingIndicator;

bool highlightMessage = false;
final ValueNotifier<String?> _replyId = ValueNotifier(null);

Expand Down Expand Up @@ -184,7 +180,6 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
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,
Expand All @@ -210,23 +205,19 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
)
: _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(
ValueListenableBuilder(
valueListenable: ChatViewInheritedWidget.of(context)!
.chatController
.typingIndicatorNotifier,
builder: (context, value, child) => value
? TypingIndicator(
typeIndicatorConfig: widget.typeIndicatorConfig,
chatBubbleConfig:
chatBubbleConfig?.inComingChatBubbleConfig,
showIndicator: value,
),
),
)
: Container(),
),
Flexible(
child: Align(
alignment: suggestionsListConfig.axisAlignment.alignment,
Expand Down
7 changes: 0 additions & 7 deletions lib/src/widgets/chat_list_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -128,8 +124,6 @@ class _ChatListWidgetState extends State<ChatListWidget>

ScrollController get scrollController => chatController.scrollController;

bool get showTypingIndicator => widget.showTypingIndicator;

ChatBackgroundConfiguration get chatBackgroundConfig =>
widget.chatBackgroundConfig;

Expand Down Expand Up @@ -193,7 +187,6 @@ class _ChatListWidgetState extends State<ChatListWidget>
children: [
ChatGroupedListWidget(
showPopUp: showPopupValue,
showTypingIndicator: showTypingIndicator,
scrollController: scrollController,
isEnableSwipeToSeeTime:
featureActiveConfig?.enableSwipeToSeeTime ?? true,
Expand Down
4 changes: 0 additions & 4 deletions lib/src/widgets/chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ class _ChatViewState extends State<ChatView>

ChatController get chatController => widget.chatController;

// bool get showTypingIndicator => widget.showTypingIndicator;

ChatBackgroundConfiguration get chatBackgroundConfig =>
widget.chatBackgroundConfig;

Expand Down Expand Up @@ -249,8 +247,6 @@ class _ChatViewState extends State<ChatView>
valueListenable: replyMessage,
builder: (_, state, child) {
return ChatListWidget(
showTypingIndicator:
chatController.showTypingIndicator,
replyMessage: state,
chatController: widget.chatController,
chatBackgroundConfig: widget.chatBackgroundConfig,
Expand Down

0 comments on commit 800871f

Please sign in to comment.