mirror of
https://github.com/metabolist/metatext
synced 2024-12-29 19:21:03 +01:00
33 lines
947 B
Swift
33 lines
947 B
Swift
// Copyright © 2021 Metabolist. All rights reserved.
|
|
|
|
import Foundation
|
|
import Kingfisher
|
|
import ServiceLayer
|
|
|
|
struct ImageCacheConfiguration {
|
|
private let environment: AppEnvironment
|
|
|
|
init(environment: AppEnvironment) {
|
|
self.environment = environment
|
|
}
|
|
}
|
|
|
|
extension ImageCacheConfiguration {
|
|
func configure() throws {
|
|
KingfisherManager.shared.cache = try ImageCache(
|
|
name: Self.name,
|
|
cacheDirectoryURL: Self.directoryURL)
|
|
try KingfisherManager.shared.defaultOptions = [
|
|
.cacheSerializer(ImageCacheSerializer(service: .init(environment: environment)))
|
|
]
|
|
}
|
|
}
|
|
|
|
private extension ImageCacheConfiguration {
|
|
static let name = "Images"
|
|
static let directoryURL = FileManager.default.containerURL(
|
|
forSecurityApplicationGroupIdentifier: AppEnvironment.appGroup)?
|
|
.appendingPathComponent("Library")
|
|
.appendingPathComponent("Caches")
|
|
}
|