Skip to content

Commit

Permalink
Merge pull request #76 from WeTransfer/feature/notification-style-mai…
Browse files Browse the repository at this point in the history
…n-actor

Make UINotificationStyle conform to main actor
  • Loading branch information
AvdLee authored Jan 25, 2024
2 parents 94735df + 8af57e2 commit dfedd79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/UINotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public protocol UINotificationAction {
}

/// Defines a style which will be applied on the notification view.
@MainActor
public protocol UINotificationStyle: Sendable {
var titleFont: UIFont { get }
var subtitleFont: UIFont { get }
Expand Down Expand Up @@ -103,9 +104,10 @@ public final class UINotification: Equatable, @unchecked Sendable {

weak var delegate: UINotificationDelegate?

public init(content: UINotificationContent, style: UINotificationStyle = UINotificationSystemStyle(), action: UINotificationAction? = nil) {
@MainActor
public init(content: UINotificationContent, style: UINotificationStyle? = nil, action: UINotificationAction? = nil) {
self.notificationContent = content
self.style = style
self.style = style ?? UINotificationSystemStyle()
self.action = action
}

Expand Down
1 change: 1 addition & 0 deletions Tests/UINotificationQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ final class UINotificationQueueTests: UINotificationTestCase {
}

/// When a request is already queued, it should not be added if duplicates are not allowed.
@MainActor
func testDuplicateNotificationRequestsQueue() {
let queue = UINotificationQueue(delegate: MockQueueDelegate())
queue.add(notification, notificationViewType: UINotificationView.self)
Expand Down
1 change: 1 addition & 0 deletions Tests/UINotificationTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import XCTest
@testable import UINotifications

@MainActor
class UINotificationTestCase: XCTestCase {
internal let notification = UINotification(content: UINotificationContent(title: "", subtitle: "", image: nil))

Expand Down

0 comments on commit dfedd79

Please sign in to comment.