[#1161] Remove Send.Success + rework Send.Failure

- Closes #1161
This commit is contained in:
Honza Rychnovský 2024-03-21 13:02:31 +01:00 committed by GitHub
parent 3845772071
commit 7f3e55cc82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 39 additions and 57 deletions

View File

@ -16,6 +16,7 @@ directly impact users rather than highlighting other key architectural updates.*
lightwalletd servers in runtime.
- The About screen now contains a link to the new Zashi Privacy Policy website
- The Send Confirmation screen has been reworked according to the new design
- Transitions between screens are now animated with a simple slide animation
### Changed
- The Transaction History UI has been incorporated into the Account screen

View File

@ -87,7 +87,7 @@ fun PrimaryButton(
horizontal = ZcashTheme.dimens.spacingNone,
vertical = ZcashTheme.dimens.spacingSmall
),
contentPaddingValues: PaddingValues = PaddingValues(all = 14.dp)
contentPaddingValues: PaddingValues = PaddingValues(all = 15.dp)
) {
Button(
shape = RectangleShape,

View File

@ -117,7 +117,6 @@ class SendViewTestSetup(
),
sendStage = sendStage,
onCreateZecSend = setZecSend,
zecSend = zecSend,
focusManager = LocalFocusManager.current,
onBack = onBackAction,
onSettings = { onSettingsCount.incrementAndGet() },

View File

@ -158,7 +158,7 @@ internal fun WrapBalances(
Twig.debug { "Shielding transaction event" }
setShieldState(ShieldState.None)
}.onFailure {
showShieldingError(null)
showShieldingError(it)
}
}
}.onFailure {

View File

@ -166,7 +166,6 @@ internal fun WrapSend(
Send(
walletSnapshot = walletSnapshot,
sendStage = sendStage,
zecSend = zecSend,
onCreateZecSend = { newZecSend ->
scope.launch {
Twig.debug { "Getting send transaction proposal" }
@ -179,8 +178,6 @@ internal fun WrapSend(
goSendConfirmation(enrichedZecSend)
}.onFailure {
Twig.error(it) { "Transaction proposal failed" }
// TODO [#1161]: Remove Send-Success and rework Send-Failure
// TODO [#1161]: https://github.com/Electric-Coin-Company/zashi-android/issues/1161
setSendStage(SendStage.SendFailure(it.message ?: ""))
}
}

View File

@ -80,7 +80,6 @@ private fun PreviewSendForm() {
Send(
walletSnapshot = WalletSnapshotFixture.new(),
sendStage = SendStage.Form,
zecSend = null,
onCreateZecSend = {},
focusManager = LocalFocusManager.current,
onBack = {},
@ -120,7 +119,6 @@ private fun PreviewSendFailure() {
fun Send(
walletSnapshot: WalletSnapshot,
sendStage: SendStage,
zecSend: ZecSend?,
onCreateZecSend: (ZecSend) -> Unit,
focusManager: FocusManager,
onBack: () -> Unit,
@ -143,7 +141,6 @@ fun Send(
onBack = onBack,
focusManager = focusManager,
sendStage = sendStage,
zecSend = zecSend,
onCreateZecSend = onCreateZecSend,
recipientAddressState = recipientAddressState,
onRecipientAddressChange = onRecipientAddressChange,
@ -191,7 +188,6 @@ private fun SendMainContent(
focusManager: FocusManager,
onBack: () -> Unit,
goBalances: () -> Unit,
zecSend: ZecSend?,
onCreateZecSend: (ZecSend) -> Unit,
sendStage: SendStage,
onQrScannerOpen: () -> Unit,
@ -204,32 +200,30 @@ private fun SendMainContent(
setMemoState: (MemoState) -> Unit,
modifier: Modifier = Modifier,
) {
when {
// For now, we merge [SendStage.Form] and [SendStage.Proposing] into one stage. We could eventually display a
// loader if calling the Proposal API takes longer than expected
(sendStage == SendStage.Form || sendStage == SendStage.Proposing || null == zecSend) -> {
SendForm(
walletSnapshot = walletSnapshot,
recipientAddressState = recipientAddressState,
onRecipientAddressChange = onRecipientAddressChange,
amountState = amountState,
setAmountState = setAmountState,
memoState = memoState,
setMemoState = setMemoState,
onCreateZecSend = onCreateZecSend,
focusManager = focusManager,
onQrScannerOpen = onQrScannerOpen,
goBalances = goBalances,
hasCameraFeature = hasCameraFeature,
modifier = modifier
)
}
(sendStage is SendStage.SendFailure) -> {
SendFailure(
reason = sendStage.error,
onDone = onBack,
)
}
// For now, we merge [SendStage.Form] and [SendStage.Proposing] into one stage. We could eventually display a
// loader if calling the Proposal API takes longer than expected
SendForm(
walletSnapshot = walletSnapshot,
recipientAddressState = recipientAddressState,
onRecipientAddressChange = onRecipientAddressChange,
amountState = amountState,
setAmountState = setAmountState,
memoState = memoState,
setMemoState = setMemoState,
onCreateZecSend = onCreateZecSend,
focusManager = focusManager,
onQrScannerOpen = onQrScannerOpen,
goBalances = goBalances,
hasCameraFeature = hasCameraFeature,
modifier = modifier
)
if (sendStage is SendStage.SendFailure) {
SendFailure(
reason = sendStage.error,
onDone = onBack
)
}
}

View File

@ -72,8 +72,8 @@ internal fun WrapSendConfirmation(
SendConfirmationStage.Sending -> { /* no action - wait until the sending is done */ }
is SendConfirmationStage.Failure -> setStage(SendConfirmationStage.Confirmation)
is SendConfirmationStage.MultipleTrxFailure -> {
// TODO [#1161]: Remove Send-Success and rework Send-Failure
// TODO [#1161]: https://github.com/Electric-Coin-Company/zashi-android/issues/1161
// TODO [#1294]: Add Send.Multiple-Trx-Failed screen
// TODO [#1294]: https://github.com/Electric-Coin-Company/zashi-android/issues/1294
setStage(SendConfirmationStage.Confirmation)
}
}

View File

@ -126,7 +126,7 @@ private fun SendConfirmationMainContent(
modifier: Modifier = Modifier,
) {
when (stage) {
SendConfirmationStage.Confirmation -> {
SendConfirmationStage.Confirmation, SendConfirmationStage.Sending, is SendConfirmationStage.Failure -> {
SendConfirmationContent(
zecSend = zecSend,
onBack = onBack,
@ -134,28 +134,19 @@ private fun SendConfirmationMainContent(
onStageChange(SendConfirmationStage.Sending)
onSendSubmit(zecSend)
},
isSending = false,
isSending = stage == SendConfirmationStage.Sending,
modifier = modifier
)
}
SendConfirmationStage.Sending -> {
SendConfirmationContent(
zecSend = zecSend,
onBack = onBack,
onConfirmation = {},
isSending = true,
modifier = modifier
)
}
is SendConfirmationStage.Failure -> {
SendFailure(
onDone = onBack,
reason = stage.error,
)
if (stage is SendConfirmationStage.Failure) {
SendFailure(
onDone = onBack,
reason = stage.error,
)
}
}
is SendConfirmationStage.MultipleTrxFailure -> {
// TODO [#1161]: Remove Send-Success and rework Send-Failure
// TODO [#1161]: https://github.com/Electric-Coin-Company/zashi-android/issues/1161
// TODO [#1294]: Add Send.Multiple-Trx-Failed screen
// TODO [#1294]: https://github.com/Electric-Coin-Company/zashi-android/issues/1294
SendFailure(
onDone = onBack,
reason = stage.error,