Skip to content

Commit 5f14471

Browse files
Miihagithub-actions[bot]
authored andcommitted
Run swift-format
1 parent aeaa026 commit 5f14471

File tree

7 files changed

+255
-239
lines changed

7 files changed

+255
-239
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package(
1818
)
1919
],
2020
dependencies: [
21-
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.6.0"),
21+
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.6.0")
2222
],
2323
targets: [
2424
.target(

Sources/ComposableUserNotifications/Interface.swift

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,70 @@ public struct UserNotificationClient {
2323
case openSettingsForNotification(_ notification: Notification?)
2424
}
2525

26-
public var add: @Sendable (UNNotificationRequest) async throws -> Void =
27-
unimplemented("\(Self.self).add")
26+
public var add: @Sendable (UNNotificationRequest) async throws -> Void =
27+
unimplemented("\(Self.self).add")
2828

29-
#if !os(tvOS)
30-
public var deliveredNotifications: @Sendable () async -> [Notification] = unimplemented("\(Self.self).deliveredNotifications")
31-
#endif
29+
#if !os(tvOS)
30+
public var deliveredNotifications: @Sendable () async -> [Notification] = unimplemented(
31+
"\(Self.self).deliveredNotifications")
32+
#endif
3233

33-
#if !os(tvOS)
34-
public var notificationCategories: () async -> Set<UNNotificationCategory> = unimplemented("\(Self.self).deliveredNotifications")
35-
#endif
34+
#if !os(tvOS)
35+
public var notificationCategories: () async -> Set<UNNotificationCategory> = unimplemented(
36+
"\(Self.self).deliveredNotifications")
37+
#endif
3638

37-
public var notificationSettings: () async -> Notification.Settings = unimplemented("\(Self.self).notificationSettings")
39+
public var notificationSettings: () async -> Notification.Settings = unimplemented(
40+
"\(Self.self).notificationSettings")
3841

39-
public var pendingNotificationRequests: () async -> [Notification.Request] = unimplemented("\(Self.self).pendingNotificationRequests")
42+
public var pendingNotificationRequests: () async -> [Notification.Request] = unimplemented(
43+
"\(Self.self).pendingNotificationRequests")
4044

41-
#if !os(tvOS)
42-
public var removeAllDeliveredNotifications: () async -> Void = unimplemented("\(Self.self).removeAllDeliveredNotifications")
43-
#endif
45+
#if !os(tvOS)
46+
public var removeAllDeliveredNotifications: () async -> Void = unimplemented(
47+
"\(Self.self).removeAllDeliveredNotifications")
48+
#endif
4449

45-
public var removeAllPendingNotificationRequests: () async -> Void = unimplemented("\(Self.self).removeAllPendingNotificationRequests")
50+
public var removeAllPendingNotificationRequests: () async -> Void = unimplemented(
51+
"\(Self.self).removeAllPendingNotificationRequests")
4652

47-
#if !os(tvOS)
48-
public var removeDeliveredNotificationsWithIdentifiers: ([String]) async -> Void = unimplemented("\(Self.self).removeDeliveredNotificationsWithIdentifiers")
49-
#endif
53+
#if !os(tvOS)
54+
public var removeDeliveredNotificationsWithIdentifiers: ([String]) async -> Void =
55+
unimplemented("\(Self.self).removeDeliveredNotificationsWithIdentifiers")
56+
#endif
5057

51-
public var removePendingNotificationRequestsWithIdentifiers: ([String]) async -> Void = unimplemented("\(Self.self).removePendingNotificationRequestsWithIdentifiers")
58+
public var removePendingNotificationRequestsWithIdentifiers: ([String]) async -> Void =
59+
unimplemented("\(Self.self).removePendingNotificationRequestsWithIdentifiers")
5260

5361
public var requestAuthorization: (UNAuthorizationOptions) async throws -> Bool =
54-
unimplemented("\(Self.self).requestAuthorization")
62+
unimplemented("\(Self.self).requestAuthorization")
5563

56-
#if !os(tvOS)
57-
public var setNotificationCategories: (Set<UNNotificationCategory>) async -> Void = unimplemented("\(Self.self).setNotificationCategories")
58-
#endif
64+
#if !os(tvOS)
65+
public var setNotificationCategories: (Set<UNNotificationCategory>) async -> Void =
66+
unimplemented("\(Self.self).setNotificationCategories")
67+
#endif
5968

60-
public var supportsContentExtensions: () -> Bool = unimplemented("\(Self.self).supportsContentExtensions")
69+
public var supportsContentExtensions: () -> Bool = unimplemented(
70+
"\(Self.self).supportsContentExtensions")
6171

6272
/// This Effect represents calls to the `UNUserNotificationCenterDelegate`.
6373
/// Handling the completion handlers of the `UNUserNotificationCenterDelegate`s methods
6474
/// by multiple observers might lead to unexpected behaviour.
65-
public var delegate: @Sendable () -> AsyncStream<DelegateAction> = unimplemented("\(Self.self).delegate", placeholder: .finished)
75+
public var delegate: @Sendable () -> AsyncStream<DelegateAction> = unimplemented(
76+
"\(Self.self).delegate", placeholder: .finished)
6677
}
6778

6879
extension UserNotificationClient.DelegateAction: Equatable {
69-
public static func == (lhs: UserNotificationClient.DelegateAction, rhs: UserNotificationClient.DelegateAction) -> Bool {
80+
public static func == (
81+
lhs: UserNotificationClient.DelegateAction, rhs: UserNotificationClient.DelegateAction
82+
) -> Bool {
7083
switch (lhs, rhs) {
7184
case let (.willPresentNotification(lhs, _), .willPresentNotification(rhs, _)):
7285
return lhs == rhs
73-
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
74-
case let (.didReceiveResponse(lhs, _), .didReceiveResponse(rhs, _)):
75-
return lhs == rhs
76-
#endif
86+
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
87+
case let (.didReceiveResponse(lhs, _), .didReceiveResponse(rhs, _)):
88+
return lhs == rhs
89+
#endif
7790
case let (.openSettingsForNotification(lhs), .openSettingsForNotification(rhs)):
7891
return lhs == rhs
7992
default:
Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Foundation
21
import Dependencies
2+
import Foundation
33
import UserNotifications
44

55
extension UserNotificationClient: DependencyKey {
@@ -9,44 +9,44 @@ extension UserNotificationClient: DependencyKey {
99
var client = UserNotificationClient()
1010
client.add = { try await UNUserNotificationCenter.current().add($0) }
1111

12-
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
13-
client.deliveredNotifications = {
14-
let notifications = await center.deliveredNotifications()
15-
return notifications.map(Notification.init(rawValue:))
16-
}
17-
#endif
12+
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
13+
client.deliveredNotifications = {
14+
let notifications = await center.deliveredNotifications()
15+
return notifications.map(Notification.init(rawValue:))
16+
}
17+
#endif
1818

1919
client.notificationSettings = {
2020
let settings = await center.notificationSettings()
2121
return Notification.Settings(rawValue: settings)
2222
}
2323

24-
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
25-
client.notificationCategories = {
26-
await center.notificationCategories()
27-
}
28-
#endif
24+
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
25+
client.notificationCategories = {
26+
await center.notificationCategories()
27+
}
28+
#endif
2929

3030
client.pendingNotificationRequests = {
3131
let requests = await center.pendingNotificationRequests()
3232
return requests.map(Notification.Request.init(rawValue:))
3333
}
3434

35-
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
36-
client.removeAllDeliveredNotifications = {
37-
center.removeAllDeliveredNotifications()
38-
}
39-
#endif
35+
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
36+
client.removeAllDeliveredNotifications = {
37+
center.removeAllDeliveredNotifications()
38+
}
39+
#endif
4040

4141
client.removeAllPendingNotificationRequests = {
4242
center.removeAllPendingNotificationRequests()
4343
}
4444

45-
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
46-
client.removeDeliveredNotificationsWithIdentifiers = {
47-
center.removeDeliveredNotifications(withIdentifiers: $0)
48-
}
49-
#endif
45+
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
46+
client.removeDeliveredNotificationsWithIdentifiers = {
47+
center.removeDeliveredNotifications(withIdentifiers: $0)
48+
}
49+
#endif
5050

5151
client.removePendingNotificationRequestsWithIdentifiers = {
5252
center.removePendingNotificationRequests(withIdentifiers: $0)
@@ -56,11 +56,11 @@ extension UserNotificationClient: DependencyKey {
5656
try await center.requestAuthorization(options: $0)
5757
}
5858

59-
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
60-
client.setNotificationCategories = {
61-
center.setNotificationCategories($0)
62-
}
63-
#endif
59+
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
60+
client.setNotificationCategories = {
61+
center.setNotificationCategories($0)
62+
}
63+
#endif
6464

6565
client.supportsContentExtensions = {
6666
center.supportsContentExtensions
@@ -80,8 +80,8 @@ extension UserNotificationClient: DependencyKey {
8080
}
8181
}
8282

83-
private extension UserNotificationClient {
84-
class Delegate: NSObject, UNUserNotificationCenterDelegate {
83+
extension UserNotificationClient {
84+
fileprivate class Delegate: NSObject, UNUserNotificationCenterDelegate {
8585
let continuation: AsyncStream<UserNotificationClient.DelegateAction>.Continuation
8686

8787
init(continuation: AsyncStream<UserNotificationClient.DelegateAction>.Continuation) {
@@ -92,7 +92,7 @@ private extension UserNotificationClient {
9292
_ center: UNUserNotificationCenter,
9393
willPresent notification: UNNotification,
9494
withCompletionHandler completionHandler:
95-
@escaping (UNNotificationPresentationOptions) -> Void
95+
@escaping (UNNotificationPresentationOptions) -> Void
9696
) {
9797
self.continuation.yield(
9898
.willPresentNotification(
@@ -102,29 +102,29 @@ private extension UserNotificationClient {
102102
)
103103
}
104104

105-
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
106-
func userNotificationCenter(
107-
_ center: UNUserNotificationCenter,
108-
didReceive response: UNNotificationResponse,
109-
withCompletionHandler completionHandler: @escaping () -> Void
110-
) {
111-
let wrappedResponse = Notification.Response(rawValue: response)
112-
self.continuation.yield(
113-
.didReceiveResponse(wrappedResponse) { completionHandler() }
114-
)
115-
}
116-
#endif
117-
118-
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst)
119-
func userNotificationCenter(
120-
_ center: UNUserNotificationCenter,
121-
openSettingsFor notification: UNNotification?
122-
) {
123-
let mappedNotification = notification.map(Notification.init)
124-
self.continuation.yield(
125-
.openSettingsForNotification(mappedNotification)
126-
)
127-
}
128-
#endif
105+
#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst)
106+
func userNotificationCenter(
107+
_ center: UNUserNotificationCenter,
108+
didReceive response: UNNotificationResponse,
109+
withCompletionHandler completionHandler: @escaping () -> Void
110+
) {
111+
let wrappedResponse = Notification.Response(rawValue: response)
112+
self.continuation.yield(
113+
.didReceiveResponse(wrappedResponse) { completionHandler() }
114+
)
115+
}
116+
#endif
117+
118+
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst)
119+
func userNotificationCenter(
120+
_ center: UNUserNotificationCenter,
121+
openSettingsFor notification: UNNotification?
122+
) {
123+
let mappedNotification = notification.map(Notification.init)
124+
self.continuation.yield(
125+
.openSettingsForNotification(mappedNotification)
126+
)
127+
}
128+
#endif
129129
}
130130
}

0 commit comments

Comments
 (0)