Skip to content

Commit

Permalink
Use swiftUI Circle instead of placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
esen authored and ealymbaev committed May 30, 2024
1 parent 66d3170 commit 3868e59
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct MultiSwapTokenSelectView: View {
currentToken = item.token
isPresented = false
}) {
CoinIconView(coin: item.token.coin, placeholder: item.token.placeholderImageName)
CoinIconView(coin: item.token.coin, placeholderImage: Image(item.token.placeholderImageName))

VStack(spacing: 1) {
HStack(spacing: .margin8) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct TransactionTokenSelectView: View {
viewModel.set(currentToken: token)
presentationMode.wrappedValue.dismiss()
}) {
CoinIconView(coin: token.coin, placeholder: token.placeholderImageName)
CoinIconView(coin: token.coin, placeholderImage: Image(token.placeholderImageName))

VStack(spacing: 1) {
HStack(spacing: .margin8) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import SwiftUI

struct CoinIconView: View {
let coin: Coin?
let placeholder: String
let placeholderImage: Image?

init(coin: Coin?, placeholder: String = "placeholder_circle_32") {
init(coin: Coin?, placeholderImage: Image? = nil) {
self.coin = coin
self.placeholder = placeholder
self.placeholderImage = placeholderImage
}

var body: some View {
Expand All @@ -33,7 +33,11 @@ struct CoinIconView: View {
KFImage.url(url)
.resizable()
.placeholder {
Image(placeholder)
if let placeholderImage {
placeholderImage
} else {
Circle().fill(Color.themeSteel20)
}
}
}
}

0 comments on commit 3868e59

Please sign in to comment.