feat: Add button to report offensive users to server admins

This commit is contained in:
Christian Pauly 2022-02-03 06:53:14 +01:00
parent dfa58cfe05
commit b96e67ceea
3 changed files with 53 additions and 1 deletions

View File

@ -2708,5 +2708,6 @@
"iUnderstand": "I understand",
"@iUnderstand": {},
"dismiss": "Dismiss",
"markAsRead": "Mark as read"
"markAsRead": "Mark as read",
"reportUser": "Report user"
}

View File

@ -39,6 +39,50 @@ class UserBottomSheetController extends State<UserBottomSheet> {
) ==
OkCancelResult.ok);
switch (action) {
case 'report':
final event = widget.user;
final score = await showConfirmationDialog<int>(
context: context,
title: L10n.of(context)!.reportUser,
message: L10n.of(context)!.howOffensiveIsThisContent,
cancelLabel: L10n.of(context)!.cancel,
okLabel: L10n.of(context)!.ok,
actions: [
AlertDialogAction(
key: -100,
label: L10n.of(context)!.extremeOffensive,
),
AlertDialogAction(
key: -50,
label: L10n.of(context)!.offensive,
),
AlertDialogAction(
key: 0,
label: L10n.of(context)!.inoffensive,
),
]);
if (score == null) return;
final reason = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.whyDoYouWantToReportThis,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
textFields: [DialogTextField(hintText: L10n.of(context)!.reason)]);
if (reason == null || reason.single.isEmpty) return;
final result = await showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context).client.reportContent(
event.roomId!,
event.eventId,
reason: reason.single,
score: score,
),
);
if (result.error != null) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context)!.contentHasBeenReported)));
break;
case 'mention':
Navigator.of(context, rootNavigator: false).pop();
widget.onMention!();

View File

@ -102,6 +102,13 @@ class UserBottomSheetView extends StatelessWidget {
Icons.block,
),
),
PopupMenuItem(
value: 'report',
child: _TextWithIcon(
L10n.of(context)!.reportUser,
Icons.shield_outlined,
),
),
],
onSelected: controller.participantAction,
),