mod: 移除黑名单

This commit is contained in:
guozhigq
2023-10-14 16:07:52 +08:00
parent 38a1f2e1f7
commit 8aa02f7450
3 changed files with 45 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/http_error.dart';
@ -60,7 +61,7 @@ class _BlackListPageState extends State<BlackListPage> {
centerTitle: false,
title: Obx(
() => Text(
'黑名单管理 ${_blackListController.blackList.length} / 5000',
'黑名单管理 - ${_blackListController.blackList.length}',
style: Theme.of(context).textTheme.titleMedium,
),
),
@ -104,10 +105,11 @@ class _BlackListPageState extends State<BlackListPage> {
overflow: TextOverflow.ellipsis,
),
dense: true,
// trailing: TextButton(
// onPressed: () {},
// child: const Text('移除'),
// ),
trailing: TextButton(
onPressed: () => _blackListController
.removeBlack(list[index].mid),
child: const Text('移除'),
),
);
},
),
@ -154,4 +156,12 @@ class BlackListController extends GetxController {
}
return result;
}
Future removeBlack(mid) async {
var result = await BlackHttp.removeBlack(fid: mid);
if (result['status']) {
blackList.removeWhere((e) => e.mid == mid);
SmartDialog.showToast(result['msg']);
}
}
}