1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-28 18:50:21 +01:00
metatext-app-ios-iphone-ipad/Caches/ImageCacheConfiguration.swift
2021-01-29 18:42:25 -08:00

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")
}