mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
Can delete all the notifications
This commit is contained in:
parent
8b6e464644
commit
2c1ae783e3
@ -102,4 +102,10 @@ class NotificationsHelper {
|
||||
},
|
||||
).exec())
|
||||
.isOK;
|
||||
|
||||
/// Delete all unread notifications
|
||||
Future<bool> deleteAllNotifications() async =>
|
||||
(await APIRequest(uri: "notifications/delete_all", needLogin: true)
|
||||
.exec())
|
||||
.isOK;
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
|
||||
GroupsList _groups;
|
||||
_Status _status = _Status.LOADING;
|
||||
|
||||
final _refreshKey = GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
void setStatus(_Status s) => setState(() => _status = s);
|
||||
|
||||
Future<void> _loadList() async {
|
||||
@ -77,7 +79,22 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: RefreshIndicator(child: _buildBody(), onRefresh: _loadList),
|
||||
child: Stack(children: [
|
||||
RefreshIndicator(
|
||||
key: _refreshKey,
|
||||
child: _buildBody(),
|
||||
onRefresh: _loadList,
|
||||
),
|
||||
// Add conversation button
|
||||
Positioned(
|
||||
right: 20.0,
|
||||
bottom: 20.0,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () => _deleteAllNotifications(),
|
||||
child: Icon(Icons.delete),
|
||||
),
|
||||
),
|
||||
]),
|
||||
)
|
||||
],
|
||||
);
|
||||
@ -134,6 +151,21 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
|
||||
|
||||
NotificationsHelper().markSeen(notif);
|
||||
}
|
||||
|
||||
/// Delete all the notifications
|
||||
void _deleteAllNotifications() async {
|
||||
if (!await showConfirmDialog(
|
||||
context: context,
|
||||
message: tr("Do you really want to delete all your notifications?")))
|
||||
return;
|
||||
|
||||
if (!await NotificationsHelper().deleteAllNotifications()) {
|
||||
showSimpleSnack(context, tr("Could not delete all your notifications!"));
|
||||
return;
|
||||
}
|
||||
|
||||
_refreshKey.currentState.show();
|
||||
}
|
||||
}
|
||||
|
||||
class _NotificationTile extends StatelessWidget {
|
||||
|
Loading…
Reference in New Issue
Block a user