Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [Unreleased]

* **Fix**: [428](https://github.com/SimformSolutionsPvtLtd/chatview/pull/428) Fixed reply
configuration handling when using a custom text field.
* **Fix**: [423](https://github.com/SimformSolutionsPvtLtd/chatview/pull/423)
Rendering issue in attached image preview when sending message on web.
* **Feat**: [420](https://github.com/SimformSolutionsPvtLtd/chatview/pull/420) Added support for
Expand Down
64 changes: 2 additions & 62 deletions example/lib/widgets/custom_chat_bar.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:io';

import 'package:audio_waveforms/audio_waveforms.dart';
import 'package:chatview/chatview.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:audio_waveforms/audio_waveforms.dart';

import '../../values/colors.dart';
import '../../values/icons.dart';
Expand Down Expand Up @@ -48,74 +48,14 @@ class _CustomChatBarState extends State<CustomChatBar> {
if (_replyMessage != null) {
_replyMessage = widget.replyMessage;
}
final repliedUser = _replyMessage?.replyTo.isNotEmpty ?? false
? widget.chatController.getUserFromId(_replyMessage?.replyTo ?? '')
: null;
String replyTo =
_replyMessage?.replyTo == widget.chatController.currentUser.id
? PackageStrings.currentLocale.you
: repliedUser?.name ?? '';

return Container(
color: AppColors.uiTwoBackground,
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (_replyMessage?.message.isNotEmpty ?? false)
Container(
padding: const EdgeInsets.fromLTRB(8, 8, 7.5, 7.5),
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: AppColors.uiTwoReplyLineColor,
width: 4,
),
),
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
replyTo,
style: const TextStyle(
fontStyle: FontStyle.normal,
fontWeight: FontWeight.w600,
fontSize: 14,
height: 1.3571428571,
letterSpacing: -0.01,
color: Color(0xFFD42A66),
),
),
const SizedBox(height: 1.5),
Text(
_replyMessage?.message ?? '',
style: const TextStyle(
fontSize: 12,
height: 1.33,
color: Color(0xFF0A0A0A),
),
),
],
),
),
const SizedBox(width: 16),
SizedBox.square(
dimension: 32,
child: IconButton(
onPressed: () => ChatView.closeReplyMessageView(
context,
),
padding: EdgeInsets.zero,
icon: SvgPicture.asset(AppIcons.closeCircular),
),
),
],
),
),
Comment on lines -65 to -118
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please migrate this reply view to replyMessageBuilder

Padding(
padding: const EdgeInsets.fromLTRB(7, 5.5, 9, 5.5),
child: ValueListenableBuilder(
Expand Down
153 changes: 77 additions & 76 deletions lib/src/widgets/send_message_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,83 +95,80 @@ class SendMessageWidgetState extends State<SendMessageWidget> {
chatListConfig.scrollToBottomButtonConfig;
return Align(
alignment: Alignment.bottomCenter,
child: isCustomTextField
? Builder(
// Assign the key only when using a custom text field to measure its height,
// to preventing overlap with the message list.
key: chatViewIW?.chatTextFieldViewKey,
builder: (context) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => context.calculateAndUpdateTextFieldHeight(),
);
return widget.sendMessageBuilder?.call(_replyMessage) ??
const SizedBox.shrink();
},
)
: SizedBox(
width: MediaQuery.of(context).size.width,
child: Stack(
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: Stack(
children: [
// This has been added to prevent messages from being
// displayed below the text field
// when the user scrolls the message list.
Positioned(
right: 0,
left: 0,
bottom: 0,
child: Container(
height: MediaQuery.of(context).size.height /
((!kIsWeb && Platform.isIOS) ? 24 : 28),
color: chatListConfig.chatBackgroundConfig.backgroundColor ??
Colors.white,
),
),
Positioned(
right: 0,
left: 0,
bottom: 0,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// This has been added to prevent messages from being
// displayed below the text field
// when the user scrolls the message list.
Positioned(
right: 0,
left: 0,
bottom: 0,
child: Container(
height: MediaQuery.of(context).size.height /
((!kIsWeb && Platform.isIOS) ? 24 : 28),
color:
chatListConfig.chatBackgroundConfig.backgroundColor ??
Colors.white,
if (chatViewIW
?.featureActiveConfig.enableScrollToBottomButton ??
true)
Align(
alignment:
scrollToBottomButtonConfig?.alignment?.alignment ??
Alignment.bottomCenter,
child: Padding(
padding: scrollToBottomButtonConfig?.padding ??
EdgeInsets.zero,
child: const ScrollToBottomButton(),
),
),
),
Positioned(
right: 0,
left: 0,
bottom: 0,
child: Column(
mainAxisSize: MainAxisSize.min,
Padding(
key: chatViewIW?.chatTextFieldViewKey,
padding: EdgeInsets.fromLTRB(
bottomPadding4,
bottomPadding4,
bottomPadding4,
_bottomPadding,
),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
if (chatViewIW?.featureActiveConfig
.enableScrollToBottomButton ??
true)
Align(
alignment: scrollToBottomButtonConfig
?.alignment?.alignment ??
Alignment.bottomCenter,
child: Padding(
padding: scrollToBottomButtonConfig?.padding ??
EdgeInsets.zero,
child: const ScrollToBottomButton(),
),
),
Padding(
key: chatViewIW?.chatTextFieldViewKey,
padding: EdgeInsets.fromLTRB(
bottomPadding4,
bottomPadding4,
bottomPadding4,
_bottomPadding,
ReplyMessageView(
key: _replyMessageTextFieldViewKey,
sendMessageConfig: widget.sendMessageConfig,
messageConfig: widget.messageConfig,
builder: widget.replyMessageBuilder,
onChange: (value) => _replyMessage = value,
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With sendMessageBuilder (custom text field), the builder depends on the ReplyMessage argument to attach reply metadata when sending. After this refactor, _replyMessage is updated via ReplyMessageView(onChange: ...) without calling setState, so the custom sendMessageBuilder widget may not rebuild when the reply message is set/cleared. That can leave the custom UI holding a stale ReplyMessage and sending incorrect reply info.

Consider triggering a rebuild when the reply message changes (e.g., call setState inside onChange when widget.sendMessageBuilder != null, or otherwise make the custom builder listen to the reply message changes).

Suggested change
onChange: (value) => _replyMessage = value,
onChange: (value) {
if (isCustomTextField) {
setState(() => _replyMessage = value);
} else {
_replyMessage = value;
}
},

Copilot uses AI. Check for mistakes.
),
if (widget.sendMessageConfig.shouldSendImageWithText)
SelectedImageViewWidget(
key: _selectedImageViewWidgetKey,
sendMessageConfig: widget.sendMessageConfig,
),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
ReplyMessageView(
key: _replyMessageTextFieldViewKey,
sendMessageConfig: widget.sendMessageConfig,
messageConfig: widget.messageConfig,
builder: widget.replyMessageBuilder,
onChange: (value) => _replyMessage = value,
),
if (widget
.sendMessageConfig.shouldSendImageWithText)
SelectedImageViewWidget(
key: _selectedImageViewWidgetKey,
sendMessageConfig: widget.sendMessageConfig,
),
ChatUITextField(
isCustomTextField
? Builder(
builder: (context) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => context
.calculateAndUpdateTextFieldHeight(),
);
return widget.sendMessageBuilder
?.call(_replyMessage) ??
const SizedBox.shrink();
},
)
: ChatUITextField(
focusNode: _focusNode,
textEditingController: _textEditingController,
onPressed: _onPressed,
Expand All @@ -196,15 +193,15 @@ class SendMessageWidgetState extends State<SendMessageWidget> {
}
},
),
],
),
),
],
),
),
],
),
),
],
),
),
);
}

Expand Down Expand Up @@ -272,6 +269,10 @@ class SendMessageWidgetState extends State<SendMessageWidget> {
_replyMessageTextFieldViewKey.currentState!.replyMessage.value =
_replyMessage;
}
// Scroll to ensure the reply widget is visible and messages are not overlapped
WidgetsBinding.instance.addPostFrameCallback((_) {
chatViewIW?.chatController.scrollToLastMessage();
});
Comment on lines +272 to +275
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review this, as the view scrolls down every time a user tries to reply to a message.

}

void onCloseTap() {
Expand Down