From 28d50d531378961e85c23e5be6ebd0e46f851a46 Mon Sep 17 00:00:00 2001 From: Vladyslav Shepitko Date: Tue, 5 Oct 2021 18:54:11 +0300 Subject: [PATCH] Display 1 subview for `WebImageView` for each image loading source type? --- AlphaWallet/Tokens/Views/OpenSea/WebImageView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/AlphaWallet/Tokens/Views/OpenSea/WebImageView.swift b/AlphaWallet/Tokens/Views/OpenSea/WebImageView.swift index c1b5ca381..b7911c711 100644 --- a/AlphaWallet/Tokens/Views/OpenSea/WebImageView.swift +++ b/AlphaWallet/Tokens/Views/OpenSea/WebImageView.swift @@ -23,6 +23,8 @@ class WebImageView: UIView { var url: URL? { didSet { imageView.image = nil + setIsLoadingImageFromURL(true) + if let url = url?.rewrittenIfIpfs { if url.pathExtension == "svg" { switch type { @@ -44,10 +46,16 @@ class WebImageView: UIView { var image: UIImage? { didSet { imageView.image = image + setIsLoadingImageFromURL(false) webView.loadHTMLString("", baseURL: nil) } } + private func setIsLoadingImageFromURL(_ value: Bool) { + imageView.isHidden = value + webView.isHidden = !imageView.isHidden + } + init(type: ImageType) { self.type = type url = nil @@ -101,4 +109,4 @@ class WebImageView: UIView { """ } -} \ No newline at end of file +}