Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🌟 listen to typing indicator changes better #195

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 21 additions & 35 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,38 +205,29 @@ 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(
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.
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 @@ -160,8 +160,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 @@ -242,8 +240,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