Skip to content

Commit ab3630a

Browse files
committed
feat(bookmark_card): 添加存档操作后的SnackBar反馈并更新图标 #3
在存档按钮点击后显示SnackBar提示操作结果 根据存档状态更新图标样式和提示文字
1 parent 0168262 commit ab3630a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

lib/ui/core/ui/bookmark_card.dart

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,28 @@ class _BookmarkCardState extends State<BookmarkCard> {
177177
// 存档按钮
178178
IconButton(
179179
onPressed: widget.onToggleArchive != null
180-
? () => widget.onToggleArchive!(widget.bookmark)
180+
? () {
181+
widget.onToggleArchive!(widget.bookmark);
182+
ScaffoldMessenger.of(context).showSnackBar(
183+
SnackBar(
184+
content: Text(widget.bookmark.isArchived
185+
? '已取消存档'
186+
: '已标记存档'),
187+
duration: const Duration(seconds: 2),
188+
),
189+
);
190+
}
181191
: null,
182192
icon: Icon(
183-
Icons.archive_outlined,
193+
widget.bookmark.isArchived
194+
? Icons.unarchive_outlined
195+
: Icons.archive_outlined,
184196
size: 20,
185-
color: Colors.grey[600],
197+
color: widget.bookmark.isArchived
198+
? Theme.of(context).colorScheme.primary
199+
: Theme.of(context).colorScheme.onSurfaceVariant,
186200
),
187-
tooltip: '存档',
201+
tooltip: widget.bookmark.isArchived ? '取消存档' : '存档',
188202
padding: EdgeInsets.zero,
189203
constraints: const BoxConstraints(
190204
minWidth: 32,

0 commit comments

Comments
 (0)