From 7cc2d0e4be03570c51f1cb63c672752b9fd25326 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Wed, 30 Aug 2023 20:46:38 +0200 Subject: [PATCH] chore(repo): Fix linter issues --- example/lib/main.dart | 36 +++++++++++++++++++--------- pigeons/api.dart | 56 +++++++++++++++++++++++++++++++++++++++---- pubspec.yaml | 1 + 3 files changed, 77 insertions(+), 16 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index a3fd3eb..ff07511 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -41,17 +41,27 @@ class MyAppState extends State { Future initStateAsync() async { await Permission.notification.request(); - await MoxplatformPlugin.notifications.createNotificationChannel( - "Test notification channel", - "Test1", - channelId, - false, - ); - await MoxplatformPlugin.notifications.createNotificationChannel( - "Test notification channel for warnings", - "Test2", - otherChannelId, - false, + await MoxplatformPlugin.notifications.createNotificationChannels( + [ + NotificationChannel( + id: channelId, + title: "Test1", + description: "Test notification channel", + importance: NotificationChannelImportance.MIN, + showBadge: true, + vibration: false, + enableLights: false, + ), + NotificationChannel( + id: otherChannelId, + title: "Test2", + description: "Test notification channel for warnings", + importance: NotificationChannelImportance.MIN, + showBadge: true, + vibration: false, + enableLights: false, + ), + ], ); await MoxplatformPlugin.notifications.setI18n( NotificationI18nData( @@ -303,9 +313,11 @@ class MyHomePageState extends State { } final internalPath = join(mediaPath, basename(path)); + // ignore: avoid_print print('Copying file'); await File(path).copy(internalPath); + // ignore: avoid_print print('Generating thumbnail'); final thumbResult = await MoxplatformPlugin.platform.generateVideoThumbnail( @@ -313,8 +325,10 @@ class MyHomePageState extends State { '$internalPath.thumbnail.jpg', 720, ); + // ignore: avoid_print print('Success: $thumbResult'); + // ignore: use_build_context_synchronously await showDialog( context: context, builder: (context) => Image.file( diff --git a/pigeons/api.dart b/pigeons/api.dart index a47caec..afe2909 100644 --- a/pigeons/api.dart +++ b/pigeons/api.dart @@ -34,8 +34,12 @@ class NotificationMessage { this.content, this.jid, this.timestamp, - this.avatarPath, - ); + this.avatarPath, { + this.groupId, + }); + + /// The grouping key for the notification. + final String? groupId; /// The sender of the message. final String? sender; @@ -54,7 +58,7 @@ class NotificationMessage { } class MessagingNotification { - const MessagingNotification(this.title, this.id, this.jid, this.messages, this.channelId, this.isGroupchat, this.extra); + const MessagingNotification(this.title, this.id, this.jid, this.messages, this.channelId, this.isGroupchat, this.extra, {this.groupId}); /// The title of the conversation. final String title; @@ -74,6 +78,9 @@ class MessagingNotification { /// Flag indicating whether this notification is from a groupchat or not. final bool isGroupchat; + /// The id for notification grouping. + final String? groupId; + /// Additional data to include. final Map? extra; } @@ -85,7 +92,7 @@ enum NotificationIcon { } class RegularNotification { - const RegularNotification(this.title, this.body, this.channelId, this.id, this.icon); + const RegularNotification(this.title, this.body, this.channelId, this.id, this.icon, {this.groupId}); /// The title of the notification. final String title; @@ -96,6 +103,9 @@ class RegularNotification { /// The id of the channel to show the notification on. final String channelId; + /// The id for notification grouping. + final String? groupId; + /// The id of the notification. final int id; @@ -168,10 +178,46 @@ enum FallbackIconType { notes; } +class NotificationGroup { + const NotificationGroup(this.id, this.description); + final String id; + final String description; +} + +enum NotificationChannelImportance { + MIN, + HIGH, + DEFAULT +} + +class NotificationChannel { + const NotificationChannel( + this.id, + this.title, + this.description, { + this.importance = NotificationChannelImportance.DEFAULT, + this.showBadge = true, + this.groupId, + this.vibration = true, + this.enableLights = true, + }); + final String title; + final String description; + final String id; + final NotificationChannelImportance importance; + final bool showBadge; + final String? groupId; + final bool vibration; + final bool enableLights; +} + @HostApi() abstract class MoxplatformApi { /// Notification APIs - void createNotificationChannel(String title, String description, String id, bool urgent); + void createNotificationGroups(List groups); + void deleteNotificationGroups(List ids); + void createNotificationChannels(List channels); + void deleteNotificationChannels(List ids); void showMessagingNotification(MessagingNotification notification); void showNotification(RegularNotification notification); void dismissNotification(int id); diff --git a/pubspec.yaml b/pubspec.yaml index 9bfc27f..b5c2872 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,3 +5,4 @@ environment: dev_dependencies: melos: ^3.1.1 pigeon: 10.1.4 + very_good_analysis: ^3.0.1