Skip to content

Commit

Permalink
style(flutter, lint): commit auto-formatting result, repair CI format…
Browse files Browse the repository at this point in the history
…ting check
  • Loading branch information
mikehardy committed Dec 13, 2023
1 parent 30b3479 commit ab4c988
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 47 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/flutter_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ 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
}

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) {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down

0 comments on commit ab4c988

Please sign in to comment.