Skip to content

Commit 9553fdb

Browse files
committed
Fix tool icons loading
1 parent df0cb5c commit 9553fdb

4 files changed

Lines changed: 34 additions & 4 deletions

File tree

Bluerage/Sources/Kit/Extensions/Nuke+Ext.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
import Nuke
2+
import Foundation
3+
4+
extension AssetType {
5+
6+
static var svg: AssetType {
7+
"public.svg-image"
8+
}
9+
10+
}
211

312
extension ImageDecoders {
413

14+
private struct SVG: ImageDecoding, Sendable {
15+
16+
private let assetType: AssetType = .svg
17+
18+
public var isAsynchronous: Bool { false }
19+
20+
public func decode(_ data: Data) throws -> ImageContainer {
21+
ImageContainer(image: PlatformImage(), type: self.assetType, data: data, userInfo: [:])
22+
}
23+
24+
}
25+
526
static func registerSVGDecoder() {
627
ImageDecoderRegistry.shared.register { context in
7-
let isSVG = context.urlResponse?.url?.absoluteString.hasSuffix(".svg") ?? false
8-
return isSVG ? ImageDecoders.Empty() : nil
28+
let isSVG = context.urlResponse?.isSVG ?? false
29+
return isSVG ? ImageDecoders.SVG() : nil
930
}
1031
}
1132

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
extension URLResponse {
4+
5+
var isSVG: Bool {
6+
return self.mimeType == "image/svg+xml"
7+
}
8+
9+
}

Bluerage/Sources/UI/Components/ToolCellView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct ToolCellView: View {
6666
} label: {
6767
HStack {
6868
LazyImage(url: self.tool.logoURL) { state in
69-
let isSVG = (try? state.result?.get().request.url?.absoluteString.hasSuffix(".svg")) ?? false
69+
let isSVG = (try? state.result?.get().container.type == .svg) ?? false
7070

7171
if isSVG, let data = state.imageContainer?.data {
7272
SVGView(data: data)

Tuist/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let package = Package(
2525
.package(url: "https://github.com/blueragesoftware/clerk-ios", branch: "main"),
2626
.package(url: "https://github.com/exyte/SVGView", from: "1.0.6"),
2727
.package(url: "https://github.com/gonzalezreal/swift-markdown-ui.git", from: "2.4.1"),
28-
.package(url: "https://github.com/hmlongco/Navigator", from: "1.1.1"),
28+
.package(url: "https://github.com/hmlongco/Navigator", from: "1.2.2"),
2929
.package(url: "https://github.com/siteline/swiftui-introspect", from: "26.0.0"),
3030
.package(url: "https://github.com/kean/Get", from: "2.2.1"),
3131
.package(url: "https://github.com/knocklabs/knock-swift.git", from: "1.2.4")

0 commit comments

Comments
 (0)