Updated on 2026-08-14
This commit is contained in:
parent
1010ab65f4
commit
deee4fe183
11 changed files with 57 additions and 14 deletions
|
|
@ -37,6 +37,9 @@ sealed class AddressPayIdVerifyAction : SendScreenAction {
|
|||
ADDRESS_SAME_AS_WALLET
|
||||
}
|
||||
|
||||
data class VerifyClipboard(val data: String?) : AddressPayIdVerifyAction()
|
||||
data class ChangePasteBtnEnableState(val isEnabled: Boolean): AddressPayIdVerifyAction()
|
||||
|
||||
sealed class PayIdVerification : AddressPayIdVerifyAction() {
|
||||
data class SetError(val payId: String, val error: Error) : PayIdVerification()
|
||||
data class SetPayIdWalletAddress(val payId: String, val payIdWalletAddress: String) : PayIdVerification()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,12 @@ import org.rekotlin.DispatchFunction
|
|||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class AddressPayIdMiddleware {
|
||||
fun handle(data: String, appState: AppState?, dispatch: DispatchFunction) {
|
||||
fun handle(data: String?, appState: AppState?, dispatch: DispatchFunction) {
|
||||
if (data == null) {
|
||||
dispatch(AddressVerification.SetError("", Error.ADDRESS_INVALID_OR_UNSUPPORTED_BY_BLOCKCHAIN))
|
||||
return
|
||||
}
|
||||
|
||||
val sendState = appState?.sendState ?: return
|
||||
val walletManager = sendState.walletManager ?: return
|
||||
if (data == sendState.addressPayIdState.etFieldValue) return
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.tangem.blockchain.common.Amount
|
|||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdActionUi.ChangeAddressOrPayId
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.*
|
||||
import com.tangem.tap.features.send.redux.AmountActionUi.CheckAmountToSend
|
||||
import com.tangem.tap.features.send.redux.FeeAction.RequestFee
|
||||
import com.tangem.tap.features.send.redux.SendAction
|
||||
|
|
@ -22,6 +23,18 @@ val sendMiddleware: Middleware<AppState> = { dispatch, appState ->
|
|||
{ action ->
|
||||
when (action) {
|
||||
is ChangeAddressOrPayId -> AddressPayIdMiddleware().handle(action.data, appState(), dispatch)
|
||||
is VerifyClipboard -> {
|
||||
AddressPayIdMiddleware().handle(action.data, appState()){
|
||||
when(it) {
|
||||
is AddressVerification.SetWalletAddress, is PayIdVerification.SetPayIdWalletAddress -> {
|
||||
dispatch(ChangePasteBtnEnableState(true))
|
||||
}
|
||||
is AddressVerification.SetError, is PayIdVerification.SetError -> {
|
||||
dispatch(ChangePasteBtnEnableState(false))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is CheckAmountToSend -> AmountMiddleware().handle(action.data, appState(), dispatch)
|
||||
is RequestFee -> RequestFeeMiddleware().handle(appState(), dispatch)
|
||||
is SendActionUi.SendAmountToRecipient -> verifyAndSendTransaction(appState(), dispatch)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ class AddressPayIdReducer : SendInternalReducer {
|
|||
is PayIdVerification.SetError -> state.copyPayIdError(action.payId, action.error)
|
||||
is AddressVerification.SetWalletAddress -> state.copyWalletAddress(action.address)
|
||||
is AddressVerification.SetError -> state.copyError(action.address, action.error)
|
||||
is AddressPayIdVerifyAction.ChangePasteBtnEnableState -> state.copy(pasteIsEnabled = action.isEnabled)
|
||||
is AddressPayIdVerifyAction.VerifyClipboard -> state
|
||||
}
|
||||
return updateLastState(sendState.copy(addressPayIdState = result), result)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ data class AddressPayIdState(
|
|||
val truncatedFieldValue: String? = null,
|
||||
val recipientWalletAddress: String? = null,
|
||||
val error: AddressPayIdVerifyAction.Error? = null,
|
||||
val truncateHandler: ((String) -> String)? = null
|
||||
val truncateHandler: ((String) -> String)? = null,
|
||||
val pasteIsEnabled: Boolean = false
|
||||
) : StateType {
|
||||
|
||||
fun isReady(): Boolean = error == null && recipientWalletAddress?.isNotEmpty() ?: false
|
||||
|
|
|
|||
|
|
@ -17,13 +17,10 @@ import com.tangem.tap.common.qrCodeScan.ScanQrCodeActivity
|
|||
import com.tangem.tap.common.snackBar.MaxAmountSnackbar
|
||||
import com.tangem.tap.common.text.truncateMiddleWith
|
||||
import com.tangem.tap.features.send.BaseStoreFragment
|
||||
import com.tangem.tap.features.send.redux.*
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdActionUi.*
|
||||
import com.tangem.tap.features.send.redux.AmountActionUi.*
|
||||
import com.tangem.tap.features.send.redux.FeeAction
|
||||
import com.tangem.tap.features.send.redux.FeeActionUi.*
|
||||
import com.tangem.tap.features.send.redux.ReceiptAction
|
||||
import com.tangem.tap.features.send.redux.ReleaseSendState
|
||||
import com.tangem.tap.features.send.redux.SendActionUi
|
||||
import com.tangem.tap.features.send.redux.states.FeeType
|
||||
import com.tangem.tap.features.send.redux.states.MainCurrencyType
|
||||
import com.tangem.tap.features.send.ui.stateSubscribers.SendStateSubscriber
|
||||
|
|
@ -60,6 +57,7 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
|
|||
|
||||
private fun setupAddressOrPayIdLayout() {
|
||||
store.dispatch(SetTruncateHandler { etAddressOrPayId.truncateMiddleWith(it, " *** ") })
|
||||
store.dispatch(AddressPayIdVerifyAction.VerifyClipboard(requireContext().getFromClipboard()?.toString()))
|
||||
|
||||
etAddressOrPayId.setOnFocusChangeListener { v, hasFocus ->
|
||||
store.dispatch(TruncateOrRestore(!hasFocus))
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
|
|||
}
|
||||
|
||||
fg.btnSend.isEnabled = state.sendButtonIsEnabled
|
||||
fg.imvPaste.isEnabled = state.addressPayIdState.pasteIsEnabled
|
||||
}
|
||||
|
||||
private fun handleAddressPayIdState(fg: BaseStoreFragment, state: AddressPayIdState) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="15dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="15"
|
||||
android:viewportHeight="18">
|
||||
android:width="16dp"
|
||||
android:height="19dp"
|
||||
android:viewportWidth="16"
|
||||
android:viewportHeight="19">
|
||||
<path
|
||||
android:fillColor="#1C1C1E"
|
||||
android:pathData="M12.4212,14.1668H12.8176C14.2324,14.1668 14.9364,13.4492 14.9364,12.0207V2.3564C14.9364,0.928 14.2255,0.2103 12.8176,0.2103H6.2221C4.8141,0.2103 4.1033,0.928 4.1033,2.3564V2.6913H4.9918C5.9555,2.6913 6.721,2.9647 7.4865,3.7302L11.3686,7.6192C12.1341,8.3915 12.4212,9.1843 12.4212,10.1138V14.1668ZM7.8556,2.623C7.5549,2.623 7.4182,2.4248 7.4182,2.2197V2.0762C7.4182,1.8643 7.5549,1.6729 7.8556,1.6729H11.1841C11.4848,1.6729 11.6215,1.8643 11.6215,2.0762V2.2197C11.6215,2.4248 11.4848,2.623 11.1841,2.623H7.8556ZM2.7706,17.5773H9.3729C10.7808,17.5773 11.4848,16.8597 11.4848,15.4312V9.9293H6.5433C5.6616,9.9293 5.2516,9.5124 5.2516,8.6375V3.6208H2.7706C1.3626,3.6208 0.6518,4.3385 0.6518,5.7669V15.4312C0.6518,16.8665 1.3558,17.5773 2.7706,17.5773ZM6.5365,8.9929H11.1294C11.0542,8.7264 10.8697,8.4803 10.569,8.1659L7.0081,4.5504C6.7142,4.2428 6.4476,4.0583 6.1811,3.9831V8.6444C6.1811,8.8767 6.3041,8.9929 6.5365,8.9929Z" />
|
||||
android:pathData="M13.8333,1.6667H10.35C10,0.7 9.0833,0 8,0C6.9167,0 6,0.7 5.65,1.6667H2.1667C1.25,1.6667 0.5,2.4167 0.5,3.3333V16.6667C0.5,17.5833 1.25,18.3333 2.1667,18.3333H13.8333C14.75,18.3333 15.5,17.5833 15.5,16.6667V3.3333C15.5,2.4167 14.75,1.6667 13.8333,1.6667ZM8,1.6667C8.4583,1.6667 8.8333,2.0417 8.8333,2.5C8.8333,2.9583 8.4583,3.3333 8,3.3333C7.5417,3.3333 7.1667,2.9583 7.1667,2.5C7.1667,2.0417 7.5417,1.6667 8,1.6667ZM13.8333,16.6667H2.1667V3.3333H3.8333V5.8333H12.1667V3.3333H13.8333V16.6667Z"
|
||||
android:fillColor="#1C1C1E"/>
|
||||
</vector>
|
||||
|
|
|
|||
11
app/src/main/res/drawable/ic_paste_disabled.xml
Normal file
11
app/src/main/res/drawable/ic_paste_disabled.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="19dp"
|
||||
android:viewportWidth="16"
|
||||
android:viewportHeight="19">
|
||||
|
||||
<path
|
||||
android:fillColor="#99838383"
|
||||
android:pathData="M13.8333 1.66667H10.35C10 0.7 9.08333 0 8 0C6.91667 0 6 0.7 5.65 1.66667H2.16667C1.25 1.66667 0.5 2.41667 0.5 3.33333V16.6667C0.5 17.5833 1.25 18.3333 2.16667 18.3333H13.8333C14.75 18.3333 15.5 17.5833 15.5 16.6667V3.33333C15.5 2.41667 14.75 1.66667 13.8333 1.66667ZM8 1.66667C8.45833 1.66667 8.83333 2.04167 8.83333 2.5C8.83333 2.95833 8.45833 3.33333 8 3.33333C7.54167 3.33333 7.16667 2.95833 7.16667 2.5C7.16667 2.04167 7.54167 1.66667 8 1.66667ZM13.8333 16.6667H2.16667V3.33333H3.83333V5.83333H12.1667V3.33333H13.8333V16.6667Z" />
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/paste_selector.xml
Normal file
9
app/src/main/res/drawable/paste_selector.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_enabled="true"
|
||||
android:drawable="@drawable/ic_paste" />
|
||||
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/ic_paste_disabled" />
|
||||
</selector>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
android:id="@+id/flPaste"
|
||||
android:layout_width="@dimen/btn_rounded_size"
|
||||
android:layout_height="@dimen/btn_rounded_size"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/shape_ellipse"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/flQrCode"
|
||||
app:layout_constraintEnd_toStartOf="@+id/flQrCode"
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:padding="6dp"
|
||||
app:srcCompat="@drawable/ic_paste" />
|
||||
app:srcCompat="@drawable/paste_selector" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue