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