mirror of
https://github.com/Iconica-Development/flutter_notification_center.git
synced 2025-05-18 16:43:44 +02:00
fix: delete notification bug
This commit is contained in:
parent
91621bde96
commit
b929ff5af9
5 changed files with 7 additions and 33 deletions
|
@ -6,14 +6,12 @@ import 'package:flutter_notification_center_firebase/flutter_notification_center
|
|||
|
||||
class CustomNotificationWidget extends StatelessWidget {
|
||||
final NotificationModel notification;
|
||||
final NotificationStyle style;
|
||||
final FirebaseNotificationService notificationService;
|
||||
final NotificationTranslations notificationTranslations;
|
||||
final BuildContext context;
|
||||
|
||||
const CustomNotificationWidget({
|
||||
required this.notification,
|
||||
required this.style,
|
||||
required this.notificationTranslations,
|
||||
required this.notificationService,
|
||||
required this.context,
|
||||
|
@ -56,26 +54,18 @@ class CustomNotificationWidget extends StatelessWidget {
|
|||
onTap: () async =>
|
||||
_navigateToNotificationDetail(context, notification),
|
||||
child: ListTile(
|
||||
leading: style.showNotificationIcon != null
|
||||
? Icon(
|
||||
notification.icon,
|
||||
color: style.leadingIconColor,
|
||||
)
|
||||
: null,
|
||||
title: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
notification.title,
|
||||
style: style.titleTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.push_pin),
|
||||
color: style.pinnedIconColor,
|
||||
onPressed: () async =>
|
||||
_navigateToNotificationDetail(context, notification),
|
||||
padding: const EdgeInsets.only(left: 60.0),
|
||||
|
@ -147,9 +137,8 @@ class CustomNotificationWidget extends StatelessWidget {
|
|||
margin: const EdgeInsets.only(right: 8.0),
|
||||
width: 12.0,
|
||||
height: 12.0,
|
||||
decoration: BoxDecoration(
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: style.isReadDotColor,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
|
@ -170,7 +159,6 @@ class CustomNotificationWidget extends StatelessWidget {
|
|||
builder: (context) => NotificationDetailPage(
|
||||
translations: notificationTranslations,
|
||||
notification: notification,
|
||||
notificationStyle: style,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -63,21 +63,6 @@ class _NotificationCenterDemoState extends State<NotificationCenterDemo> {
|
|||
notificationWidgetBuilder: (notification, context) =>
|
||||
CustomNotificationWidget(
|
||||
notification: notification,
|
||||
style: const NotificationStyle(
|
||||
appTitleTextStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
),
|
||||
titleTextStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 16,
|
||||
),
|
||||
leadingIconColor: Colors.grey,
|
||||
pinnedIconColor: Colors.grey,
|
||||
isReadDotColor: Colors.red,
|
||||
showNotificationIcon: true,
|
||||
),
|
||||
notificationService: service,
|
||||
notificationTranslations: const NotificationTranslations.empty(),
|
||||
context: context,
|
||||
|
|
|
@ -18,13 +18,13 @@ dependencies:
|
|||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_notification_center
|
||||
path: packages/flutter_notification_center
|
||||
ref: 2.0.0
|
||||
ref: 3.0.0
|
||||
|
||||
flutter_notification_center_firebase:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_notification_center
|
||||
path: packages/flutter_notification_center_firebase
|
||||
ref: 2.0.0
|
||||
ref: 3.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -238,7 +238,7 @@ class FirebaseNotificationService
|
|||
.doc(notificationModel.id);
|
||||
await documentReference.delete();
|
||||
listOfActiveNotifications
|
||||
.removeAt(listOfActiveNotifications.indexOf(notificationModel));
|
||||
.removeWhere((element) => element.id == notificationModel.id);
|
||||
notifyListeners();
|
||||
} on Exception catch (e) {
|
||||
debugPrint("Error deleting document: $e");
|
||||
|
@ -403,6 +403,7 @@ class FirebaseNotificationService
|
|||
.collection(activeNotificationsCollection)
|
||||
.doc(userId)
|
||||
.collection(activeNotificationsCollection)
|
||||
.where("isRead", isEqualTo: false)
|
||||
.snapshots()
|
||||
.map((e) => e.docs.length);
|
||||
yield* amount;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: flutter_notification_center_firebase
|
||||
description: "A new Flutter project."
|
||||
publish_to: "none"
|
||||
version: 2.0.0
|
||||
version: 3.0.0
|
||||
|
||||
environment:
|
||||
sdk: ">=2.18.0 <3.0.0"
|
||||
|
@ -21,7 +21,7 @@ dependencies:
|
|||
flutter_notification_center:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_notification_center
|
||||
ref: 2.0.0
|
||||
ref: 3.0.0
|
||||
path: packages/flutter_notification_center
|
||||
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue