Skip to content

Commit

Permalink
fix: šŸ› added report button and update report and more button callbacks ā€¦
Browse files Browse the repository at this point in the history
ā€¦#130

- Update more and report button callbacks
- Added report button for receiver's message and provides its callback
  • Loading branch information
apurva010 committed May 20, 2024
1 parent 179c769 commit 807c6f7
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 27 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/src/models/reply_popup_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/src/utils/package_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
1 change: 1 addition & 0 deletions lib/src/values/typedefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ typedef VoidCallBackWithFuture = Future<void> 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);
19 changes: 10 additions & 9 deletions lib/src/widgets/chat_list_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,22 @@ class _ChatListWidgetState extends State<ChatListWidget>
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);
Expand Down
49 changes: 34 additions & 15 deletions lib/src/widgets/reply_popup_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
],
),
Expand Down

0 comments on commit 807c6f7

Please sign in to comment.