Updated on 2026-08-14
This commit is contained in:
parent
881a26b3ab
commit
ce6351f209
11 changed files with 77 additions and 40 deletions
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.tap.common.redux
|
||||
|
||||
import com.tangem.common.extensions.VoidCallback
|
||||
import com.tangem.tap.features.wallet.redux.AddressData
|
||||
import com.tangem.tap.features.wallet.redux.Currency
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -11,8 +11,7 @@ interface StateDialog
|
|||
sealed class AppDialog : StateDialog {
|
||||
object ScanFailsDialog : AppDialog()
|
||||
data class AddressInfoDialog(
|
||||
val currency: Currency,
|
||||
val addressData: AddressData,
|
||||
val onCopyAddress: VoidCallback,
|
||||
val onShareAddress: VoidCallback
|
||||
) : AppDialog()
|
||||
}
|
||||
|
|
@ -4,7 +4,10 @@ import android.content.Context
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
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.redux.AppDialog
|
||||
import com.tangem.tap.features.wallet.redux.Currency
|
||||
import com.tangem.tap.store
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.dialog_onboarding_address_info.*
|
||||
|
|
@ -35,10 +38,31 @@ class AddressInfoBottomSheetDialog(
|
|||
tv_address.text = data.address
|
||||
btn_fl_copy_address.setOnClickListener {
|
||||
context.copyToClipboard(data.address)
|
||||
stateDialog.onCopyAddress()
|
||||
store.dispatchToastNotification(R.string.copy_toast_msg)
|
||||
}
|
||||
btn_fl_share.setOnClickListener {
|
||||
stateDialog.onShareAddress()
|
||||
store.dispatchShare(data.shareUrl)
|
||||
}
|
||||
tv_recieve_message.text = getQRReceiveMessage(tv_recieve_message.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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -134,12 +134,8 @@ private fun handleNoteAction(action: Action, dispatch: DispatchFunction) {
|
|||
}
|
||||
is OnboardingNoteAction.ShowAddressInfoDialog -> {
|
||||
val addressData = noteState.walletManager?.getAddressData() ?: return
|
||||
val addressWasCopied = globalState.resources.strings.addressWasCopied
|
||||
val appDialog = AppDialog.AddressInfoDialog(
|
||||
addressData,
|
||||
onCopyAddress = { store.dispatchToastNotification(addressWasCopied) },
|
||||
onShareAddress = { store.dispatchShare(addressData.shareUrl) }
|
||||
)
|
||||
|
||||
val appDialog = AppDialog.AddressInfoDialog(noteState.walletBalance.currency, addressData)
|
||||
store.dispatchDialogShow(appDialog)
|
||||
}
|
||||
is OnboardingNoteAction.TopUp -> {
|
||||
|
|
|
|||
|
|
@ -239,12 +239,7 @@ private fun handle(action: Action, dispatch: DispatchFunction) {
|
|||
is TwinCardsAction.ShowAddressInfoDialog -> {
|
||||
val addressData = twinCardsState.walletManager?.getAddressData() ?: return
|
||||
|
||||
val addressWasCopied = globalState.resources.strings.addressWasCopied
|
||||
val appDialog = AppDialog.AddressInfoDialog(
|
||||
addressData,
|
||||
onCopyAddress = { store.dispatchToastNotification(addressWasCopied) },
|
||||
onShareAddress = { store.dispatchShare(addressData.shareUrl) }
|
||||
)
|
||||
val appDialog = AppDialog.AddressInfoDialog(twinCardsState.walletBalance.currency, addressData)
|
||||
store.dispatchDialogShow(appDialog)
|
||||
}
|
||||
is TwinCardsAction.TopUp -> {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.tangem.operations.attestation.OnlineCardVerifier
|
|||
import com.tangem.tap.*
|
||||
import com.tangem.tap.common.analytics.FirebaseAnalyticsHandler
|
||||
import com.tangem.tap.common.extensions.*
|
||||
import com.tangem.tap.common.redux.AppDialog
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
|
|
@ -193,6 +194,13 @@ class WalletMiddleware {
|
|||
store.dispatch(NavigationAction.NavigateTo(AppScreen.Send))
|
||||
}
|
||||
}
|
||||
is WalletAction.ShowDialog.QrCode -> {
|
||||
val selectedWalletData = walletState.getWalletData(walletState.selectedWallet) ?: return
|
||||
val selectedAddressData = selectedWalletData.walletAddresses?.selectedAddress ?: return
|
||||
|
||||
val currency = selectedWalletData.currency
|
||||
store.dispatchDialogShow(AppDialog.AddressInfoDialog(currency, selectedAddressData))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ package com.tangem.tap.features.wallet.redux.reducers
|
|||
import com.tangem.blockchain.common.AmountType
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.tap.common.extensions.*
|
||||
import com.tangem.tap.common.extensions.toFiatString
|
||||
import com.tangem.tap.common.extensions.toFiatValue
|
||||
import com.tangem.tap.common.extensions.toFormattedCurrencyString
|
||||
import com.tangem.tap.common.extensions.toFormattedFiatValue
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.global.FiatCurrencyName
|
||||
import com.tangem.tap.domain.TapError
|
||||
|
|
@ -205,16 +208,6 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
}
|
||||
newState = newState.copy(cardImage = Artwork(artworkId = artworkUrl))
|
||||
}
|
||||
is WalletAction.ShowDialog.QrCode -> {
|
||||
val selectedWalletData = newState.getWalletData(newState.selectedWallet)
|
||||
newState = newState.copy(
|
||||
walletDialog = WalletDialog.QrDialog(
|
||||
selectedWalletData?.walletAddresses?.selectedAddress?.shareUrl?.toQrCode(),
|
||||
selectedWalletData?.walletAddresses?.selectedAddress?.shareUrl,
|
||||
selectedWalletData?.currencyData?.currency
|
||||
)
|
||||
)
|
||||
}
|
||||
is WalletAction.ShowDialog.SignedHashesMultiWalletDialog -> {
|
||||
newState = newState.copy(walletDialog = WalletDialog.SignedHashesMultiWalletDialog)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.tangem.tap.common.SnackbarHandler
|
|||
import com.tangem.tap.common.extensions.*
|
||||
import com.tangem.tap.common.redux.StateDialog
|
||||
import com.tangem.tap.common.redux.navigation.NavigationAction
|
||||
import com.tangem.tap.features.onboarding.getQRReceiveMessage
|
||||
import com.tangem.tap.features.wallet.models.PendingTransaction
|
||||
import com.tangem.tap.features.wallet.redux.*
|
||||
import com.tangem.tap.features.wallet.ui.adapters.PendingTransactionsAdapter
|
||||
|
|
@ -180,6 +181,7 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details), StoreS
|
|||
requireContext()))
|
||||
}
|
||||
iv_qr_code.setImageBitmap(state.walletAddresses.selectedAddress.shareUrl.toQrCode())
|
||||
tv_recieve_message.text = getQRReceiveMessage(tv_recieve_message.context, state.currency)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,9 @@ class SingleWalletView : WalletView {
|
|||
store.dispatch(WalletAction.CopyAddress(addressString, fragment.requireContext()))
|
||||
}
|
||||
}
|
||||
btn_show_qr.setOnClickListener { store.dispatch(WalletAction.ShowDialog.QrCode) }
|
||||
btn_show_qr.setOnClickListener {
|
||||
store.dispatch(WalletAction.ShowDialog.QrCode)
|
||||
}
|
||||
|
||||
setupTradeButton(fragment, state.tradeCryptoState)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,24 +24,26 @@
|
|||
app:layout_constraintTop_toBottomOf="@+id/pseudo_toolbar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_scan_address"
|
||||
android:id="@+id/tv_recieve_message"
|
||||
style="@style/TextViewOnboarding.Body"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="@string/onboarding_dialog_wallet_address"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:textAlignment="center"
|
||||
android:textAllCaps="false"
|
||||
app:layout_constraintEnd_toEndOf="@+id/imv_qr_code"
|
||||
app:layout_constraintStart_toStartOf="@+id/imv_qr_code"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imv_qr_code" />
|
||||
app:layout_constraintBottom_toTopOf="@+id/guideline3"
|
||||
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" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.8047809" />
|
||||
app:layout_constraintGuide_percent="0.8" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/btn_fl_copy_address"
|
||||
|
|
@ -83,6 +85,7 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_copy_green" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
|
@ -104,11 +107,12 @@
|
|||
app:layout_constraintTop_toTopOf="@+id/guideline3">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_share_green" />
|
||||
android:src="@drawable/ic_share_chip"
|
||||
android:tint="@color/accent" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -179,6 +179,20 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/btn_copy" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_recieve_message"
|
||||
style="@style/TextViewOnboarding.Body"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textAlignment="center"
|
||||
android:textAllCaps="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_qr_code"
|
||||
tools:text="@string/address_qr_code_message_token_format" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@
|
|||
<string name="onboarding_done_button_continue" translatable="false">Continue</string>
|
||||
<string name="onboarding_balance_title" translatable="false">Balance</string>
|
||||
<string name="address_qr_code_message_format" translatable="false">Send only %s (%s) to this address. Sending any other currency will result in its irreversible loss.</string>
|
||||
<string name="address_qr_code_message_token_format" translatable="false">Send only %s (%s) from %@snetwork to this address. Sending any other currency will result in its irreversible loss.</string>
|
||||
<string name="address_qr_code_message_token_format" translatable="false">Send only %s (%s) from %s network to this address. Sending any other currency will result in its irreversible loss.</string>
|
||||
|
||||
<string name="onboarding_twins_interrupt_warning" translatable="false">If the process of re-creating the wallet gets interrupted in any way, you’ll have to start over.</string>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue