Replace SVGKit package with CoreSVG

Changelog-Fixed: Fixed crash on some SVG profile pictures
Closes: #416
This commit is contained in:
OlegAba
2023-01-27 16:03:17 -05:00
committed by William Casarin
parent e4beb872a5
commit 0e8c94b668
4 changed files with 116 additions and 38 deletions

View File

@@ -5,9 +5,8 @@
// Created by Oleg Abalonski on 1/11/23.
//
import Foundation
import UIKit
import Kingfisher
import SVGKit
class KFImageModel: ObservableObject {
@@ -80,8 +79,15 @@ struct CustomImageProcessor: ImageProcessor {
}
// Handle SVG image
if let svgImage = SVGKImage(data: data), let image = svgImage.uiImage {
return image.kf.scaled(to: options.scaleFactor)
if let dataString = String(data: data, encoding: .utf8),
let svg = SVG(dataString) {
let render = UIGraphicsImageRenderer(size: svg.size)
let image = render.image { context in
svg.draw(in: context.cgContext)
}
return image.kf.scaled(to: options.scaleFactor)
}
return DefaultImageProcessor.default.process(item: item, options: options)