From ab4c988edb1283bf13c71133702b3c6963ee8234 Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Wed, 13 Dec 2023 09:43:58 -0500 Subject: [PATCH] style(flutter, lint): commit auto-formatting result, repair CI formatting check --- .github/workflows/flutter_checks.yml | 27 ++++------ .../ios/Classes/NotifeePluginSwift.swift | 52 +++++++++---------- .../method_channel_notifee_test.dart | 6 +-- 3 files changed, 38 insertions(+), 47 deletions(-) diff --git a/.github/workflows/flutter_checks.yml b/.github/workflows/flutter_checks.yml index 7aa58ea6..9956b764 100644 --- a/.github/workflows/flutter_checks.yml +++ b/.github/workflows/flutter_checks.yml @@ -48,30 +48,23 @@ jobs: run: | ./.github/workflows/scripts/install-tools.sh curl -sL https://github.com/google/google-java-format/releases/download/google-java-format-1.3/google-java-format-1.3-all-deps.jar -o $HOME/google-java-format.jar + - name: Install native formatters + uses: nick-invision/retry@v2 + with: + timeout_minutes: 10 + retry_wait_seconds: 60 + max_attempts: 3 + command: HOMEBREW_NO_AUTO_UPDATE=1 brew install clang-format swiftformat + - name: "Bootstrap Workspace" run: melos bootstrap working-directory: ./packages/flutter - name: "Dart" run: | - melos exec -c 1 -- \ - "flutter format ." - ../../.github/workflows/scripts/validate-formatting.sh - working-directory: ./packages/flutter - - name: "Objective-C" - if: ${{ success() || failure() }} - run: | - melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" --dir-exists="ios" -- \ - find . -maxdepth 3 -name "*.h" -o -name "*.m" -print0 \| xargs -0 clang-format -i --style=Google --verbose + melos run format ../../.github/workflows/scripts/validate-formatting.sh working-directory: ./packages/flutter - - name: "Java" - if: ${{ success() || failure() }} - run: | - melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" --dir-exists="android" -- \ - find . -maxdepth 12 -name "*.java" -print0 \| xargs -0 java -jar $HOME/google-java-format.jar --replace - ../../.github/workflows/scripts/validate-formatting.sh - working-directory: ./packages/flutter - + test: runs-on: ubuntu-latest timeout-minutes: 30 diff --git a/packages/flutter/packages/notifee/ios/Classes/NotifeePluginSwift.swift b/packages/flutter/packages/notifee/ios/Classes/NotifeePluginSwift.swift index 35bfddc9..1d6e5853 100644 --- a/packages/flutter/packages/notifee/ios/Classes/NotifeePluginSwift.swift +++ b/packages/flutter/packages/notifee/ios/Classes/NotifeePluginSwift.swift @@ -11,7 +11,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { var args = NSDictionary() - init(messenger: FlutterBinaryMessenger, channel: FlutterMethodChannel) { + init(messenger: FlutterBinaryMessenger, channel: FlutterMethodChannel) { self.messenger = messenger self.channel = channel } @@ -19,13 +19,13 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { public func didReceiveNotifeeCoreEvent(_ event: [AnyHashable: Any]) { print(event) - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { - if (UIApplication.shared.applicationState == .background) { - self.channel?.invokeMethod("Notifee#onBackgroundEvent" , arguments: event) - } else { - NotifeePluginSwift.eventSink?(event) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + if UIApplication.shared.applicationState == .background { + self.channel?.invokeMethod("Notifee#onBackgroundEvent", arguments: event) + } else { + NotifeePluginSwift.eventSink?(event) + } } - } } public static func register(with registrar: FlutterPluginRegistrar) { @@ -34,8 +34,6 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { let channel = FlutterMethodChannel(name: kFLTNotifeeChannelName, binaryMessenger: binaryMessenger) let instance = NotifeePluginSwift(messenger: binaryMessenger, channel: channel) - - registrar.addMethodCallDelegate(instance, channel: channel) registrar.publish(instance) @@ -46,7 +44,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { eventChannel.setStreamHandler(NotifeeStreamHandler()) } - internal func displayNotification(arguments: [String: Any], result: @escaping FlutterResult) { + func displayNotification(arguments: [String: Any], result: @escaping FlutterResult) { NotifeeCore.displayNotification(arguments, with: { (error: Error?) in if error != nil { result(error) @@ -56,7 +54,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func createTriggerNotification(arguments: [String: Any], result: @escaping FlutterResult) { + func createTriggerNotification(arguments: [String: Any], result: @escaping FlutterResult) { NotifeeCore.createTriggerNotification(arguments["notification"] as! [String: Any], withTrigger: arguments["trigger"] as! [String: Any], with: { (error: Error?) in if error != nil { result(error) @@ -66,7 +64,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func cancelAllNotifications(arguments: [String: Any], result: @escaping FlutterResult) { + func cancelAllNotifications(arguments: [String: Any], result: @escaping FlutterResult) { NotifeeCore.cancelAllNotifications(arguments["type"] as! Int, with: { (error: Error?) in if error != nil { result(error) @@ -76,7 +74,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func cancelAllNotificationsWithIds(arguments: [String: Any], result: @escaping FlutterResult) { + func cancelAllNotificationsWithIds(arguments: [String: Any], result: @escaping FlutterResult) { NotifeeCore.cancelAllNotifications(withIds: arguments["type"] as! Int, withIds: arguments["ids"] as! [String], with: { (error: Error?) in if error != nil { result(error) @@ -86,7 +84,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func requestPermission(arguments _: [String: Any], result: @escaping FlutterResult) { + func requestPermission(arguments _: [String: Any], result: @escaping FlutterResult) { NotifeeCore.requestPermission(["alert": true, "sound": true, "badge": true], with: { (error: Error?, settings: Any?) in if error != nil { result(error) @@ -96,7 +94,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func getBadgeCount(result: @escaping FlutterResult) { + func getBadgeCount(result: @escaping FlutterResult) { NotifeeCore.getBadgeCount { (error: Error?, count: Any?) in if error != nil { result(error) @@ -106,7 +104,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { } } - internal func getNotificationCategories(result: @escaping FlutterResult) { + func getNotificationCategories(result: @escaping FlutterResult) { NotifeeCore.getNotificationCategories { (error: Error?, categories: Any?) in if error != nil { result(error) @@ -116,7 +114,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { } } - internal func getNotificationSettings(result: @escaping FlutterResult) { + func getNotificationSettings(result: @escaping FlutterResult) { NotifeeCore.getNotificationSettings { (error: Error?, settings: Any?) in if error != nil { result(error) @@ -126,7 +124,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { } } - internal func getTriggerNotificationIds(result: @escaping FlutterResult) { + func getTriggerNotificationIds(result: @escaping FlutterResult) { NotifeeCore.getTriggerNotificationIds { (error: Error?, ids: Any?) in if error != nil { result(error) @@ -136,7 +134,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { } } - internal func getTriggerNotifications(result: @escaping FlutterResult) { + func getTriggerNotifications(result: @escaping FlutterResult) { NotifeeCore.getTriggerNotifications { (error: Error?, notifications: Any?) in if error != nil { result(error) @@ -146,7 +144,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { } } - internal func getDisplayedNotifications(result: @escaping FlutterResult) { + func getDisplayedNotifications(result: @escaping FlutterResult) { NotifeeCore.getDisplayedNotifications { (error: Error?, notifications: Any?) in if error != nil { result(error) @@ -155,8 +153,8 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { } } } - - internal func getInitialNotification(result: @escaping FlutterResult) { + + func getInitialNotification(result: @escaping FlutterResult) { NotifeeCore.getInitialNotification { (error: Error?, notification: Any?) in if error != nil { result(error) @@ -166,7 +164,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { } } - internal func incrementBadgeCount(arguments: Int, result: @escaping FlutterResult) { + func incrementBadgeCount(arguments: Int, result: @escaping FlutterResult) { NotifeeCore.incrementBadgeCount(arguments, with: { (error: Error?) in if error != nil { result(error) @@ -176,7 +174,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func decrementBadgeCount(arguments: Int, result: @escaping FlutterResult) { + func decrementBadgeCount(arguments: Int, result: @escaping FlutterResult) { NotifeeCore.decrementBadgeCount(arguments, with: { (error: Error?) in if error != nil { result(error) @@ -186,7 +184,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func setBadgeCount(arguments: Int, result: @escaping FlutterResult) { + func setBadgeCount(arguments: Int, result: @escaping FlutterResult) { NotifeeCore.setBadgeCount(arguments, with: { (error: Error?) in if error != nil { result(error) @@ -196,7 +194,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { }) } - internal func setNotificationCategories(arguments: [[AnyHashable: Any]], result: @escaping FlutterResult) { + func setNotificationCategories(arguments: [[AnyHashable: Any]], result: @escaping FlutterResult) { NotifeeCore.setNotificationCategories(arguments, with: { (error: Error?) in if error != nil { result(error) @@ -210,7 +208,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate { if call.method == "displayNotification" { displayNotification(arguments: call.arguments as! [String: Any], result: result) } else if call.method == "getInitialNotification" { - getInitialNotification(result: result) + getInitialNotification(result: result) } else if call.method == "createTriggerNotification" { createTriggerNotification(arguments: call.arguments as! [String: Any], result: result) } else if call.method == "cancelAllNotifications" { diff --git a/packages/flutter/packages/notifee_platform_interface/test/method_channel_test/method_channel_notifee_test.dart b/packages/flutter/packages/notifee_platform_interface/test/method_channel_test/method_channel_notifee_test.dart index d32cb275..d5a3002f 100644 --- a/packages/flutter/packages/notifee_platform_interface/test/method_channel_test/method_channel_notifee_test.dart +++ b/packages/flutter/packages/notifee_platform_interface/test/method_channel_test/method_channel_notifee_test.dart @@ -6,15 +6,15 @@ import 'package:flutter_test/flutter_test.dart'; typedef MethodCallCallback = dynamic Function(MethodCall methodCall); void handleMethodCall(MethodCallCallback methodCallCallback) => - TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(MethodChannelNotifee.channel, (call) async { return await methodCallCallback(call); }); void initializeMethodChannel() { TestWidgetsFlutterBinding.ensureInitialized(); - TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler(MethodChannelNotifee.channel, (call) async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelNotifee.channel, (call) async { return null; }); }