重构
This commit is contained in:
@@ -234,73 +234,4 @@ class _FavoritesPageState extends State<FavoritesPage>
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showFavoriteDetails(BuildContext context, int index, String category) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('$category详情'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('分类: $category'),
|
||||
const SizedBox(height: 8),
|
||||
Text('收藏时间: ${(index + 1) * 2}天前'),
|
||||
const SizedBox(height: 8),
|
||||
const Text('这是收藏内容的详细信息。'),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('关闭'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleFavoriteAction(String action, int index) {
|
||||
switch (action) {
|
||||
case 'share':
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('分享了收藏${index + 1}')));
|
||||
break;
|
||||
case 'edit':
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('编辑了收藏${index + 1}')));
|
||||
break;
|
||||
case 'delete':
|
||||
_showDeleteConfirm(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _showDeleteConfirm(int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('确认删除'),
|
||||
content: Text('确定要删除收藏${index + 1}吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('已删除收藏${index + 1}')));
|
||||
},
|
||||
child: const Text('删除', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user