Transaction proposal navigation
This commit is contained in:
parent
6453830f88
commit
f1903a75eb
|
@ -57,6 +57,7 @@ import co.electriccoin.zcash.ui.common.usecase.UpdateContactUseCase
|
||||||
import co.electriccoin.zcash.ui.common.usecase.ValidateContactAddressUseCase
|
import co.electriccoin.zcash.ui.common.usecase.ValidateContactAddressUseCase
|
||||||
import co.electriccoin.zcash.ui.common.usecase.ValidateContactNameUseCase
|
import co.electriccoin.zcash.ui.common.usecase.ValidateContactNameUseCase
|
||||||
import co.electriccoin.zcash.ui.common.usecase.ValidateEndpointUseCase
|
import co.electriccoin.zcash.ui.common.usecase.ValidateEndpointUseCase
|
||||||
|
import co.electriccoin.zcash.ui.common.usecase.ViewTransactionsAfterSuccessfulProposalUseCase
|
||||||
import co.electriccoin.zcash.ui.common.usecase.Zip321BuildUriUseCase
|
import co.electriccoin.zcash.ui.common.usecase.Zip321BuildUriUseCase
|
||||||
import co.electriccoin.zcash.ui.common.usecase.Zip321ParseUriValidationUseCase
|
import co.electriccoin.zcash.ui.common.usecase.Zip321ParseUriValidationUseCase
|
||||||
import org.koin.core.module.dsl.factoryOf
|
import org.koin.core.module.dsl.factoryOf
|
||||||
|
@ -124,4 +125,5 @@ val useCaseModule =
|
||||||
factoryOf(::SharePCZTUseCase)
|
factoryOf(::SharePCZTUseCase)
|
||||||
factoryOf(::CreateKeystoneProposalPCZTEncoderUseCase)
|
factoryOf(::CreateKeystoneProposalPCZTEncoderUseCase)
|
||||||
factoryOf(::ObserveOnAccountChangedUseCase)
|
factoryOf(::ObserveOnAccountChangedUseCase)
|
||||||
|
factoryOf(::ViewTransactionsAfterSuccessfulProposalUseCase)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package co.electriccoin.zcash.ui.common.usecase
|
||||||
|
|
||||||
|
import co.electriccoin.zcash.ui.NavigationRouter
|
||||||
|
import co.electriccoin.zcash.ui.NavigationTargets.HOME
|
||||||
|
import co.electriccoin.zcash.ui.common.repository.KeystoneProposalRepository
|
||||||
|
|
||||||
|
class ViewTransactionsAfterSuccessfulProposalUseCase(
|
||||||
|
private val keystoneProposalRepository: KeystoneProposalRepository,
|
||||||
|
private val navigationRouter: NavigationRouter,
|
||||||
|
private val observeClearSend: ObserveClearSendUseCase
|
||||||
|
) {
|
||||||
|
operator fun invoke() {
|
||||||
|
keystoneProposalRepository.clear()
|
||||||
|
observeClearSend.requestClear()
|
||||||
|
navigationRouter.forward(HOME)
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import co.electriccoin.zcash.ui.common.repository.SubmitProposalState
|
||||||
import co.electriccoin.zcash.ui.common.usecase.CancelKeystoneProposalFlowUseCase
|
import co.electriccoin.zcash.ui.common.usecase.CancelKeystoneProposalFlowUseCase
|
||||||
import co.electriccoin.zcash.ui.common.usecase.CopyToClipboardUseCase
|
import co.electriccoin.zcash.ui.common.usecase.CopyToClipboardUseCase
|
||||||
import co.electriccoin.zcash.ui.common.usecase.SendEmailUseCase
|
import co.electriccoin.zcash.ui.common.usecase.SendEmailUseCase
|
||||||
|
import co.electriccoin.zcash.ui.common.usecase.ViewTransactionsAfterSuccessfulProposalUseCase
|
||||||
import co.electriccoin.zcash.ui.design.util.stringRes
|
import co.electriccoin.zcash.ui.design.util.stringRes
|
||||||
import co.electriccoin.zcash.ui.screen.addressbook.viewmodel.ADDRESS_MAX_LENGTH
|
import co.electriccoin.zcash.ui.screen.addressbook.viewmodel.ADDRESS_MAX_LENGTH
|
||||||
import co.electriccoin.zcash.ui.screen.sendconfirmation.model.SubmitResult
|
import co.electriccoin.zcash.ui.screen.sendconfirmation.model.SubmitResult
|
||||||
|
@ -28,7 +29,8 @@ class KeystoneTransactionProgressViewModel(
|
||||||
private val keystoneProposalRepository: KeystoneProposalRepository,
|
private val keystoneProposalRepository: KeystoneProposalRepository,
|
||||||
private val copyToClipboardUseCase: CopyToClipboardUseCase,
|
private val copyToClipboardUseCase: CopyToClipboardUseCase,
|
||||||
private val sendEmailUseCase: SendEmailUseCase,
|
private val sendEmailUseCase: SendEmailUseCase,
|
||||||
private val cancelKeystoneProposalFlow: CancelKeystoneProposalFlowUseCase
|
private val cancelKeystoneProposalFlow: CancelKeystoneProposalFlowUseCase,
|
||||||
|
private val viewTransactionsAfterSuccessfulProposal: ViewTransactionsAfterSuccessfulProposalUseCase,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private val supportContacted = MutableStateFlow(false)
|
private val supportContacted = MutableStateFlow(false)
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ class KeystoneTransactionProgressViewModel(
|
||||||
showBackButton = supportContacted,
|
showBackButton = supportContacted,
|
||||||
onBack = {
|
onBack = {
|
||||||
if (supportContacted) {
|
if (supportContacted) {
|
||||||
onBackToHomepageAndClearSendForm()
|
onBackToSendFormAndClear()
|
||||||
}
|
}
|
||||||
// do nothing
|
// do nothing
|
||||||
},
|
},
|
||||||
|
@ -91,15 +93,15 @@ class KeystoneTransactionProgressViewModel(
|
||||||
|
|
||||||
private fun createGrpcFailureTransactionState() =
|
private fun createGrpcFailureTransactionState() =
|
||||||
GrpcFailureTransactionState(
|
GrpcFailureTransactionState(
|
||||||
onBack = ::onBackToHomepageAndClearSendForm,
|
onBack = ::onViewTransactions,
|
||||||
onCloseClick = ::onBackToHomepageAndClearSendForm
|
onCloseClick = ::onViewTransactions
|
||||||
)
|
)
|
||||||
|
|
||||||
private suspend fun createSuccessfulTransactionState(proposal: TransactionProposal?) =
|
private suspend fun createSuccessfulTransactionState(proposal: TransactionProposal?) =
|
||||||
SuccessfulTransactionState(
|
SuccessfulTransactionState(
|
||||||
onBack = ::onBackToHomepageAndClearSendForm,
|
onBack = ::onViewTransactions,
|
||||||
onViewTransactionClick = ::onBackToHomepageAndClearSendForm,
|
onViewTransactionClick = ::onViewTransactions,
|
||||||
onCloseClick = ::onBackToHomepageAndClearSendForm,
|
onCloseClick = ::onViewTransactions,
|
||||||
text =
|
text =
|
||||||
if (proposal is ShieldTransactionProposal) {
|
if (proposal is ShieldTransactionProposal) {
|
||||||
stringRes(R.string.send_confirmation_success_subtitle_transparent)
|
stringRes(R.string.send_confirmation_success_subtitle_transparent)
|
||||||
|
@ -118,9 +120,9 @@ class KeystoneTransactionProgressViewModel(
|
||||||
proposal: TransactionProposal?,
|
proposal: TransactionProposal?,
|
||||||
result: SubmitResult.SimpleTrxFailure
|
result: SubmitResult.SimpleTrxFailure
|
||||||
) = FailureTransactionState(
|
) = FailureTransactionState(
|
||||||
onBack = ::onBackToHomepage,
|
onBack = ::onBackToSendForm,
|
||||||
onCloseClick = ::onBackToHomepage,
|
onCloseClick = ::onBackToSendForm,
|
||||||
onViewTransactionClick = ::onBackToHomepageAndClearSendForm,
|
onViewTransactionClick = ::onViewTransactions,
|
||||||
onReportClick = {
|
onReportClick = {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
sendEmailUseCase(result)
|
sendEmailUseCase(result)
|
||||||
|
@ -167,11 +169,15 @@ class KeystoneTransactionProgressViewModel(
|
||||||
return address?.let { "${it.take(ADDRESS_MAX_LENGTH)}..." }.orEmpty()
|
return address?.let { "${it.take(ADDRESS_MAX_LENGTH)}..." }.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onBackToHomepageAndClearSendForm() {
|
private fun onBackToSendFormAndClear() {
|
||||||
cancelKeystoneProposalFlow(clearSendForm = true)
|
cancelKeystoneProposalFlow(clearSendForm = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onBackToHomepage() {
|
private fun onBackToSendForm() {
|
||||||
cancelKeystoneProposalFlow(clearSendForm = false)
|
cancelKeystoneProposalFlow(clearSendForm = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onViewTransactions() {
|
||||||
|
viewTransactionsAfterSuccessfulProposal()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue