Skip to content

Commit

Permalink
Merge pull request #2258 from onevcat/v8
Browse files Browse the repository at this point in the history
Kingfisher version 8
  • Loading branch information
onevcat authored Jun 11, 2024
2 parents 7e1d2c0 + 7856e0f commit ccb87f9
Show file tree
Hide file tree
Showing 156 changed files with 8,508 additions and 4,300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import UIKit
import Kingfisher

protocol MainDataViewReloadable {
func reload()
protocol MainDataViewReloadable: Sendable {
@MainActor func reload()
}

extension UITableViewController: MainDataViewReloadable {
Expand All @@ -44,25 +44,26 @@ extension UICollectionViewController: MainDataViewReloadable {
}

protocol KingfisherActionAlertPopup {
@MainActor
func alertPopup(_ sender: Any) -> UIAlertController
}

func cleanCacheAction() -> UIAlertAction {
@MainActor func cleanCacheAction() -> UIAlertAction {
return UIAlertAction(title: "Clean Cache", style: .default) { _ in
KingfisherManager.shared.cache.clearMemoryCache()
KingfisherManager.shared.cache.clearDiskCache()
}
}

func reloadAction(_ reloadable: MainDataViewReloadable) -> UIAlertAction {
@MainActor func reloadAction(_ reloadable: MainDataViewReloadable) -> UIAlertAction {
return UIAlertAction(title: "Reload", style: .default) { _ in
reloadable.reload()
}
}

let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
@MainActor let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)

func createAlert(_ sender: Any, actions: [UIAlertAction]) -> UIAlertController {
@MainActor func createAlert(_ sender: Any, actions: [UIAlertAction]) -> UIAlertController {
let alert = UIAlertController(title: "Action", message: nil, preferredStyle: .actionSheet)
alert.popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem
alert.popoverPresentationController?.permittedArrowDirections = .any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ class IndicatorCollectionViewController: UICollectionViewController {
func startAnimatingView() {
view.isHidden = false
timer = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: true) { _ in
UIView.animate(withDuration: 0.2, animations: {
if self.view.backgroundColor == .red {
self.view.backgroundColor = .orange
} else {
self.view.backgroundColor = .red
}
})
Task { @MainActor in
UIView.animate(withDuration: 0.2, animations: {
if self.view.backgroundColor == .red {
self.view.backgroundColor = .orange
} else {
self.view.backgroundColor = .red
}
})
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ProgressiveJPEGViewController: UIViewController {
processorIdentifier: self.processor.identifier,
callbackQueue: .mainAsync,
completionHandler: {
self.loadImage()
Task { @MainActor in self.loadImage() }
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ class TextAttachmentViewController: UIViewController {
attributedText.replaceCharacters(in: NSRange(), with: NSAttributedString(attachment: textAttachment))
label.attributedText = attributedText

let label = getLabel()
KF.url(URL(string: "https://onevcat.com/assets/images/avatar.jpg")!)
.resizing(referenceSize: CGSize(width: 30, height: 30))
.roundCorner(radius: .point(15))
.set(to: textAttachment, attributedView: self.getLabel())
.set(to: textAttachment, attributedView: label)
}

func getLabel() -> UILabel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import WatchKit
import Foundation
import Kingfisher

var count = 0
@MainActor var count = 0

class InterfaceController: WKInterfaceController {

Expand All @@ -48,9 +48,9 @@ class InterfaceController: WKInterfaceController {
func refreshImage() {
let url = URL(string: "https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/kingfisher-\(currentIndex! + 1).jpg")!
print("Start loading... \(url)")
interfaceImage.kf.setImage(with: url) { r in
interfaceImage.kf.setImage(with: url, completionHandler: { r in
print(r)
}
})
}

override func willActivate() {
Expand Down
Loading

0 comments on commit ccb87f9

Please sign in to comment.