From 0fb44f08ce101b1017cbe985428ad607499524aa Mon Sep 17 00:00:00 2001 From: kean Date: Tue, 24 Dec 2024 13:18:31 -0500 Subject: [PATCH 1/3] Remove remaining AlamofireImage usages from the anouncement cells --- .../WhatsNew/Views/AnnouncementCell.swift | 3 ++- .../Views/DashboardCustomAnnouncementCell.swift | 13 ++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/WordPress/Classes/ViewRelated/WhatsNew/Views/AnnouncementCell.swift b/WordPress/Classes/ViewRelated/WhatsNew/Views/AnnouncementCell.swift index ec80d65d9df4..7be2473e8678 100644 --- a/WordPress/Classes/ViewRelated/WhatsNew/Views/AnnouncementCell.swift +++ b/WordPress/Classes/ViewRelated/WhatsNew/Views/AnnouncementCell.swift @@ -1,3 +1,4 @@ +import UIKit class AnnouncementCell: AnnouncementTableViewCell { @@ -59,7 +60,7 @@ class AnnouncementCell: AnnouncementTableViewCell { } else if let url = URL(string: feature.iconUrl) { - announcementImageView.af.setImage(withURL: url) + announcementImageView.wp.setImage(with: url) } headingLabel.text = feature.title subHeadingLabel.text = feature.subtitle diff --git a/WordPress/Classes/ViewRelated/WhatsNew/Views/DashboardCustomAnnouncementCell.swift b/WordPress/Classes/ViewRelated/WhatsNew/Views/DashboardCustomAnnouncementCell.swift index a42d26e5c286..63d1832e235d 100644 --- a/WordPress/Classes/ViewRelated/WhatsNew/Views/DashboardCustomAnnouncementCell.swift +++ b/WordPress/Classes/ViewRelated/WhatsNew/Views/DashboardCustomAnnouncementCell.swift @@ -65,20 +65,15 @@ class DashboardCustomAnnouncementCell: AnnouncementTableViewCell { func configure(feature: WordPressKit.Feature) { if let url = URL(string: feature.iconUrl) { - announcementImageView.af.setImage(withURL: url, completion: { [weak self] response in - - guard let self, - let width = response.value?.size.width, - let height = response.value?.size.height else { + announcementImageView.wp.setImage(with: url) { [weak self] result in + guard let self, case .success(let image) = result else { return } - - let aspectRatio = width / height - + let aspectRatio = image.size.width / image.size.height NSLayoutConstraint.activate([ self.announcementImageView.widthAnchor.constraint(equalTo: self.announcementImageView.heightAnchor, multiplier: aspectRatio) ]) - }) + } } headingLabel.text = feature.subtitle } From 6493022a8c1f982ef8f28932b5187eabfada6a7e Mon Sep 17 00:00:00 2001 From: kean Date: Tue, 24 Dec 2024 13:19:06 -0500 Subject: [PATCH 2/3] Remove AlamofireImageCacheAdapter --- .../Media/MemoryCache+Extensions.swift | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/WordPress/Classes/Utility/Media/MemoryCache+Extensions.swift b/WordPress/Classes/Utility/Media/MemoryCache+Extensions.swift index 1cbada8b8a06..dc3e2cf3c11e 100644 --- a/WordPress/Classes/Utility/Media/MemoryCache+Extensions.swift +++ b/WordPress/Classes/Utility/Media/MemoryCache+Extensions.swift @@ -1,6 +1,5 @@ import UIKit import WordPressMedia -import AlamofireImage import WordPressUI extension MemoryCache { @@ -8,11 +7,6 @@ extension MemoryCache { func register() { // WordPressUI WordPressUI.ImageCache.shared = WordpressUICacheAdapter(cache: .shared) - - // AlamofireImage - UIImageView.af.sharedImageDownloader = AlamofireImage.ImageDownloader( - imageCache: AlamofireImageCacheAdapter(cache: .shared) - ) } } @@ -27,45 +21,3 @@ private struct WordpressUICacheAdapter: WordPressUI.ImageCaching { cache.getImage(forKey: key) } } - -private struct AlamofireImageCacheAdapter: AlamofireImage.ImageRequestCache { - let cache: MemoryCache - - func image(for request: URLRequest, withIdentifier identifier: String?) -> AlamofireImage.Image? { - image(withIdentifier: cacheKey(for: request, identifier: identifier)) - } - - func add(_ image: AlamofireImage.Image, for request: URLRequest, withIdentifier identifier: String?) { - add(image, withIdentifier: cacheKey(for: request, identifier: identifier)) - } - - func removeImage(for request: URLRequest, withIdentifier identifier: String?) -> Bool { - removeImage(withIdentifier: cacheKey(for: request, identifier: identifier)) - } - - func image(withIdentifier identifier: String) -> AlamofireImage.Image? { - cache.getImage(forKey: identifier) - } - - func add(_ image: AlamofireImage.Image, withIdentifier identifier: String) { - cache.setImage(image, forKey: identifier) - } - - func removeImage(withIdentifier identifier: String) -> Bool { - cache.removeImage(forKey: identifier) - return true - } - - func removeAllImages() -> Bool { - // Do nothing (the app decides when to remove images) - return true - } - - private func cacheKey(for request: URLRequest, identifier: String?) -> String { - var key = request.url?.absoluteString ?? "" - if let identifier { - key += "-\(identifier)" - } - return key - } -} From 53f578dbcf55a58fd28eb4798d852fb0206f779e Mon Sep 17 00:00:00 2001 From: kean Date: Tue, 24 Dec 2024 13:20:28 -0500 Subject: [PATCH 3/3] Remove AlamofireImage --- Modules/Package.swift | 2 -- .../xcshareddata/swiftpm/Package.resolved | 11 +---------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Modules/Package.swift b/Modules/Package.swift index 784600c6d15e..8c475f26cfd0 100644 --- a/Modules/Package.swift +++ b/Modules/Package.swift @@ -18,7 +18,6 @@ let package = Package( dependencies: [ .package(url: "https://github.com/airbnb/lottie-ios", from: "4.4.0"), .package(url: "https://github.com/Alamofire/Alamofire", from: "5.9.1"), - .package(url: "https://github.com/Alamofire/AlamofireImage", from: "4.3.0"), .package(url: "https://github.com/AliSoftware/OHHTTPStubs", from: "9.1.0"), .package(url: "https://github.com/Automattic/Automattic-Tracks-iOS", from: "3.4.2"), .package(url: "https://github.com/Automattic/AutomatticAbout-swift", from: "1.1.4"), @@ -146,7 +145,6 @@ enum XcodeSupport { "WordPressMedia", "WordPressUI", .product(name: "Alamofire", package: "Alamofire"), - .product(name: "AlamofireImage", package: "AlamofireImage"), .product(name: "AutomatticAbout", package: "AutomatticAbout-swift"), .product(name: "AutomatticTracks", package: "Automattic-Tracks-iOS"), .product(name: "CocoaLumberjack", package: "CocoaLumberjack"), diff --git a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4888e01b33f6..e3f213f8d1e8 100644 --- a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "e67326cf4e0b967f85976c160b6e3742a401276eabf3e18b25fce8bb219e1350", + "originHash" : "2325eaeb036deffbb1d475c9c1b62fef474fe61fdbea5d4335dd314f4bd5cab6", "pins" : [ { "identity" : "alamofire", @@ -10,15 +10,6 @@ "version" : "5.9.1" } }, - { - "identity" : "alamofireimage", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Alamofire/AlamofireImage", - "state" : { - "revision" : "1eaf3b6c6882bed10f6e7b119665599dd2329aa1", - "version" : "4.3.0" - } - }, { "identity" : "automattic-tracks-ios", "kind" : "remoteSourceControl",