opt: report panel

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-05 16:21:54 +08:00
parent 8236b93717
commit 72dd0b9e81
6 changed files with 151 additions and 109 deletions

View File

@@ -5,13 +5,10 @@ Widget radioWidget<T>({
T? groupValue,
required ValueChanged onChanged,
required String title,
double? paddingStart,
EdgeInsetsGeometry? padding,
}) {
return InkWell(
onTap: () => onChanged(value),
child: Row(
Widget child() => Row(
children: [
if (paddingStart != null) SizedBox(width: paddingStart),
Radio(
value: value,
groupValue: groupValue,
@@ -20,6 +17,14 @@ Widget radioWidget<T>({
),
Text(title),
],
),
);
return InkWell(
onTap: () => onChanged(value),
child: padding != null
? Padding(
padding: padding,
child: child(),
)
: child(),
);
}

View File

@@ -47,7 +47,9 @@ void autoWrapReportDialog(
padding: const EdgeInsets.only(left: 22),
child: Text(
title.key,
style: Theme.of(context).textTheme.labelSmall,
style: TextStyle(
color:
Theme.of(context).colorScheme.outline),
),
),
Padding(
@@ -59,6 +61,7 @@ void autoWrapReportDialog(
value: opt.key,
groupValue: reasonType,
title: opt.value,
padding: const EdgeInsets.only(right: 10),
onChanged: (value) {
reasonType = value;
if (context.mounted) {
@@ -105,23 +108,38 @@ void autoWrapReportDialog(
),
),
),
Padding(
padding: const EdgeInsets.only(left: 12, top: 12),
child: Row(
children: [
Checkbox(
value: banUid,
onChanged: (v) {
banUid = v ?? false;
GestureDetector(
onTap: () {
banUid = !banUid;
(context as Element?)?.markNeedsBuild();
},
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
child: Padding(
padding: const EdgeInsets.only(left: 18, top: 10),
child: Row(
children: [
Icon(
size: 22,
banUid
? Icons.check_box_outlined
: Icons.check_box_outline_blank,
color: banUid
? Theme.of(context).colorScheme.primary
: Theme.of(context)
.colorScheme
.onSurfaceVariant,
),
Text(
' 拉黑该用户',
style: TextStyle(
color: banUid
? Theme.of(context).colorScheme.primary
: null,
),
),
const Text('拉黑该用户'),
],
),
),
),
],
),
),
@@ -145,6 +163,7 @@ void autoWrapReportDialog(
SmartDialog.showLoading();
try {
final data = await onSuccess(reasonType!, reasonDesc, banUid);
SmartDialog.dismiss();
if (data['code'] == 0) {
Get.back();
SmartDialog.showToast('举报成功');
@@ -152,9 +171,8 @@ void autoWrapReportDialog(
SmartDialog.showToast(data['message']);
}
} catch (e) {
SmartDialog.showToast('提交失败:$e');
} finally {
SmartDialog.dismiss();
SmartDialog.showToast('提交失败:$e');
}
},
child: const Text('确定'),
@@ -167,7 +185,7 @@ void autoWrapReportDialog(
class ReportOptions {
// from https://s1.hdslb.com/bfs/seed/jinkela/comment-h5/static/js/605.chunks.js
static const Map<String, Map<int, String>> commentReport = {
static Map<String, Map<int, String>> get commentReport => {
'违反法律法规': {9: '违法违规', 2: '色情', 10: '低俗', 12: '赌博诈骗', 23: '违法信息外链'},
'谣言类不实信息': {19: '涉政谣言', 22: '虚假不实信息', 20: '涉社会事件谣言'},
'侵犯个人权益': {7: '人身攻击', 15: '侵犯隐私'},
@@ -183,7 +201,7 @@ class ReportOptions {
'其他': {0: '其他'},
};
static const Map<String, Map<int, String>> dynamicReport = {
static Map<String, Map<int, String>> get dynamicReport => {
'': {
4: '垃圾广告',
8: '引战',

View File

@@ -327,7 +327,9 @@ class AuthorPanel extends StatelessWidget {
),
onTap: () {
Get.back();
autoWrapReportDialog(context, ReportOptions.dynamicReport,
autoWrapReportDialog(
context,
ReportOptions.dynamicReport,
(reasonType, reasonDesc, banUid) async {
if (banUid) {
VideoHttp.relationMod(
@@ -352,7 +354,8 @@ class AuthorPanel extends StatelessWidget {
),
);
return res.data as Map;
});
},
);
},
minLeadingWidth: 0,
),

View File

@@ -1037,24 +1037,32 @@ class MorePanel extends StatelessWidget {
switch (type) {
case 'report':
Get.back();
autoWrapReportDialog(Get.context!, ReportOptions.commentReport,
autoWrapReportDialog(
Get.context!,
ReportOptions.commentReport,
(reasonType, reasonDesc, banUid) async {
final res = await Request().post('/x/v2/reply/report',
final res = await Request().post(
'/x/v2/reply/report',
data: {
'add_blacklist': banUid.toString(),
'add_blacklist': banUid,
'csrf': await Request.getCsrf(),
'gaia_source': 'main_h5',
'oid': item.oid.toString(),
'oid': item.oid,
'platform': 'android',
'reason': reasonType.toString(),
'rpid': item.rpid.toString(),
'reason': reasonType,
'rpid': item.rpid,
'scene': 'main',
'type': '1',
'type': 1,
if (reasonType == 0) 'content': reasonDesc!
},
options: Options(contentType: Headers.formUrlEncodedContentType));
options: Options(contentType: Headers.formUrlEncodedContentType),
);
if (res.data['code'] == 0) {
onDelete?.call(item.rpid);
}
return res.data as Map;
});
},
);
break;
case 'copyAll':
Get.back();

View File

@@ -1069,7 +1069,7 @@ class ReplyItemGrpc extends StatelessWidget {
Widget morePanel({
required BuildContext context,
required dynamic item,
required ReplyInfo item,
required onDelete,
}) {
Future<dynamic> menuActionHandler(String type) async {
@@ -1077,25 +1077,33 @@ class ReplyItemGrpc extends StatelessWidget {
switch (type) {
case 'report':
Get.back();
autoWrapReportDialog(context, ReportOptions.commentReport,
autoWrapReportDialog(
context,
ReportOptions.commentReport,
(reasonType, reasonDesc, banUid) async {
final res = await Request().post('/x/v2/reply/report',
final res = await Request().post(
'/x/v2/reply/report',
data: {
'add_blacklist': banUid.toString(),
'add_blacklist': banUid,
'csrf': await Request.getCsrf(),
'gaia_source': 'main_h5',
'oid': item.oid.toString(),
'oid': item.oid,
'platform': 'android',
'reason': reasonType.toString(),
'rpid': item.id.toString(),
'reason': reasonType,
'rpid': item.id,
'scene': 'main',
'type': '1',
'type': 1,
if (reasonType == 0) 'content': reasonDesc!
},
options:
Options(contentType: Headers.formUrlEncodedContentType));
Options(contentType: Headers.formUrlEncodedContentType),
);
if (res.data['code'] == 0) {
onDelete?.call(item.id.toInt());
}
return res.data as Map;
});
},
);
break;
case 'copyAll':
Get.back();

View File

@@ -327,7 +327,7 @@ class Utils {
builder: (context) => Column(
children: List.generate(list.length, (index) {
return radioWidget(
paddingStart: 14,
padding: const EdgeInsets.only(left: 14),
title: list[index].title ?? '',
groupValue: checkedId,
value: list[index].id,