Skip to content

Commit 800871f

Browse files
feat: 🌟 listen to typing indicator changes better
1 parent 232214c commit 800871f

File tree

3 files changed

+10
-30
lines changed

3 files changed

+10
-30
lines changed

lib/src/widgets/chat_groupedlist_widget.dart

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class ChatGroupedListWidget extends StatefulWidget {
3333
const ChatGroupedListWidget({
3434
Key? key,
3535
required this.showPopUp,
36-
required this.showTypingIndicator,
3736
required this.scrollController,
3837
required this.chatBackgroundConfig,
3938
required this.replyMessage,
@@ -52,8 +51,7 @@ class ChatGroupedListWidget extends StatefulWidget {
5251
/// Allow user to swipe to see time while reaction pop is not open.
5352
final bool showPopUp;
5453

55-
/// Allow user to show typing indicator.
56-
final bool showTypingIndicator;
54+
/// Pass scroll controller
5755
final ScrollController scrollController;
5856

5957
/// Allow user to give customisation to background of chat
@@ -103,8 +101,6 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
103101

104102
bool get showPopUp => widget.showPopUp;
105103

106-
bool get showTypingIndicator => widget.showTypingIndicator;
107-
108104
bool highlightMessage = false;
109105
final ValueNotifier<String?> _replyId = ValueNotifier(null);
110106

@@ -184,7 +180,6 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
184180
reverse: true,
185181
// When reaction popup is being appeared at that user should not scroll.
186182
physics: showPopUp ? const NeverScrollableScrollPhysics() : null,
187-
padding: EdgeInsets.only(bottom: showTypingIndicator ? 50 : 0),
188183
controller: widget.scrollController,
189184
child: Column(
190185
mainAxisSize: MainAxisSize.min,
@@ -210,23 +205,19 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
210205
)
211206
: _chatStreamBuilder,
212207
),
213-
widget.showTypingIndicator
214-
? TypingIndicator(
215-
typeIndicatorConfig: widget.typeIndicatorConfig,
216-
chatBubbleConfig: chatBubbleConfig?.inComingChatBubbleConfig,
217-
showIndicator: widget.showTypingIndicator,
218-
)
219-
: ValueListenableBuilder(
220-
valueListenable: ChatViewInheritedWidget.of(context)!
221-
.chatController
222-
.typingIndicatorNotifier,
223-
builder: (context, value, child) => TypingIndicator(
208+
ValueListenableBuilder(
209+
valueListenable: ChatViewInheritedWidget.of(context)!
210+
.chatController
211+
.typingIndicatorNotifier,
212+
builder: (context, value, child) => value
213+
? TypingIndicator(
224214
typeIndicatorConfig: widget.typeIndicatorConfig,
225215
chatBubbleConfig:
226216
chatBubbleConfig?.inComingChatBubbleConfig,
227217
showIndicator: value,
228-
),
229-
),
218+
)
219+
: Container(),
220+
),
230221
Flexible(
231222
child: Align(
232223
alignment: suggestionsListConfig.axisAlignment.alignment,

lib/src/widgets/chat_list_widget.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class ChatListWidget extends StatefulWidget {
3636
Key? key,
3737
required this.chatController,
3838
required this.chatBackgroundConfig,
39-
required this.showTypingIndicator,
4039
required this.assignReplyMessage,
4140
required this.replyMessage,
4241
this.loadingWidget,
@@ -63,9 +62,6 @@ class ChatListWidget extends StatefulWidget {
6362
/// Provides widget for loading view while pagination is enabled.
6463
final Widget? loadingWidget;
6564

66-
/// Provides flag for turn on/off typing indicator.
67-
final bool showTypingIndicator;
68-
6965
/// Provides configuration for reaction pop up appearance.
7066
final ReactionPopupConfiguration? reactionPopupConfig;
7167

@@ -128,8 +124,6 @@ class _ChatListWidgetState extends State<ChatListWidget>
128124

129125
ScrollController get scrollController => chatController.scrollController;
130126

131-
bool get showTypingIndicator => widget.showTypingIndicator;
132-
133127
ChatBackgroundConfiguration get chatBackgroundConfig =>
134128
widget.chatBackgroundConfig;
135129

@@ -193,7 +187,6 @@ class _ChatListWidgetState extends State<ChatListWidget>
193187
children: [
194188
ChatGroupedListWidget(
195189
showPopUp: showPopupValue,
196-
showTypingIndicator: showTypingIndicator,
197190
scrollController: scrollController,
198191
isEnableSwipeToSeeTime:
199192
featureActiveConfig?.enableSwipeToSeeTime ?? true,

lib/src/widgets/chat_view.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ class _ChatViewState extends State<ChatView>
164164

165165
ChatController get chatController => widget.chatController;
166166

167-
// bool get showTypingIndicator => widget.showTypingIndicator;
168-
169167
ChatBackgroundConfiguration get chatBackgroundConfig =>
170168
widget.chatBackgroundConfig;
171169

@@ -249,8 +247,6 @@ class _ChatViewState extends State<ChatView>
249247
valueListenable: replyMessage,
250248
builder: (_, state, child) {
251249
return ChatListWidget(
252-
showTypingIndicator:
253-
chatController.showTypingIndicator,
254250
replyMessage: state,
255251
chatController: widget.chatController,
256252
chatBackgroundConfig: widget.chatBackgroundConfig,

0 commit comments

Comments
 (0)