Updated on 2026-08-14

This commit is contained in:
Tangem 2021-04-12 07:48:02 +00:00
commit f72b1eddbc
7 changed files with 32 additions and 29 deletions

View file

@ -76,9 +76,9 @@ dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
implementation 'com.tangem:blockchain:1.157.0'
implementation 'com.tangem:core:1.108.0'
implementation 'com.tangem:sdk:1.108.0'
implementation 'com.tangem:blockchain:1.164.0'
implementation 'com.tangem:core:1.109.0'
implementation 'com.tangem:sdk:1.109.0'
// WebView
implementation "androidx.browser:browser:1.3.0"

View file

@ -135,9 +135,11 @@ internal class AddressPayIdMiddleware {
if (failReason == null) {
noSchemeAddress.getQueryParameter("amount")?.toBigDecimalOrNull()?.let {
dispatch(AmountAction.SetAmount(it, false))
dispatch(AmountActionUi.CheckAmountToSend)
}
dispatch(SetWalletAddress(supposedAddress, isUserInput))
dispatch(TransactionExtrasAction.Prepare(wallet.blockchain, address, null))
dispatch(FeeAction.RequestFee)
} else {
dispatch(SetAddressError(failReason))
dispatch(TransactionExtrasAction.Release)

View file

@ -6,6 +6,7 @@ import com.tangem.common.extensions.isZero
import com.tangem.tap.common.redux.AppState
import com.tangem.tap.features.send.redux.*
import com.tangem.tap.features.send.redux.states.MainCurrencyType
import com.tangem.tap.features.send.redux.states.SendState
import org.rekotlin.Action
import java.math.BigDecimal
@ -43,6 +44,7 @@ class AmountMiddleware {
}
dispatch(AmountAction.SetAmount(inputValueCrypto, true))
dispatch(AmountActionUi.CheckAmountToSend)
dispatch(FeeAction.RequestFee)
}
@ -78,15 +80,18 @@ class AmountMiddleware {
}
private fun setMaxAmount(appState: AppState?, dispatch: (Action) -> Unit) {
val amountState = appState?.sendState?.amountState ?: return
val sendState = appState?.sendState ?: return
dispatch(AmountAction.SetAmount(amountState.balanceCrypto, false))
dispatch(FeeAction.RequestFee)
if (!amountState.isCoinAmount()) return
dispatch(FeeAction.ChangeLayoutVisibility(main = true, controls = true, chipGroup = true))
dispatch(FeeActionUi.ChangeIncludeFee(true))
dispatch(AmountAction.SetAmount(sendState.amountState.balanceCrypto, false))
dispatch(AmountActionUi.CheckAmountToSend)
if (SendState.isReadyToRequestFee()) {
dispatch(FeeAction.RequestFee)
if (!sendState.amountState.isCoinAmount()) return
dispatch(FeeAction.ChangeLayoutVisibility(main = true, controls = true, chipGroup = true))
dispatch(FeeActionUi.ChangeIncludeFee(true))
}
}
private fun toggleMainCurrency(appState: AppState?, dispatch: (Action) -> Unit) {

View file

@ -10,6 +10,7 @@ import com.tangem.tap.features.send.redux.AmountActionUi
import com.tangem.tap.features.send.redux.FeeAction
import com.tangem.tap.features.send.redux.ReceiptAction
import com.tangem.tap.features.send.redux.SendAction
import com.tangem.tap.features.send.redux.states.SendState
import com.tangem.tap.scope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -26,7 +27,7 @@ class RequestFeeMiddleware {
val sendState = appState?.sendState ?: return
val walletManager = sendState.walletManager ?: return
if (!sendState.addressPayIdIsReady()) {
if (!SendState.isReadyToRequestFee()) {
dispatch(FeeAction.FeeCalculation.SetFeeError(FeeAction.Error.ADDRESS_OR_AMOUNT_IS_EMPTY))
dispatch(FeeAction.ChangeLayoutVisibility(main = false, chipGroup = true))
dispatch(ReceiptAction.RefreshReceipt)

View file

@ -41,7 +41,7 @@ class ReceiptReducer : SendInternalReducer {
val layoutType = determineLayoutType(amountState.mainCurrency.type, amountState.typeOfAmount)
val symbols = determineSymbols(wallet)
val showBlank = !sendState.isReadyToSend()
val showBlank = !SendState.isReadyToSend()
val result = state.copy(
visibleTypeOfReceipt = layoutType,
mainCurrency = amountState.mainCurrency,

View file

@ -45,13 +45,6 @@ data class SendState(
override val stateId: StateId = StateId.SEND_SCREEN
fun isReadyToSend(): Boolean {
val sendState = store.state.sendState
return addressPayIdIsReady() && sendState.amountState.isReady() && sendState.feeState.isReady()
}
fun addressPayIdIsReady(): Boolean = store.state.sendState.addressPayIdState.isReady()
fun getDecimals(type: MainCurrencyType): Int = when (type) {
MainCurrencyType.FIAT -> 2
MainCurrencyType.CRYPTO -> amountState.amountToExtract?.decimals ?: 0
@ -110,6 +103,17 @@ data class SendState(
AmountType.Reserve -> false
}
}
companion object {
fun addressPayIdIsReady(): Boolean = store.state.sendState.addressPayIdState.isReady()
fun amountIsReady(): Boolean = store.state.sendState.amountState.isReady()
fun isReadyToRequestFee(): Boolean = addressPayIdIsReady() && amountIsReady()
fun isReadyToSend(): Boolean = addressPayIdIsReady() && amountIsReady() &&
store.state.sendState.feeState.isReady()
}
}
enum class SendButtonState {

View file

@ -100,14 +100,12 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
.filter { store.state.sendState.addressPayIdState.viewFieldValue.value != it }
.onEach {
store.dispatch(AddressPayIdActionUi.HandleUserInput(it))
store.dispatch(FeeAction.RequestFee)
}
.launchIn(mainScope)
imvPaste.setOnClickListener {
store.dispatch(PasteAddressPayId(requireContext().getFromClipboard()?.toString() ?: ""))
store.dispatch(TruncateOrRestore(!etAddressOrPayId.isFocused))
store.dispatch(FeeAction.RequestFee)
}
imvQrCode.setOnClickListener {
startActivityForResult(
@ -127,12 +125,6 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
.onEach { store.dispatch(TransactionExtrasAction.XlmMemo.HandleUserInput(it)) }
.launchIn(mainScope)
// groupMemo.setOnCheckedChangeListener { group, checkedId ->
// if (checkedId == -1) return@setOnCheckedChangeListener
//
// store.dispatch(TransactionExtrasAction.XlmMemo.ChangeSelectedMemo(MemoUiHelper.toType(checkedId)))
// }
etDestinationTag.inputtedTextAsFlow()
.debounce(400)
.filter {
@ -155,7 +147,6 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
imvQrCode.postDelayed({
store.dispatch(PasteAddressPayId(scannedCode))
store.dispatch(TruncateOrRestore(!etAddressOrPayId.isFocused))
store.dispatch(FeeAction.RequestFee)
}, 200)
}
@ -177,7 +168,6 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
etAmountToSend.clearFocus()
etAmountToSend.postDelayed(200) { etAmountToSend.hideSoftKeyboard() }
store.dispatch(SetMaxAmount)
store.dispatch(CheckAmountToSend)
}
var snackbarControlledByChangingFocus = false
keyboardObserver = KeyboardObserver(requireActivity())
@ -230,6 +220,7 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
flExpandCollapse.setOnClickListener {
store.dispatch(ToggleControlsVisibility)
}
chipGroup.check(FeeUiHelper.toId(FeeType.NORMAL))
chipGroup.setOnCheckedChangeListener { group, checkedId ->
if (checkedId == -1) return@setOnCheckedChangeListener