1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-18 12:28:35 +01:00
metatext-app-ios-iphone-ipad/Extensions/KingfisherOptionsInfo+Extensions.swift
Justin Mazzocchi 70720b3c26
Sort imports
2020-09-04 19:31:43 -07:00

31 lines
1.1 KiB
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import struct Kingfisher.DownsamplingImageProcessor
import struct Kingfisher.FormatIndicatedCacheSerializer
import protocol Kingfisher.ImageProcessor
import struct Kingfisher.KingfisherOptionsInfo
import struct Kingfisher.RoundCornerImageProcessor
import KingfisherSwiftUI
import SwiftUI
extension KingfisherOptionsInfo {
static func downsampled(size: CGSize, scaleFactor: CGFloat, rounded: Bool = true) -> Self {
var processor: ImageProcessor = DownsamplingImageProcessor(size: size)
if rounded {
processor = processor.append(another: RoundCornerImageProcessor(radius: .widthFraction(0.5)))
}
return [
.processor(processor),
.scaleFactor(scaleFactor),
.cacheOriginalImage,
.cacheSerializer(FormatIndicatedCacheSerializer.png)
]
}
static func downsampled(dimension: CGFloat, scaleFactor: CGFloat, rounded: Bool = true) -> Self {
downsampled(size: CGSize(width: dimension, height: dimension), scaleFactor: scaleFactor, rounded: rounded)
}
}