Skip to content

Commit 46bb51e

Browse files
committed
add isReplyEnabled
1 parent fcd7f1a commit 46bb51e

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

lib/src/widgets/chat_view.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class ChatView extends StatefulWidget {
6363
this.replyMessageBuilder,
6464
this.replySuggestionsConfig,
6565
this.scrollToBottomButtonConfig,
66+
this.isReplyEnabled = true,
6667
}) : chatBackgroundConfig = chatBackgroundConfig ?? const ChatBackgroundConfiguration(),
6768
chatViewStateConfig = chatViewStateConfig ?? const ChatViewStateConfiguration(),
6869
super(key: key);
@@ -148,6 +149,9 @@ class ChatView extends StatefulWidget {
148149
/// Provides a configuration for scroll to bottom button config
149150
final ScrollToBottomButtonConfig? scrollToBottomButtonConfig;
150151

152+
/// Determines if the reply feature is enabled.
153+
final bool isReplyEnabled;
154+
151155
static void closeReplyMessageView(BuildContext context) {
152156
final state = context.findAncestorStateOfType<_ChatViewState>();
153157
if (state == null) return;
@@ -259,7 +263,7 @@ class _ChatViewState extends State<ChatView> with SingleTickerProviderStateMixin
259263
);
260264
},
261265
),
262-
if (featureActiveConfig.enableTextField)
266+
if (featureActiveConfig.enableTextField && widget.isReplyEnabled)
263267
SendMessageWidget(
264268
key: _sendMessageKey,
265269
sendMessageBuilder: widget.sendMessageBuilder,

lib/src/widgets/reply_icon.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ReplyIcon extends StatelessWidget {
2727
Key? key,
2828
required this.animationValue,
2929
this.replyIconSize = 25,
30+
this.isReplyEnabled = true,
3031
}) : super(key: key);
3132

3233
/// Represents scale animation value of icon when user swipes for reply.
@@ -35,8 +36,15 @@ class ReplyIcon extends StatelessWidget {
3536
/// Allow user to set color of icon which is appeared when user swipes for reply.
3637
final double replyIconSize;
3738

39+
/// Determines if the reply feature is enabled.
40+
final bool isReplyEnabled;
41+
3842
@override
3943
Widget build(BuildContext context) {
44+
if (!isReplyEnabled) {
45+
return const SizedBox.shrink();
46+
}
47+
4048
final swipeToReplyConfig = context.chatListConfig.swipeToReplyConfig;
4149
return Stack(
4250
alignment: Alignment.center,
@@ -45,8 +53,7 @@ class ReplyIcon extends StatelessWidget {
4553
decoration: BoxDecoration(
4654
borderRadius: BorderRadius.circular(replyIconSize),
4755
color: animationValue >= 1.0
48-
? swipeToReplyConfig?.replyIconBackgroundColor ??
49-
Colors.grey.shade300
56+
? swipeToReplyConfig?.replyIconBackgroundColor ?? Colors.grey.shade300
5057
: Colors.transparent,
5158
),
5259
height: replyIconSize,
@@ -55,8 +62,7 @@ class ReplyIcon extends StatelessWidget {
5562
value: animationValue,
5663
backgroundColor: Colors.transparent,
5764
strokeWidth: 1.5,
58-
color: swipeToReplyConfig?.replyIconProgressRingColor ??
59-
Colors.grey.shade300,
65+
color: swipeToReplyConfig?.replyIconProgressRingColor ?? Colors.grey.shade300,
6066
),
6167
),
6268
Transform.scale(

lib/src/widgets/swipe_to_reply.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SwipeToReply extends StatefulWidget {
3131
required this.onSwipe,
3232
required this.child,
3333
this.isMessageByCurrentUser = true,
34+
this.isReplyEnabled = true,
3435
}) : super(key: key);
3536

3637
/// Provides callback when user swipes chat bubble from left side.
@@ -65,8 +66,7 @@ class _SwipeToReplyState extends State<SwipeToReply> {
6566
return !(chatViewIW?.featureActiveConfig.enableSwipeToReply ?? true)
6667
? widget.child
6768
: GestureDetector(
68-
onHorizontalDragStart: (details) =>
69-
initialTouchPoint = details.globalPosition.dx,
69+
onHorizontalDragStart: (details) => initialTouchPoint = details.globalPosition.dx,
7070
onHorizontalDragEnd: (details) => setState(
7171
() {
7272
paddingValue = 0;
@@ -75,16 +75,12 @@ class _SwipeToReplyState extends State<SwipeToReply> {
7575
),
7676
onHorizontalDragUpdate: _onHorizontalDragUpdate,
7777
child: Stack(
78-
alignment: isMessageByCurrentUser
79-
? Alignment.centerRight
80-
: Alignment.centerLeft,
78+
alignment: isMessageByCurrentUser ? Alignment.centerRight : Alignment.centerLeft,
8179
fit: StackFit.passthrough,
8280
children: [
8381
ReplyIcon(
8482
replyIconSize: replyIconSize,
85-
animationValue: paddingValue > replyIconSize
86-
? (paddingValue) / (paddingLimit)
87-
: 0.0,
83+
animationValue: paddingValue > replyIconSize ? (paddingValue) / (paddingLimit) : 0.0,
8884
),
8985
Padding(
9086
padding: EdgeInsets.only(

0 commit comments

Comments
 (0)