Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down
11 changes: 1 addition & 10 deletions WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 0 additions & 48 deletions WordPress/Classes/Utility/Media/MemoryCache+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import UIKit
import WordPressMedia
import AlamofireImage
import WordPressUI

extension MemoryCache {
/// Registers the cache with all the image loading systems used by the app.
func register() {
// WordPressUI
WordPressUI.ImageCache.shared = WordpressUICacheAdapter(cache: .shared)

// AlamofireImage
UIImageView.af.sharedImageDownloader = AlamofireImage.ImageDownloader(
imageCache: AlamofireImageCacheAdapter(cache: .shared)
)
}
}

Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import UIKit

class AnnouncementCell: AnnouncementTableViewCell {

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down