Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New ImageView class for loading and showing Erc20 Coin icons (#141)
- Loading branch information
Showing
16 changed files
with
99 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...allet/BankWallet/Assets.xcassets/Coin Icons/Erc20 Placeholder Icon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "phi@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "phi@3x.png", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+1.02 KB
...ankWallet/Assets.xcassets/Coin Icons/Erc20 Placeholder Icon.imageset/phi@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.57 KB
...ankWallet/Assets.xcassets/Coin Icons/Erc20 Placeholder Icon.imageset/phi@3x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
BankWallet/BankWallet/Modules/Deposit/ViewItems/CollectionView/AddressItem.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
struct AddressItem { | ||
let title: String | ||
let coin: Coin | ||
let address: String | ||
let coinCode: CoinCode | ||
} | ||
|
||
extension AddressItem: Equatable { | ||
|
||
public static func ==(lhs: AddressItem, rhs: AddressItem) -> Bool { | ||
return lhs.title == rhs.title && lhs.address == rhs.address && lhs.coinCode == rhs.coinCode | ||
return lhs.coin == rhs.coin && lhs.address == rhs.address | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
BankWallet/BankWallet/UserInterface/CoinIconImageView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import UIKit | ||
import AlamofireImage | ||
|
||
class CoinIconImageView: UIImageView { | ||
|
||
private static let filter = DynamicImageFilter("TemplateImageFilter") { image in | ||
return image.withRenderingMode(.alwaysTemplate) | ||
} | ||
|
||
private static let erc20placeholderImage = UIImage(named: "Erc20 Placeholder Icon")?.withRenderingMode(.alwaysTemplate) | ||
|
||
func bind(coin: Coin) { | ||
switch coin.type { | ||
case let .erc20(address, _): | ||
// let baseApiUrl = App.shared.appConfigProvider.ratesApiUrl | ||
let baseApiUrl = "https://ipfs.horizontalsystems.xyz/ipns/Qmd4Gv2YVPqs6dmSy1XEq7pQRSgLihqYKL2JjK7DMUFPVz/io-hs/data" | ||
let screenScale = Int(UIScreen.main.scale) | ||
|
||
let urlString = "\(baseApiUrl)/blockchain/ETH/erc20/\(address)/icons/ios/icon@\(screenScale)x.png" | ||
|
||
if let url = URL(string: urlString) { | ||
af_setImage( | ||
withURL: url, | ||
placeholderImage: CoinIconImageView.erc20placeholderImage, | ||
filter: CoinIconImageView.filter | ||
) | ||
} | ||
default: | ||
image = UIImage(named: "\(coin.code) Icon")?.withRenderingMode(.alwaysTemplate) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.