From 807c6f7cc71dd22ca2005dd4dcd091a1dc51dec8 Mon Sep 17 00:00:00 2001 From: Apurva Kanthraviya Date: Thu, 16 May 2024 15:39:27 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20added=20report=20button?= =?UTF-8?q?=20and=20update=20report=20and=20more=20button=20callbacks=20#1?= =?UTF-8?q?30?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update more and report button callbacks - Added report button for receiver's message and provides its callback --- CHANGELOG.md | 3 ++ README.md | 19 ++++++- lib/src/models/reply_popup_configuration.dart | 4 +- lib/src/utils/package_strings.dart | 1 + lib/src/values/typedefs.dart | 1 + lib/src/widgets/chat_list_widget.dart | 19 +++---- lib/src/widgets/reply_popup_widget.dart | 49 +++++++++++++------ 7 files changed, 69 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 158def18..2a7009fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ ## [1.3.2] (Unreleased) + +* **Fix**: [130](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/130) Added + report button for receiver message and update onMoreTap, onReportTap callback. * **Fix**: [126](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/126) Added flag to hide user name in chat. * **Feat**: [161](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/161) Added diff --git a/README.md b/README.md index 0f0352a4..bd5be3c4 100644 --- a/README.md +++ b/README.md @@ -482,7 +482,7 @@ ChatView( ) ``` -19. Flag `enableOtherUserName` to hide user name in chat. +20. Flag `enableOtherUserName` to hide user name in chat. ```dart ChatView( @@ -495,6 +495,23 @@ ChatView( ) ``` +21. Added report button for receiver message and update `onMoreTap` and `onReportTap` callbacks. + +```dart +ChatView( + ... + replyPopupConfig: ReplyPopupConfiguration( + onReportTap: (Message message) { + debugPrint('Message: $message'); + }, + onMoreTap: (Message message, bool sendByCurrentUser) { + debugPrint('Message : $message'); + }, + ), + ... +) +``` + ## How to use diff --git a/lib/src/models/reply_popup_configuration.dart b/lib/src/models/reply_popup_configuration.dart index 15b3ecb4..0c0b0cc3 100644 --- a/lib/src/models/reply_popup_configuration.dart +++ b/lib/src/models/reply_popup_configuration.dart @@ -39,10 +39,10 @@ class ReplyPopupConfiguration { final MessageCallBack? onReplyTap; /// Provides callback on onReport button. - final VoidCallBack? onReportTap; + final MessageCallBack? onReportTap; /// Provides callback on onMore button. - final VoidCallBack? onMoreTap; + final MoreTapCallBack? onMoreTap; /// Used to give text style of button text. final TextStyle? buttonTextStyle; diff --git a/lib/src/utils/package_strings.dart b/lib/src/utils/package_strings.dart index 85c0e305..23c12ccc 100644 --- a/lib/src/utils/package_strings.dart +++ b/lib/src/utils/package_strings.dart @@ -34,4 +34,5 @@ class PackageStrings { static const String photo = "Photo"; static const String send = "Send"; static const String you = "You"; + static const String report = "Report"; } diff --git a/lib/src/values/typedefs.dart b/lib/src/values/typedefs.dart index 43ea2e41..515e4f88 100644 --- a/lib/src/values/typedefs.dart +++ b/lib/src/values/typedefs.dart @@ -35,3 +35,4 @@ typedef VoidCallBackWithFuture = Future Function(); typedef StringsCallBack = void Function(String emoji, String messageId); typedef StringWithReturnWidget = Widget Function(String separator); typedef DragUpdateDetailsCallback = void Function(DragUpdateDetails); +typedef MoreTapCallBack = void Function(Message message, bool sendByCurrentUser); diff --git a/lib/src/widgets/chat_list_widget.dart b/lib/src/widgets/chat_list_widget.dart index b246a33d..09fb2d19 100644 --- a/lib/src/widgets/chat_list_widget.dart +++ b/lib/src/widgets/chat_list_widget.dart @@ -271,21 +271,22 @@ class _ChatListWidgetState extends State topBorderColor: replyPopup?.topBorderColor, onMoreTap: () { _onChatListTap(); - if (replyPopup?.onMoreTap != null) { - replyPopup?.onMoreTap!(); - } + replyPopup?.onMoreTap?.call( + message, + sendByCurrentUser, + ); }, onReportTap: () { _onChatListTap(); - if (replyPopup?.onReportTap != null) { - replyPopup?.onReportTap!(); - } + replyPopup?.onReportTap?.call( + message, + ); }, onUnsendTap: () { _onChatListTap(); - if (replyPopup?.onUnsendTap != null) { - replyPopup?.onUnsendTap!(message); - } + replyPopup?.onUnsendTap?.call( + message, + ); }, onReplyTap: () { widget.assignReplyMessage(message); diff --git a/lib/src/widgets/reply_popup_widget.dart b/lib/src/widgets/reply_popup_widget.dart index e721ed5b..3e50ed9d 100644 --- a/lib/src/widgets/reply_popup_widget.dart +++ b/lib/src/widgets/reply_popup_widget.dart @@ -71,29 +71,48 @@ class ReplyPopupWidget extends StatelessWidget { color: topBorderColor ?? Colors.grey.shade400, width: 1)), ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - InkWell( - onTap: onReplyTap, - child: Text( - PackageStrings.reply, - style: textStyle, + Expanded( + child: InkWell( + onTap: onReplyTap, + child: Text( + PackageStrings.reply, + textAlign: TextAlign.center, + style: textStyle, + ), ), ), if (sendByCurrentUser) - InkWell( - onTap: onUnsendTap, + Expanded( + child: InkWell( + onTap: onUnsendTap, + child: Text( + PackageStrings.unsend, + textAlign: TextAlign.center, + style: textStyle, + ), + ), + ), + if (!sendByCurrentUser) + Expanded( + child: InkWell( + onTap: onReportTap, + child: Text( + PackageStrings.report, + textAlign: TextAlign.center, + style: textStyle, + ), + ), + ), + Expanded( + child: InkWell( + onTap: onMoreTap, child: Text( - PackageStrings.unsend, + PackageStrings.more, + textAlign: TextAlign.center, style: textStyle, ), ), - InkWell( - onTap: onMoreTap, - child: Text( - PackageStrings.more, - style: textStyle, - ), ), ], ),