Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-28 18:40:03 +03:00
parent 87ba93d4d6
commit 1084c9ff69
11 changed files with 65 additions and 45 deletions

View file

@ -11,8 +11,8 @@ import com.tangem.tap.common.extensions.copyToClipboard
import com.tangem.tap.common.extensions.dispatchDialogHide
import com.tangem.tap.common.extensions.dispatchShare
import com.tangem.tap.common.extensions.dispatchToastNotification
import com.tangem.tap.common.extensions.getString
import com.tangem.tap.common.redux.AppDialog
import com.tangem.tap.features.wallet.models.Currency
import com.tangem.tap.features.wallet.redux.AddressData
import com.tangem.tap.store
import com.tangem.wallet.R
@ -62,26 +62,12 @@ class AddressInfoBottomSheetDialog(
Analytics.send(Token.Recieve.ButtonShareAddress())
store.dispatchShare(data.shareUrl)
}
tvReceiveMessage.text = getQRReceiveMessage(tvReceiveMessage.context, stateDialog.currency)
}
}
fun getQRReceiveMessage(context: Context, currency: Currency): String {
return when (currency) {
is Currency.Blockchain -> {
context.getString(
R.string.address_qr_code_message_format,
currency.blockchain.fullName,
currency.currencySymbol,
)
}
is Currency.Token -> {
context.getString(
R.string.address_qr_code_message_token_format,
currency.token.name,
currency.currencySymbol,
currency.blockchain.fullName,
)
}
val blockchain = stateDialog.currency.blockchain
tvReceiveMessage.text = tvReceiveMessage.getString(
id = R.string.address_qr_code_message_format,
blockchain.fullName,
blockchain.currency,
blockchain.fullName,
)
}
}

View file

@ -36,7 +36,6 @@ import com.tangem.tap.common.extensions.toQrCode
import com.tangem.tap.common.recyclerView.SpaceItemDecoration
import com.tangem.tap.common.redux.navigation.NavigationAction
import com.tangem.tap.domain.tokens.models.BlockchainNetwork
import com.tangem.tap.features.onboarding.getQRReceiveMessage
import com.tangem.tap.features.wallet.models.Currency
import com.tangem.tap.features.wallet.models.PendingTransaction
import com.tangem.tap.features.wallet.redux.ErrorType
@ -324,8 +323,21 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
)
}
ivQrCode.setImageBitmap(state.walletAddresses.selectedAddress.shareUrl.toQrCode())
tvReceiveMessage.text =
getQRReceiveMessage(tvReceiveMessage.context, state.currency)
tvReceiveMessage.text = when (val currency = state.currency) {
is Currency.Blockchain -> tvReceiveMessage.getString(
id = R.string.address_qr_code_message_format,
currency.blockchain.fullName,
currency.currencySymbol,
currency.blockchain.fullName,
)
is Currency.Token -> tvReceiveMessage.getString(
id = R.string.address_qr_code_message_format,
currency.token.name,
currency.currencySymbol,
currency.blockchain.fullName,
)
}
}
}

View file

@ -6,6 +6,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.tangem.tap.common.extensions.beginDelayedTransition
import com.tangem.tap.common.extensions.fitChipsByGroupWidth
import com.tangem.tap.common.extensions.getQuantityString
import com.tangem.tap.common.extensions.getString
import com.tangem.tap.common.extensions.hide
import com.tangem.tap.common.extensions.show
import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsState
@ -65,7 +66,7 @@ class SingleWalletView : WalletView() {
setupTwinCards(state.twinCardsState, binding)
setupButtons(state.primaryWallet, binding, state.isExchangeServiceFeatureOn)
setupAddressCard(state.primaryWallet, binding)
setupAddressCard(state, binding)
showPendingTransactionsIfPresent(state.primaryWallet.pendingTransactions)
setupBalance(state, state.primaryWallet)
}
@ -152,35 +153,50 @@ class SingleWalletView : WalletView() {
}
}
private fun setupAddressCard(state: WalletData, binding: FragmentWalletBinding) = with(binding.lAddress) {
if (state.walletAddresses != null && state.currency is Currency.Blockchain) {
private fun setupAddressCard(state: WalletState, binding: FragmentWalletBinding) = with(binding.lAddress) {
val primaryWallet = state.primaryWallet
if (primaryWallet?.walletAddresses != null && primaryWallet.currency is Currency.Blockchain) {
binding.lAddress.root.show()
if (state.shouldShowMultipleAddress()) {
if (primaryWallet.shouldShowMultipleAddress()) {
(binding.lAddress.root as? ViewGroup)?.beginDelayedTransition()
chipGroupAddressType.show()
chipGroupAddressType.fitChipsByGroupWidth()
val checkedId = MultipleAddressUiHelper.typeToId(state.walletAddresses.selectedAddress.type)
val checkedId = MultipleAddressUiHelper.typeToId(primaryWallet.walletAddresses.selectedAddress.type)
if (checkedId != View.NO_ID) chipGroupAddressType.check(checkedId)
chipGroupAddressType.setOnCheckedChangeListener { group, checkedId ->
if (checkedId == -1) return@setOnCheckedChangeListener
val type = MultipleAddressUiHelper.idToType(checkedId, state.currency.blockchain)
val type = MultipleAddressUiHelper.idToType(checkedId, primaryWallet.currency.blockchain)
type?.let { store.dispatch(WalletAction.ChangeSelectedAddress(type)) }
}
} else {
chipGroupAddressType.hide()
}
tvAddress.text = state.walletAddresses.selectedAddress.address
tvAddress.text = primaryWallet.walletAddresses.selectedAddress.address
tvExplore.setOnClickListener {
store.dispatch(
WalletAction.ExploreAddress(
state.walletAddresses.selectedAddress.exploreUrl,
primaryWallet.walletAddresses.selectedAddress.exploreUrl,
fragment!!.requireContext(),
),
)
}
setupCardInfo(state)
} else {
binding.lAddress.root.hide()
}
}
private fun setupCardInfo(state: WalletState) {
val textView = binding?.lAddress?.tvInfo
val blockchain = state.primaryWallet?.currency?.blockchain
if (textView != null && blockchain != null) {
textView.text = textView.getString(
id = R.string.address_qr_code_message_format,
blockchain.fullName,
blockchain.currency,
blockchain.fullName,
)
}
}
}

View file

@ -36,7 +36,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imv_qr_code"
tools:text="@string/address_qr_code_message_token_format" />
tools:text="Send only Ethereum (ETH) from Ethereum network to this address. Using other tokens and networks may result in loss of funds." />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"

View file

@ -137,6 +137,17 @@
</FrameLayout>
<TextView
android:id="@+id/tv_info"
style="@style/TextViewOnboarding.Body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing16"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_explore"
tools:text="Send only Ethereum (ETH) from Ethereum network to this address. Using other tokens and networks may result in loss of funds." />
<View
android:id="@+id/v_payid_divider"
android:layout_width="match_parent"

View file

@ -174,7 +174,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_copy"
tools:text="@string/address_qr_code_message_token_format" />
tools:text="Send only Ethereum (ETH) from Ethereum network to this address. Using other tokens and networks may result in loss of funds." />
</androidx.constraintlayout.widget.ConstraintLayout>