Updated on 2026-08-14
This commit is contained in:
parent
4587cb4bf7
commit
6d7d3060b2
3 changed files with 37 additions and 19 deletions
|
|
@ -32,11 +32,13 @@ data class WalletState(
|
|||
currencyData.status != com.tangem.tap.features.wallet.ui.BalanceStatus.EmptyCard &&
|
||||
currencyData.status != com.tangem.tap.features.wallet.ui.BalanceStatus.UnknownBlockchain
|
||||
|
||||
val showSegwitAddress: Boolean
|
||||
val showMultipleAddress: Boolean
|
||||
get() {
|
||||
val listOfAddresses = walletAddresses?.list ?: return false
|
||||
return (wallet?.blockchain == Blockchain.Bitcoin || wallet?.blockchain == Blockchain.BitcoinTestnet)
|
||||
&& listOfAddresses.size > 1
|
||||
return (wallet?.blockchain == Blockchain.Bitcoin ||
|
||||
wallet?.blockchain == Blockchain.BitcoinTestnet ||
|
||||
wallet?.blockchain == Blockchain.CardanoShelley) &&
|
||||
listOfAddresses.size > 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import androidx.transition.TransitionInflater
|
|||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.squareup.picasso.Picasso
|
||||
import com.tangem.blockchain.blockchains.bitcoin.BitcoinAddressType
|
||||
import com.tangem.blockchain.blockchains.cardano.CardanoAddressType
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.tap.common.extensions.*
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
|
|
@ -229,27 +231,27 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
if (state.walletAddresses != null) {
|
||||
l_address?.show()
|
||||
val tvAddressPaddingTop = tv_address.resources.getDimension(R.dimen.dimen16).toInt()
|
||||
if (state.showSegwitAddress) {
|
||||
if (state.showMultipleAddress) {
|
||||
(l_address as? ViewGroup)?.beginDelayedTransition()
|
||||
tv_address.setPadding(tv_address.paddingStart, tvAddressPaddingTop / 2,
|
||||
tv_address.paddingEnd, tv_address.paddingBottom)
|
||||
chip_group_segwit.show()
|
||||
chip_group_segwit.fitChipsByGroupWidth()
|
||||
chip_group_address_type.show()
|
||||
chip_group_address_type.fitChipsByGroupWidth()
|
||||
|
||||
val checkedId = SegwitUiHelper.typeToId(state.walletAddresses.selectedAddress.type)
|
||||
if (checkedId != View.NO_ID) chip_group_segwit.check(checkedId)
|
||||
val checkedId = MultipleAddressUiHelper.typeToId(state.walletAddresses.selectedAddress.type)
|
||||
if (checkedId != View.NO_ID) chip_group_address_type.check(checkedId)
|
||||
|
||||
chip_group_segwit.setOnCheckedChangeListener { group, checkedId ->
|
||||
chip_group_address_type.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == -1) return@setOnCheckedChangeListener
|
||||
|
||||
SegwitUiHelper.idToType(checkedId)?.let {
|
||||
MultipleAddressUiHelper.idToType(checkedId, state.wallet?.blockchain)?.let {
|
||||
store.dispatch(WalletAction.ChangeSelectedAddress(it))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tv_address.setPadding(tv_address.paddingStart, tvAddressPaddingTop,
|
||||
tv_address.paddingEnd, tv_address.paddingBottom)
|
||||
chip_group_segwit.hide()
|
||||
chip_group_address_type.hide()
|
||||
}
|
||||
tv_address.text = state.walletAddresses.selectedAddress.address
|
||||
tv_explore?.setOnClickListener {
|
||||
|
|
@ -332,20 +334,34 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
|
||||
}
|
||||
|
||||
class SegwitUiHelper {
|
||||
class MultipleAddressUiHelper {
|
||||
companion object {
|
||||
fun typeToId(type: AddressType): Int {
|
||||
return when (type) {
|
||||
is BitcoinAddressType.Legacy -> R.id.chip_legacy
|
||||
is BitcoinAddressType.Segwit -> R.id.chip_default
|
||||
is CardanoAddressType.Byron -> R.id.chip_legacy
|
||||
is CardanoAddressType.Shelley -> R.id.chip_default
|
||||
else -> View.NO_ID
|
||||
}
|
||||
}
|
||||
|
||||
fun idToType(id: Int): AddressType? {
|
||||
fun idToType(id: Int, blockchain: Blockchain?): AddressType? {
|
||||
return when (id) {
|
||||
R.id.chip_default -> BitcoinAddressType.Segwit
|
||||
R.id.chip_legacy -> BitcoinAddressType.Legacy
|
||||
R.id.chip_default -> {
|
||||
when (blockchain) {
|
||||
Blockchain.Bitcoin -> BitcoinAddressType.Segwit
|
||||
Blockchain.CardanoShelley -> CardanoAddressType.Shelley
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
R.id.chip_legacy -> {
|
||||
when (blockchain) {
|
||||
Blockchain.Bitcoin -> BitcoinAddressType.Legacy
|
||||
Blockchain.CardanoShelley -> CardanoAddressType.Byron
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/chip_group_segwit"
|
||||
android:id="@+id/chip_group_address_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
android:textSize="13sp"
|
||||
app:layout_constraintEnd_toStartOf="@id/btn_copy"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_segwit"
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_address_type"
|
||||
tools:text="139mrsJgyWnJ**** **** y9BV" />
|
||||
|
||||
<TextView
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
android:elevation="3dp"
|
||||
android:focusable="true"
|
||||
app:layout_constraintEnd_toStartOf="@id/btn_show_qr"
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_segwit">
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_address_type">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_copy"
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
android:elevation="3dp"
|
||||
android:focusable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_segwit">
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_address_type">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_qr"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue