Skip to content

Commit

Permalink
MOB-2098 - Show all available ULW tokens in share screen (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Pecheneg authored Jul 3, 2024
1 parent 31e0bfc commit acc0c8c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,7 @@ private extension ShareWalletAssetInfoView {
}

func filterMultiChainTokensToDisplay(tokens: [BalanceTokenUIDescription]) -> [BalanceTokenUIDescription] {
let groupedByChainTokens = [String : [BalanceTokenUIDescription]].init(grouping: tokens, by: { $0.chain })

var tokensToDisplay = [BalanceTokenUIDescription]()

for key in groupedByChainTokens.keys.sorted() {
let chainTokens = groupedByChainTokens[key] ?? []
let tokenToUse: BalanceTokenUIDescription
if chainTokens.count == 1 {
tokenToUse = chainTokens[0]
} else {
tokenToUse = chainTokens.filter({ $0.parent == nil }).first ?? chainTokens.first!
}
tokensToDisplay.append(tokenToUse)
}

return tokensToDisplay
tokens
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,24 @@ extension CopyMultichainWalletAddressesPullUpView {
let token: BalanceTokenUIDescription
let selectionType: SelectionType
@State private var icon: UIImage?
@State private var parentIcon: UIImage?

var body: some View {
UDListItemView(title: token.name,
subtitle: token.address.walletAddressTruncated,
subtitleStyle: .default,
imageType: .uiImage(icon ?? .init()),
imageStyle: .full,
rightViewStyle: rightViewStyle())
ZStack(alignment: .bottomLeading) {
UDListItemView(title: token.name,
subtitle: token.address.walletAddressTruncated,
subtitleStyle: .default,
imageType: .uiImage(icon ?? .init()),
imageStyle: .full,
rightViewStyle: rightViewStyle())
if let parentIcon {
Image(uiImage: parentIcon)
.resizable()
.squareFrame(20)
.clipShape(Circle())
.offset(x: 24, y: -2)
}
}
.onAppear(perform: onAppear)
}

Expand Down Expand Up @@ -140,6 +150,9 @@ extension CopyMultichainWalletAddressesPullUpView {
token.loadTokenIcon { image in
self.icon = image
}
token.loadParentIcon { image in
self.parentIcon = image
}
}
}
}
Expand Down Expand Up @@ -181,6 +194,7 @@ extension CopyMultichainWalletAddressesPullUpView {

#Preview {
CopyMultichainWalletAddressesPullUpView(tokens: [MockEntitiesFabric.Tokens.mockEthToken(),
MockEntitiesFabric.Tokens.mockMaticToken()],
MockEntitiesFabric.Tokens.mockMaticToken(),
MockEntitiesFabric.Tokens.mockUSDTToken()],
selectionType: .copyOnly)
}

0 comments on commit acc0c8c

Please sign in to comment.