瀏覽代碼

Make ImageTransition Sendable

onevcat 1 年之前
父節點
當前提交
86e7bfa17c
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      Sources/Image/ImageTransition.swift

+ 5 - 4
Sources/Image/ImageTransition.swift

@@ -34,7 +34,7 @@ import UIKit
 /// transition. Apple's `UIViewAnimationOptions` are used under the hood.
 ///
 /// For custom transitions, you should specify your own transition options, animations, and completion handler as well.
-public enum ImageTransition {
+public enum ImageTransition: Sendable {
     /// No animation transition.
     case none
     /// Fade effect to the loaded image over a specified duration.
@@ -56,8 +56,8 @@ public enum ImageTransition {
     ///    - completion: A block called when the transition animation finishes.
     case custom(duration: TimeInterval,
                  options: UIView.AnimationOptions,
-              animations: ((UIImageView, UIImage) -> Void)?,
-              completion: ((Bool) -> Void)?)
+              animations: (@Sendable (UIImageView, UIImage) -> Void)?,
+              completion: (@Sendable (Bool) -> Void)?)
     
     var duration: TimeInterval {
         switch self {
@@ -87,6 +87,7 @@ public enum ImageTransition {
         }
     }
     
+    @MainActor
     var animations: ((UIImageView, UIImage) -> Void)? {
         switch self {
         case .custom(_, _, let animations, _): return animations
@@ -103,7 +104,7 @@ public enum ImageTransition {
 }
 #else
 // Just a placeholder for compiling on macOS.
-public enum ImageTransition {
+public enum ImageTransition: Sendable {
     case none
     /// This is a placeholder on macOS now. It is for SwiftUI (KFImage) to identify the fade option only.
     case fade(TimeInterval)