From 72da950ad98cac25a6c9fbe923e4d1ed7939c2c9 Mon Sep 17 00:00:00 2001 From: mike-dydx Date: Thu, 6 Jun 2024 14:03:16 -0400 Subject: [PATCH] do not render svgs --- .../dydxTransferSearchViewBuilder.swift | 25 +++++++++++-------- .../Search/dydxTransferSearchItemView.swift | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Search/dydxTransferSearchViewBuilder.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Search/dydxTransferSearchViewBuilder.swift index dd387763f..e5b3def6d 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Search/dydxTransferSearchViewBuilder.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Search/dydxTransferSearchViewBuilder.swift @@ -112,16 +112,21 @@ private extension dydxTransferSearchItemViewModel { } self.isSelected = selected if let iconUrl = option.iconUrl, let url = URL(string: iconUrl) { - self.icon = PlatformIconViewModel( - type: .url(url: url, placeholderContent: { - Text(option.localizedString?.prefix(1) ?? "") - .frame(width: 32, height: 32) - .themeColor(foreground: .textTertiary) - .themeColor(background: .layer5) - .borderAndClip(style: .circle, borderColor: .layer7, lineWidth: 1) - .wrappedInAnyView() - }), - size: CGSize(width: 32, height: 32)) + let type: PlatformIconViewModel.IconType + let placeholderText = Text(option.localizedString?.prefix(1) ?? "") + .frame(width: 32, height: 32) + .themeColor(foreground: .textTertiary) + .themeColor(background: .layer5) + .borderAndClip(style: .circle, borderColor: .layer7, lineWidth: 1) + .wrappedInAnyView() + // SwiftUI does not process svgs well + if url.absoluteString.ends(with: ".svg") { + self.icon = placeholderText.wrappedViewModel + } else { + self.icon = PlatformIconViewModel( + type: .url(url: url, placeholderContent: { placeholderText }), + size: CGSize(width: 32, height: 32)) + } } self.onTapAction = onTapAction } diff --git a/dydx/dydxViews/dydxViews/_v4/Transfer/Search/dydxTransferSearchItemView.swift b/dydx/dydxViews/dydxViews/_v4/Transfer/Search/dydxTransferSearchItemView.swift index 4af7c65fe..e2e02dc4c 100644 --- a/dydx/dydxViews/dydxViews/_v4/Transfer/Search/dydxTransferSearchItemView.swift +++ b/dydx/dydxViews/dydxViews/_v4/Transfer/Search/dydxTransferSearchItemView.swift @@ -12,7 +12,7 @@ import Utilities public class dydxTransferSearchItemViewModel: PlatformViewModel { @Published public var onTapAction: (() -> Void)? - @Published public var icon: PlatformIconViewModel? + @Published public var icon: PlatformViewModel? @Published public var text: String? @Published public var tokenText: TokenTextViewModel? @Published public var isSelected: Bool = false