Skip to content

Commit 7dad523

Browse files
committed
feat(account): add mark all as read and delete read notifications buttons
- Add mark all as read button with tooltip - Implement delete read notifications button with confirmation dialog - Update button availability based on current notification state
1 parent 5395fe5 commit 7dad523

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

lib/account/view/in_app_notification_center_page.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,60 @@ class _InAppNotificationCenterPageState
6060
InAppNotificationCenterBloc,
6161
InAppNotificationCenterState
6262
>(
63+
builder: (context, state) {
64+
final hasUnread = state.notifications.any((n) => !n.isRead);
65+
return IconButton(
66+
onPressed: hasUnread
67+
? () {
68+
context.read<InAppNotificationCenterBloc>().add(
69+
const InAppNotificationCenterMarkAllAsRead(),
70+
);
71+
}
72+
: null,
73+
icon: const Icon(Icons.done_all),
74+
tooltip: l10n.notificationCenterMarkAllAsReadButton,
75+
);
76+
},
77+
),
78+
BlocBuilder<
79+
InAppNotificationCenterBloc,
80+
InAppNotificationCenterState
81+
>(
82+
builder: (context, state) {
83+
return IconButton(
84+
tooltip: l10n.deleteReadNotificationsButtonTooltip,
85+
icon: const Icon(Icons.delete_sweep_outlined),
86+
onPressed: state.hasReadItemsInCurrentTab
87+
? () async {
88+
final confirmed = await showDialog<bool>(
89+
context: context,
90+
builder: (context) => AlertDialog(
91+
title: Text(l10n.deleteConfirmationDialogTitle),
92+
content:
93+
Text(l10n.deleteReadNotificationsDialogContent),
94+
actions: [
95+
TextButton(
96+
onPressed: () => Navigator.pop(context, false),
97+
child: Text(l10n.cancelButtonLabel),
98+
),
99+
TextButton(
100+
onPressed: () => Navigator.pop(context, true),
101+
child: Text(l10n.deleteButtonLabel),
102+
),
103+
],
104+
),
105+
);
106+
if (confirmed == true && context.mounted) {
107+
context.read<InAppNotificationCenterBloc>().add(
108+
const InAppNotificationCenterReadItemsDeleted(),
109+
);
110+
}
111+
}
112+
: null,
113+
);
114+
},
115+
),
116+
BlocBuilder<InAppNotificationCenterBloc, InAppNotificationCenterState>(
63117
builder: (context, state) {
64118
final hasUnread = state.notifications.any((n) => !n.isRead);
65119
return IconButton(

0 commit comments

Comments
 (0)