Skip to content

Commit

Permalink
Merge pull request #21 from Iconica-Development/1.4.0
Browse files Browse the repository at this point in the history
fix: resolve several issues
  • Loading branch information
Gorter-dev authored May 29, 2024
2 parents 8aa34cf + a46a1d9 commit 03d4305
Show file tree
Hide file tree
Showing 31 changed files with 589 additions and 536 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

updates:
- package-ecosystem: "pub"
directory: "/packages/flutter_notification_center"
schedule:
interval: "weekly"

- package-ecosystem: "pub"
directory: "/packages/flutter_notification_center_firebase"
schedule:
interval: "weekly"

- package-ecosystem: "pub"
directory: "/packages/flutter_notification_center/example"
schedule:
interval: "weekly"
14 changes: 14 additions & 0 deletions .github/workflows/document-component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Iconica Standard Component Documentation Workflow
# Workflow Caller version: 1.0.0

on:
release:
types: [published]

workflow_dispatch:

jobs:
call-iconica-component-documentation-workflow:
uses: Iconica-Development/.github/.github/workflows/component-documentation.yml@master
secrets: inherit
permissions: write-all
14 changes: 14 additions & 0 deletions .github/workflows/melos-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Iconica Standard Melos CI Workflow
# Workflow Caller version: 1.0.0

on:
pull_request:
workflow_dispatch:

jobs:
call-global-iconica-workflow:
uses: Iconica-Development/.github/.github/workflows/melos-ci.yml@master
secrets: inherit
permissions: write-all
with:
subfolder: '.' # add optional subfolder to run workflow in
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [1.4.0] - 29 May 2024

* Make notifications user bound and not app bound (https://github.com/Iconica-Development/flutter_notification_center/issues/8)
* Fix indicator amount of bell icon (https://github.com/Iconica-Development/flutter_notification_center/issues/10)
* Add unpin functionality (https://github.com/Iconica-Development/flutter_notification_center/issues/15)
* Change color of bin icon (https://github.com/Iconica-Development/flutter_notification_center/issues/19)
* Fix multiple dialog and snackbars stacking on top
* Fix notification center updating when new notifications come in and the screen is open
* Fix sorting of all notifications
* Fix pinned notifications should remain on top

## [1.3.1] - 30 April 2024

* Fix Animationcontroller not disposing correctly.
Expand Down
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright (c) 2024 Iconica, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9 changes: 0 additions & 9 deletions analysis_options.yaml

This file was deleted.

39 changes: 39 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: flutter_notification_center

packages:
- packages/**

command:
version:
branch: master

scripts:
lint:all:
run: dart run melos run analyze && dart run melos run format-check
description: Run all static analysis checks.

get:
run: |
melos exec -c 1 -- "flutter pub get"
melos exec --scope="*example*" -c 1 -- "flutter pub get"
upgrade:
run: melos exec -c 1 -- "flutter pub upgrade"

create:
# run create in the example folder of flutter_chat_view
run: melos exec --scope="*example*" -c 1 -- "flutter create ."

analyze:
run: |
dart run melos exec -c 1 -- \
flutter analyze --fatal-infos
description: Run `flutter analyze` for all packages.

format:
run: dart run melos exec dart format .
description: Run `dart format` for all packages.

format-check:
run: dart run melos exec dart format . --set-exit-if-changed
description: Run `dart format` checks for all packages.
2 changes: 1 addition & 1 deletion packages/flutter_notification_center/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ app.*.map.json
lib/config/
pubspec.lock
dotenv

firebase_options.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_notification_center/flutter_notification_center.dart';
import 'package:flutter_notification_center_firebase/flutter_notification_center_firebase.dart';
Expand All @@ -22,33 +24,62 @@ class CustomNotificationWidget extends StatelessWidget {
Widget build(BuildContext context) {
return notification.isPinned
//Pinned notification
? GestureDetector(
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,
),
),
],
? Dismissible(
key: Key('${notification.id}_pinned'),
onDismissed: (direction) async {
await unPinNotification(notificationService, notification,
notificationTranslations, context);
},
background: Container(
color: const Color.fromRGBO(59, 213, 111, 1),
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Icon(
Icons.push_pin,
color: Colors.white,
),
),
trailing: IconButton(
icon: const Icon(Icons.push_pin),
color: style.pinnedIconColor,
onPressed: () async =>
_navigateToNotificationDetail(context, notification),
padding: const EdgeInsets.only(left: 60.0),
),
secondaryBackground: Container(
color: const Color.fromRGBO(59, 213, 111, 1),
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Icon(
Icons.push_pin,
color: Colors.white,
),
),
),
child: GestureDetector(
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),
),
),
),
)
Expand All @@ -57,10 +88,11 @@ class CustomNotificationWidget extends StatelessWidget {
key: Key(notification.id),
onDismissed: (direction) async {
if (direction == DismissDirection.endToStart) {
await dismissNotification(notificationService, notification);
await dismissNotification(notificationService, notification,
notificationTranslations, context);
} else if (direction == DismissDirection.startToEnd) {
await pinNotification(
notificationService, notification, context);
await pinNotification(notificationService, notification,
notificationTranslations, context);
}
},
background: Container(
Expand All @@ -81,7 +113,7 @@ class CustomNotificationWidget extends StatelessWidget {
padding: EdgeInsets.only(right: 16.0),
child: Icon(
Icons.delete,
color: Colors.white,
color: Colors.black,
),
),
),
Expand Down Expand Up @@ -130,7 +162,7 @@ class CustomNotificationWidget extends StatelessWidget {
BuildContext context,
NotificationModel notification,
) async {
await markNotificationAsRead(notificationService, notification);
unawaited(markNotificationAsRead(notificationService, notification));
if (context.mounted) {
await Navigator.push(
context,
Expand All @@ -144,25 +176,4 @@ class CustomNotificationWidget extends StatelessWidget {
);
}
}

Future<void> dismissNotification(
FirebaseNotificationService notificationService,
NotificationModel notification,
) async {
await notificationService.dismissActiveNotification(notification);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Notification dismissed"),
),
);
}
}

Future<void> markNotificationAsRead(
FirebaseNotificationService notificationService,
NotificationModel notification,
) async {
await notificationService.markNotificationAsRead(notification);
}
}
29 changes: 13 additions & 16 deletions packages/flutter_notification_center/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:example/custom_notification.dart';
// import 'package:firebase_auth/firebase_auth.dart';
// import 'package:example/firebase_options.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:firebase_core/firebase_core.dart';
// import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_notification_center_firebase/flutter_notification_center_firebase.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:flutter_notification_center/flutter_notification_center.dart';
Expand All @@ -21,14 +22,9 @@ void main() async {
}

Future<void> _configureApp() async {
try {
await dotenv.load(fileName: 'dotenv');
} catch (e) {
debugPrint('Failed to load dotenv file: $e');
}
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// await Firebase.initializeApp(
// options: DefaultFirebaseOptions.currentPlatform,
// );
await SystemChrome.setPreferredOrientations(
[
DeviceOrientation.portraitDown,
Expand All @@ -55,14 +51,15 @@ class _NotificationCenterDemoState extends State<NotificationCenterDemo> {
@override
void initState() {
super.initState();
var service =
FirebaseNotificationService(newNotificationCallback: (notification) {
popupHandler.handleNotificationPopup(notification);
});
var service = FirebaseNotificationService(
newNotificationCallback: (notification) {
popupHandler.handleNotificationPopup(notification);
},
);
config = NotificationConfig(
service: service,
enableNotificationPopups: true,
showAsSnackBar: false,
showAsSnackBar: true,
notificationWidgetBuilder: (notification, context) =>
CustomNotificationWidget(
notification: notification,
Expand All @@ -82,7 +79,7 @@ class _NotificationCenterDemoState extends State<NotificationCenterDemo> {
showNotificationIcon: true,
),
notificationService: service,
notificationTranslations: const NotificationTranslations(),
notificationTranslations: const NotificationTranslations.empty(),
context: context,
),
seperateNotificationsWithDivider: true,
Expand Down
21 changes: 6 additions & 15 deletions packages/flutter_notification_center/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@ dependencies:
sdk: flutter
intl: ^0.17.0

flutter_animated_widgets:
git:
url: https://github.com/Iconica-Development/flutter_animated_widgets
ref: 0.0.1
cloud_firestore: ^4.16.1

flutter_dotenv: ^5.0.2
firebase_auth: ^4.2.6
firebase_core: ^2.5.0
firebase_storage: ^11.0.14

flutter_notification_center:
git:
url: https://github.com/Iconica-Development/flutter_notification_center
ref: 1.3.0
ref: 1.4.0
path: packages/flutter_notification_center

flutter_notification_center_firebase:
path: ../../flutter_notification_center_firebase
git:
url: https://github.com/Iconica-Development/flutter_notification_center
ref: 1.4.0
path: packages/flutter_notification_center_firebase



Expand All @@ -46,6 +39,4 @@ dev_dependencies:
# The following section is specific to Flutter packages.
flutter:
uses-material-design: true
assets:
- dotenv

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NotificationConfig {
const NotificationConfig({
required this.service,
this.seperateNotificationsWithDivider = true,
this.translations = const NotificationTranslations(),
this.translations = const NotificationTranslations.empty(),
this.notificationWidgetBuilder,
this.showAsSnackBar = true,
this.enableNotificationPopups = true,
Expand Down
Loading

0 comments on commit 03d4305

Please sign in to comment.