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
59 changes: 59 additions & 0 deletions example/lib/example_two/example_two_chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,65 @@ class _ExampleTwoChatScreenState extends State<ExampleTwoChatScreen> {
const SnackBar(content: Text('Attach button pressed')),
),
),
replyMessageBuilder: (context, state) {
final repliedUser = state.replyTo.isNotEmpty
? _chatController.getUserFromId(state.replyTo)
: null;
final replyTo = state.replyTo == _chatController.currentUser.id
? PackageStrings.currentLocale.you
: repliedUser?.name ?? '';
return 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(
state.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),
),
),
],
),
);
},
featureActiveConfig: const FeatureActiveConfig(
lastSeenAgoBuilderVisibility: false,
enableOtherUserProfileAvatar: false,
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
Copy Markdown
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
134 changes: 72 additions & 62 deletions lib/src/widgets/send_message_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,67 +95,77 @@ 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,
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,
),
child: Stack(
Padding(
key: chatViewIW?.chatTextFieldViewKey,
padding: EdgeInsets.fromLTRB(
bottomPadding4,
bottomPadding4,
bottomPadding4,
_bottomPadding,
),
child: isCustomTextField
? Column(
mainAxisSize: MainAxisSize.min,
children: [
ReplyMessageView(
key: _replyMessageTextFieldViewKey,
sendMessageConfig: widget.sendMessageConfig,
messageConfig: widget.messageConfig,
builder: widget.replyMessageBuilder,
onChange: (value) => _replyMessage = value,
),
Builder(
builder: (context) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => context
.calculateAndUpdateTextFieldHeight(),
);
return widget.sendMessageBuilder
?.call(_replyMessage) ??
const SizedBox.shrink();
},
),
],
)
: Stack(
alignment: Alignment.bottomCenter,
children: [
ReplyMessageView(
Expand Down Expand Up @@ -198,13 +208,13 @@ class SendMessageWidgetState extends State<SendMessageWidget> {
),
],
),
),
],
),
),
],
),
),
],
),
),
);
}

Expand Down
Loading