diff --git a/lib/ui/screens/conversation_screen.dart b/lib/ui/screens/conversation_screen.dart index 6371227..55637af 100644 --- a/lib/ui/screens/conversation_screen.dart +++ b/lib/ui/screens/conversation_screen.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:comunic/enums/report_target_type.dart'; import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/helpers/events_helper.dart'; import 'package:comunic/helpers/server_config_helper.dart'; @@ -11,7 +12,9 @@ import 'package:comunic/models/config.dart'; import 'package:comunic/models/conversation.dart'; import 'package:comunic/models/conversation_message.dart'; import 'package:comunic/models/new_conversation_message.dart'; +import 'package:comunic/models/report_target.dart'; import 'package:comunic/ui/dialogs/pick_file_dialog.dart'; +import 'package:comunic/ui/dialogs/report_dialog.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/tiles/conversation_message_tile.dart'; import 'package:comunic/ui/tiles/server_conversation_message_tile.dart'; @@ -504,6 +507,7 @@ class _ConversationScreenState extends SafeState { onRequestMessageStats: _requestMessageStats, onRequestMessageUpdate: _updateMessage, onRequestMessageDelete: _deleteMessage, + onReportMessage: _reportMessage, ); Widget _buildDateWidget(DateTime dt) => Center( @@ -753,4 +757,9 @@ class _ConversationScreenState extends SafeState { if (!await _conversationsHelper.deleteMessage(message.id)) showSimpleSnack(context, tr("Could not delete conversation message!")!); } + + /// Report message + void _reportMessage(ConversationMessage msg) => showReportDialog( + ctx: context, + target: ReportTarget(ReportTargetType.ConversationMessage, msg.id!)); } diff --git a/lib/ui/tiles/comment_tile.dart b/lib/ui/tiles/comment_tile.dart index e5a4730..dfe0645 100644 --- a/lib/ui/tiles/comment_tile.dart +++ b/lib/ui/tiles/comment_tile.dart @@ -115,7 +115,7 @@ class CommentTile extends StatelessWidget { ]..addAll(srvConfig!.isReportingEnabled && !comment.isOwner ? [ PopupMenuItem( - child: Text(tr("Report Abuse")!), + child: Text(tr("Report abuse")!), value: _CommentAction.REPORT, ) ] diff --git a/lib/ui/tiles/conversation_message_tile.dart b/lib/ui/tiles/conversation_message_tile.dart index 481e60f..c0dd9d3 100644 --- a/lib/ui/tiles/conversation_message_tile.dart +++ b/lib/ui/tiles/conversation_message_tile.dart @@ -1,3 +1,4 @@ +import 'package:comunic/helpers/server_config_helper.dart'; import 'package:comunic/models/conversation_message.dart'; import 'package:comunic/models/user.dart'; import 'package:comunic/ui/widgets/conversation_file_tile.dart'; @@ -17,6 +18,7 @@ enum _MenuChoices { DELETE, REQUEST_UPDATE_CONTENT, GET_STATS, + REPORT } typedef OnRequestMessageStats = void Function(ConversationMessage); @@ -29,6 +31,7 @@ class ConversationMessageTile extends StatelessWidget { final OnRequestMessageStats onRequestMessageStats; final OnRequestMessageUpdate onRequestMessageUpdate; final OnRequestMessageDelete onRequestMessageDelete; + final Function(ConversationMessage) onReportMessage; const ConversationMessageTile({ Key? key, @@ -37,6 +40,7 @@ class ConversationMessageTile extends StatelessWidget { required this.onRequestMessageStats, required this.onRequestMessageUpdate, required this.onRequestMessageDelete, + required this.onReportMessage, }) : super(key: key); @override @@ -90,6 +94,14 @@ class ConversationMessageTile extends StatelessWidget { value: _MenuChoices.DELETE, child: Text(tr("Delete")!), ), + + // Report the message + PopupMenuItem( + enabled: + srvConfig!.isReportingEnabled && !message.isOwner, + value: _MenuChoices.REPORT, + child: Text(tr("Report abuse")!), + ), ]..removeWhere((element) => !element.enabled), ), ) @@ -133,6 +145,10 @@ class ConversationMessageTile extends StatelessWidget { case _MenuChoices.DELETE: onRequestMessageDelete(message); break; + + case _MenuChoices.REPORT: + onReportMessage(message); + break; } } } diff --git a/lib/ui/tiles/conversation_tile.dart b/lib/ui/tiles/conversation_tile.dart index 5f2aebf..6140d6a 100644 --- a/lib/ui/tiles/conversation_tile.dart +++ b/lib/ui/tiles/conversation_tile.dart @@ -133,7 +133,7 @@ class ConversationTile extends StatelessWidget { ]..addAll(srvConfig!.isReportingEnabled ? [ PopupMenuItem( - child: Text(tr("Report")!), + child: Text(tr("Report abuse")!), value: _PopupMenuChoices.REPORT, ) ]