mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: del msg feed
opt: msg feed Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -40,7 +40,7 @@ class SysMsgController extends CommonController {
|
||||
|
||||
Future onRemove(dynamic id, int index) async {
|
||||
try {
|
||||
var res = await MsgHttp.removeSysMsg(id);
|
||||
var res = await MsgHttp.delSysMsg(id);
|
||||
if (res['status']) {
|
||||
List list = (loadingState.value as Success).response;
|
||||
list.removeAt(index);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -52,7 +53,8 @@ class _SysMsgPageState extends State<SysMsgPage> {
|
||||
_sysMsgController.onLoadMore();
|
||||
}
|
||||
|
||||
String? content = loadingState.response[index].content;
|
||||
final item = loadingState.response[index];
|
||||
String? content = item.content;
|
||||
if (content != null) {
|
||||
try {
|
||||
dynamic jsonContent = json.decode(content);
|
||||
@@ -64,36 +66,16 @@ class _SysMsgPageState extends State<SysMsgPage> {
|
||||
return ListTile(
|
||||
onTap: () {},
|
||||
onLongPress: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('确定删除该通知?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
_sysMsgController.onRemove(
|
||||
loadingState.response[index].id,
|
||||
index,
|
||||
);
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
));
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定删除该通知?',
|
||||
onConfirm: () {
|
||||
_sysMsgController.onRemove(item.id, index);
|
||||
},
|
||||
);
|
||||
},
|
||||
title: Text(
|
||||
"${loadingState.response[index].title}",
|
||||
"${item.title}",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
subtitle: Column(
|
||||
@@ -114,13 +96,14 @@ class _SysMsgPageState extends State<SysMsgPage> {
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"${loadingState.response[index].timeAt}",
|
||||
"${item.timeAt}",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.copyWith(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
textAlign: TextAlign.end,
|
||||
|
||||
Reference in New Issue
Block a user