mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 12:15:31 +00:00
Format code
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
@ -8,17 +7,12 @@ import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/inventree/notification.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class NotificationWidget extends StatefulWidget {
|
||||
|
||||
@override
|
||||
_NotificationState createState() => _NotificationState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
|
||||
_NotificationState() : super();
|
||||
|
||||
List<InvenTreeNotification> notifications = [];
|
||||
@ -29,8 +23,7 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
String getAppBarTitle() => L10().notifications;
|
||||
|
||||
@override
|
||||
Future<void> request (BuildContext context) async {
|
||||
|
||||
Future<void> request(BuildContext context) async {
|
||||
final results = await InvenTreeNotification().list();
|
||||
|
||||
notifications.clear();
|
||||
@ -45,8 +38,8 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
/*
|
||||
* Dismiss an individual notification entry (mark it as "read")
|
||||
*/
|
||||
Future<void> dismissNotification(BuildContext context, InvenTreeNotification notification) async {
|
||||
|
||||
Future<void> dismissNotification(
|
||||
BuildContext context, InvenTreeNotification notification) async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isDismissing = true;
|
||||
@ -71,36 +64,34 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
*/
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().notifications,
|
||||
),
|
||||
subtitle: notifications.isEmpty ? Text(L10().notificationsEmpty) : null,
|
||||
leading: notifications.isEmpty ? Icon(TablerIcons.bell_exclamation) : Icon(TablerIcons.bell),
|
||||
trailing: Text("${notifications.length}"),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(
|
||||
L10().notifications,
|
||||
),
|
||||
subtitle: notifications.isEmpty ? Text(L10().notificationsEmpty) : null,
|
||||
leading: notifications.isEmpty
|
||||
? Icon(TablerIcons.bell_exclamation)
|
||||
: Icon(TablerIcons.bell),
|
||||
trailing: Text("${notifications.length}"),
|
||||
));
|
||||
|
||||
for (var notification in notifications) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(notification.name),
|
||||
subtitle: Text(notification.message),
|
||||
trailing: IconButton(
|
||||
icon: Icon(TablerIcons.bookmark),
|
||||
onPressed: isDismissing ? null : () async {
|
||||
dismissNotification(context, notification);
|
||||
},
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(notification.name),
|
||||
subtitle: Text(notification.message),
|
||||
trailing: IconButton(
|
||||
icon: Icon(TablerIcons.bookmark),
|
||||
onPressed: isDismissing
|
||||
? null
|
||||
: () async {
|
||||
dismissNotification(context, notification);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user