From 14708d7f809363098b88cda57dd53fd0ac0c78d8 Mon Sep 17 00:00:00 2001 From: vatsaltanna-simformsolutions <63704011+vatsaltanna-simformsolutions@users.noreply.github.com> Date: Tue, 6 Aug 2024 09:55:32 +0530 Subject: [PATCH] feat: :sparkles: ability to completely override userReactionCallback (#236) --- CHANGELOG.md | 2 ++ lib/src/models/reaction_popup_configuration.dart | 4 ++++ lib/src/widgets/reaction_popup.dart | 12 +++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f136dee..87fa6192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ hide share icon in image view * **Fix**: [232](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/232) The audio record cancelIcon is overflowed pixel +* **Feat** [228](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/228) Ability to + completely override userReactionCallback ## [2.0.0] diff --git a/lib/src/models/reaction_popup_configuration.dart b/lib/src/models/reaction_popup_configuration.dart index 5854b8d9..8df12e50 100644 --- a/lib/src/models/reaction_popup_configuration.dart +++ b/lib/src/models/reaction_popup_configuration.dart @@ -54,8 +54,12 @@ class ReactionPopupConfiguration { /// Provides callback when user react on message. final ReactionCallback? userReactionCallback; + /// Provides feasibility to completely override userReactionCallback defaults to false. + final bool? overrideUserReactionCallback; + const ReactionPopupConfiguration({ this.userReactionCallback, + this.overrideUserReactionCallback = false, this.showGlassMorphismEffect = false, this.backgroundColor, this.shadow, diff --git a/lib/src/widgets/reaction_popup.dart b/lib/src/widgets/reaction_popup.dart index d7330300..4e6841e1 100644 --- a/lib/src/widgets/reaction_popup.dart +++ b/lib/src/widgets/reaction_popup.dart @@ -147,11 +147,13 @@ class ReactionPopupState extends State onEmojiTap: (emoji) { widget.onTap(); if (currentUser != null && _message != null) { - chatController?.setReaction( - emoji: emoji, - messageId: _message!.id, - userId: currentUser!.id, - ); + if (!(reactionPopupConfig?.overrideUserReactionCallback ?? false)) { + chatController?.setReaction( + emoji: emoji, + messageId: _message!.id, + userId: currentUser!.id, + ); + } reactionPopupConfig?.userReactionCallback?.call( _message!, emoji,