✨ Report post
This commit is contained in:
parent
fa346b528e
commit
d4aaf61091
@ -387,5 +387,10 @@
|
||||
"articleWrittenAt": "Written at {}",
|
||||
"articleEditedAt": "Edited at {}",
|
||||
"attachmentSaved": "Saved to album",
|
||||
"openInAlbum": "Open in album"
|
||||
"openInAlbum": "Open in album",
|
||||
"postAbuseReport": "Report Post",
|
||||
"postAbuseReportDescription": "Report posts that violate our user agreement and community guidelines to help us improve the content on Solar Network. Please describe how this post violates the relevant rules. Do not include any sensitive information. We will process your report within 24 hours.",
|
||||
"postAbuseReportReason": "Reason",
|
||||
"postAbuseReportSubmitted": "Report submitted, thank you for your contribution.",
|
||||
"submit": "Submit"
|
||||
}
|
||||
|
@ -387,5 +387,10 @@
|
||||
"articleWrittenAt": "发表于 {}",
|
||||
"articleEditedAt": "编辑于 {}",
|
||||
"attachmentSaved": "已保存到相册",
|
||||
"openInAlbum": "在相册中打开"
|
||||
"openInAlbum": "在相册中打开",
|
||||
"postAbuseReport": "检举帖子",
|
||||
"postAbuseReportDescription": "检举不符合我们用户协议以及社区准则的帖子,来帮助我们更好的维护 Solar Network 上的内容。请在下面描述该帖子如何违反我么的相关规定。请勿填写任何敏感信息。我们将会在 24 小时内处理您的检举。",
|
||||
"postAbuseReportReason": "检举原因",
|
||||
"postAbuseReportSubmitted": "检举已提交,感谢你的贡献。",
|
||||
"submit": "提交"
|
||||
}
|
||||
|
@ -569,6 +569,18 @@ class _PostContentHeader extends StatelessWidget {
|
||||
Text('report').tr(),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => _PostAbuseReportDialog(
|
||||
data: data,
|
||||
),
|
||||
).then((value) {
|
||||
if (value == true && context.mounted) {
|
||||
context.showSnackbar('postAbuseReportSubmitted'.tr());
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -724,3 +736,79 @@ class _PostTruncatedHint extends StatelessWidget {
|
||||
).opacity(0.75);
|
||||
}
|
||||
}
|
||||
|
||||
class _PostAbuseReportDialog extends StatefulWidget {
|
||||
final SnPost data;
|
||||
|
||||
const _PostAbuseReportDialog({super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<_PostAbuseReportDialog> createState() => _PostAbuseReportDialogState();
|
||||
}
|
||||
|
||||
class _PostAbuseReportDialogState extends State<_PostAbuseReportDialog> {
|
||||
bool _isBusy = false;
|
||||
|
||||
final _reasonController = TextEditingController();
|
||||
|
||||
@override
|
||||
dispose() {
|
||||
_reasonController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _performAction() async {
|
||||
setState(() => _isBusy = true);
|
||||
try {
|
||||
final sn = context.read<SnNetworkProvider>();
|
||||
await sn.client.request(
|
||||
'/cgi/id/reports/abuse',
|
||||
data: {
|
||||
'resource': 'post:${widget.data.id}',
|
||||
'reason': _reasonController.text,
|
||||
},
|
||||
);
|
||||
if (!mounted) return;
|
||||
Navigator.pop(context, true);
|
||||
} catch (err) {
|
||||
if (!mounted) return;
|
||||
context.showErrorDialog(err);
|
||||
} finally {
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('postAbuseReport'.tr()),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('postAbuseReportDescription'.tr()),
|
||||
const Gap(12),
|
||||
TextField(
|
||||
controller: _reasonController,
|
||||
maxLength: null,
|
||||
decoration: InputDecoration(
|
||||
border: const UnderlineInputBorder(),
|
||||
labelText: 'postAbuseReportReason'.tr(),
|
||||
),
|
||||
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _isBusy ? null : () => Navigator.pop(context),
|
||||
child: Text('dialogDismiss').tr(),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _isBusy ? null : _performAction,
|
||||
child: Text('submit').tr(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user