diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt index ab941817ae..f326c96c1d 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt @@ -16,7 +16,6 @@ import com.tangem.tap.features.wallet.ui.BalanceStatus import com.tangem.tap.features.wallet.ui.BalanceWidgetData import com.tangem.tap.features.wallet.ui.TokenData import com.tangem.tap.store -import com.tangem.wallet.R import org.rekotlin.Action class WalletReducer { @@ -141,19 +140,18 @@ private fun internalReduce(action: Action, state: AppState): WalletState { )) } is WalletAction.LoadArtwork -> { - val cardId = store.state.globalState.scanNoteResponse?.card?.cardId - val cardPublicKey = store.state.globalState.scanNoteResponse?.card?.cardPublicKey?.toHexString() - val artworkUrl = if (cardId != null && cardPublicKey != null && action.artworkId != null) { + val cardId = action.card.cardId + val cardPublicKey = action.card.cardPublicKey?.toHexString() + val artworkUrl = if (cardPublicKey != null && action.artworkId != null) { TangemService.getUrlForArtwork(cardId, cardPublicKey, action.artworkId) + } else if (action.card.cardData?.batchId == Artwork.SERGIO_BATCH) { + Artwork.SERGIO_CARD_URL + } else if (action.card.cardData?.batchId == Artwork.MARTA_BATCH) { + Artwork.MARTA_CARD_URL } else { - null + Artwork.DEFAULT_IMG_URL } - val artwork = if (artworkUrl != null) { - Artwork(artworkId = artworkUrl) - } else { - Artwork(artworkResId = R.drawable.card_default) - } - newState = newState.copy(cardImage = artwork) + newState = newState.copy(cardImage = Artwork(artworkId = artworkUrl)) } is WalletAction.ShowQrCode -> { newState = newState.copy( diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt index de06fe71a2..818956e16e 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt @@ -66,7 +66,14 @@ data class AddressData( ) data class Artwork( - val artworkId: String? = null, - val artwork: Bitmap? = null, - val artworkResId: Int? = null -) \ No newline at end of file + val artworkId: String, + val artwork: Bitmap? = null +) { + companion object { + const val DEFAULT_IMG_URL = "https://app.tangem.com/cards/card_default.png" + const val SERGIO_CARD_URL = "https://app.tangem.com/cards/card_tg059.png" + const val MARTA_CARD_URL = "https://app.tangem.com/cards/card_tg083.png" + const val SERGIO_BATCH = "tg059" + const val MARTA_BATCH = "tg083" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt index a2796e21a7..13c4366fef 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt @@ -192,13 +192,9 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber Picasso.get().load(address) - is Int -> Picasso.get().load(address) - else -> null - } - picassoRequest?.placeholder(R.drawable.card_placeholder) + Picasso.get() + .load(cardImage?.artworkId) + .placeholder(R.drawable.card_placeholder) ?.error(R.drawable.card_placeholder) ?.into(iv_card) }