[#1434] Improve Shielding UX

* [#1434] Improve Shielding UX

- Closes #1434
- Changelog update

* Trigger balances refresh after sending too
This commit is contained in:
Honza Rychnovský 2024-05-06 16:33:31 +02:00 committed by GitHub
parent 6160554d64
commit 5c21a776d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 21 deletions

View File

@ -22,6 +22,7 @@ directly impact users rather than highlighting other key architectural updates.*
design
### Fixed
- Transparent funds shielding action has been improved to address the latest user feedback
- A few more minor UI improvements
## [1.0 (638)] - 2024-04-26

View File

@ -2,6 +2,7 @@
package co.electriccoin.zcash.ui.screen.balances
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.viewModels
import androidx.compose.runtime.Composable
@ -113,6 +114,11 @@ internal fun WrapBalances(
val (isShowingErrorDialog, setShowErrorDialog) = rememberSaveable { mutableStateOf(false) }
fun showShieldingSuccess() {
setShieldState(ShieldState.Shielded)
Toast.makeText(context, context.getString(R.string.balances_shielding_successful), Toast.LENGTH_LONG).show()
}
suspend fun showShieldingError(errorMessage: String?) {
Twig.error { "Shielding proposal failed with: $errorMessage" }
@ -167,16 +173,18 @@ internal fun WrapBalances(
spendingKey = spendingKey,
proposal = newProposal
)
// Triggering the transaction history and balances refresh to be notified immediately
// about the wallet's updated state
(synchronizer as SdkSynchronizer).run {
refreshTransactions()
refreshAllBalances()
}
when (result) {
SubmitResult.Success -> {
Twig.info { "Shielding transaction done successfully" }
setShieldState(ShieldState.Shielded)
// Triggering transaction history refresh to be notified about the newly created
// transaction asap
(synchronizer as SdkSynchronizer).refreshTransactions()
// We could consider notifying UI with a change to emphasize the shielding action
// was successful, or we could switch the selected tab to Account
showShieldingSuccess()
}
is SubmitResult.SimpleTrxFailure -> {
Twig.warn { "Shielding transaction failed" }
@ -205,15 +213,9 @@ fun updateTransparentBalanceState(
walletSnapshot: WalletSnapshot?
): ShieldState {
return when {
(walletSnapshot == null) -> {
currentShieldState
}
(
walletSnapshot.transparentBalance >= Zatoshi(DEFAULT_SHIELDING_THRESHOLD) &&
currentShieldState.isEnabled()
) -> ShieldState.Available
else -> {
currentShieldState
}
(walletSnapshot == null) -> currentShieldState
(walletSnapshot.transparentBalance >= Zatoshi(DEFAULT_SHIELDING_THRESHOLD) && currentShieldState.isEnabled()) ->
ShieldState.Available
else -> currentShieldState
}
}

View File

@ -78,7 +78,7 @@ internal fun MainActivity.WrapSendConfirmation(
@VisibleForTesting
@Composable
@Suppress("LongParameterList", "LongMethod")
@Suppress("LongParameterList", "LongMethod", "CyclomaticComplexMethod")
internal fun WrapSendConfirmation(
activity: ComponentActivity,
arguments: SendConfirmationArguments,
@ -182,12 +182,17 @@ internal fun WrapSendConfirmation(
spendingKey = spendingKey,
proposal = newZecSend.proposal!!
)
// Triggering the transaction history and balances refresh to be notified immediately
// about the wallet's updated state
(synchronizer as SdkSynchronizer).run {
refreshTransactions()
refreshAllBalances()
}
when (result) {
SubmitResult.Success -> {
setStage(SendConfirmationStage.Confirmation)
// Triggering transaction history refreshing to be notified about the newly created
// transaction asap
(synchronizer as SdkSynchronizer).refreshTransactions()
goHome()
}
is SubmitResult.SimpleTrxFailure -> {

View File

@ -28,6 +28,8 @@
<string name="balances_status_detailed_stopped">Synchronizer stopped</string>
<string name="balances_status_restoring_text">The restore process can take several hours on lower-powered devices, and even on powerful devices is likely to take more than an hour.</string>
<string name="balances_shielding_successful">Shielding has been successfully submitted</string>
<string name="balances_shielding_dialog_error_title">Failed to shield funds</string>
<string name="balances_shielding_dialog_error_text">Error: The attempt to shield the transparent funds failed. Try it again, please.</string>
<string name="balances_shielding_dialog_error_btn">OK</string>