Merge pull request #1860 from Electric-Coin-Company/feature/bugfixes

2.0.1 bugfixes
This commit is contained in:
Milan 2025-04-29 14:47:58 +02:00 committed by GitHub
commit a5b06c41e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 57 additions and 11 deletions

View File

@ -6,6 +6,10 @@ and this application adheres to [Semantic Versioning](https://semver.org/spec/v2
## [Unreleased] ## [Unreleased]
### Fixed
- Homepage buttons now display correctly on small screen devices
- Scan navigates back to zip 321 when insufficient funds detected
## [2.0.0 (934)] - 2025-04-25 ## [2.0.0 (934)] - 2025-04-25
### Added: ### Added:

View File

@ -27,6 +27,7 @@ import androidx.compose.ui.input.pointer.changedToUp
import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import co.electriccoin.zcash.ui.design.R import co.electriccoin.zcash.ui.design.R
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
@ -91,21 +92,25 @@ fun ZashiBigIconButton(
shadowElevation = shadowElevation shadowElevation = shadowElevation
) { ) {
Column( Column(
modifier = backgroundModifier.padding(16.dp), modifier = backgroundModifier,
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center verticalArrangement = Arrangement.Center
) { ) {
Image( Image(
modifier = Modifier.padding(start = 16.dp, top = 16.dp, end = 16.dp),
painter = painterResource(state.icon), painter = painterResource(state.icon),
contentDescription = state.text.getValue(), contentDescription = state.text.getValue(),
colorFilter = ColorFilter.tint(ZashiColors.Text.textPrimary) colorFilter = ColorFilter.tint(ZashiColors.Text.textPrimary)
) )
Spacer(Modifier.height(4.dp)) Spacer(Modifier.height(4.dp))
Text( Text(
modifier = Modifier.padding(bottom = 16.dp),
text = state.text.getValue(), text = state.text.getValue(),
style = ZashiTypography.textXs, style = ZashiTypography.textXs,
fontWeight = FontWeight.Medium, fontWeight = FontWeight.Medium,
color = ZashiColors.Text.textPrimary color = ZashiColors.Text.textPrimary,
maxLines = 1,
overflow = TextOverflow.Clip
) )
} }
} }

View File

@ -2,6 +2,7 @@ package co.electriccoin.zcash.ui.common.usecase
import co.electriccoin.zcash.ui.NavigationRouter import co.electriccoin.zcash.ui.NavigationRouter
import co.electriccoin.zcash.ui.common.datasource.AccountDataSource import co.electriccoin.zcash.ui.common.datasource.AccountDataSource
import co.electriccoin.zcash.ui.common.datasource.TransactionProposalNotCreatedException
import co.electriccoin.zcash.ui.common.model.KeystoneAccount import co.electriccoin.zcash.ui.common.model.KeystoneAccount
import co.electriccoin.zcash.ui.common.model.ZashiAccount import co.electriccoin.zcash.ui.common.model.ZashiAccount
import co.electriccoin.zcash.ui.common.repository.KeystoneProposalRepository import co.electriccoin.zcash.ui.common.repository.KeystoneProposalRepository
@ -77,6 +78,11 @@ class OnZip321ScannedUseCase(
) )
) )
navigationRouter.replace(Send(), ReviewTransaction) navigationRouter.replace(Send(), ReviewTransaction)
} catch (_: TransactionProposalNotCreatedException) {
prefillSend.requestFromZip321(zip321.payment)
navigationRouter.replace(Send())
zashiProposalRepository.clear()
keystoneProposalRepository.clear()
} catch (e: Exception) { } catch (e: Exception) {
navigateToErrorUseCase(ErrorArgs.General(e)) navigateToErrorUseCase(ErrorArgs.General(e))
zashiProposalRepository.clear() zashiProposalRepository.clear()
@ -113,6 +119,11 @@ class OnZip321ScannedUseCase(
) )
) )
navigationRouter.forward(ReviewTransaction) navigationRouter.forward(ReviewTransaction)
} catch (_: TransactionProposalNotCreatedException) {
prefillSend.requestFromZip321(zip321.payment)
navigationRouter.back()
zashiProposalRepository.clear()
keystoneProposalRepository.clear()
} catch (e: Exception) { } catch (e: Exception) {
navigateToErrorUseCase(ErrorArgs.General(e)) navigateToErrorUseCase(ErrorArgs.General(e))
zashiProposalRepository.clear() zashiProposalRepository.clear()

View File

@ -1,5 +1,7 @@
package co.electriccoin.zcash.ui.common.usecase package co.electriccoin.zcash.ui.common.usecase
import PaymentRequest
import cash.z.ecc.android.sdk.ext.convertZecToZatoshi
import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.Zatoshi
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -15,7 +17,7 @@ class PrefillSendUseCase {
operator fun invoke() = bus.receiveAsFlow() operator fun invoke() = bus.receiveAsFlow()
fun request(value: DetailedTransactionData) = fun requestFromTransactionDetail(value: DetailedTransactionData) =
scope.launch { scope.launch {
bus.send( bus.send(
PrefillSendData.All( PrefillSendData.All(
@ -27,10 +29,20 @@ class PrefillSendUseCase {
) )
} }
fun request(value: PrefillSendData) = fun requestFromZip321(value: PaymentRequest) =
scope.launch { scope.launch {
bus.send(value) val request = value.payments.firstOrNull()
bus.send(
PrefillSendData.All(
amount = request?.nonNegativeAmount?.value?.convertZecToZatoshi() ?: Zatoshi(0),
address = request?.recipientAddress?.value,
fee = null,
memos = request?.message?.let { listOf(it) }
)
)
} }
fun request(value: PrefillSendData) = scope.launch { bus.send(value) }
} }
sealed interface PrefillSendData { sealed interface PrefillSendData {

View File

@ -8,7 +8,7 @@ class SendTransactionAgainUseCase(
private val navigationRouter: NavigationRouter private val navigationRouter: NavigationRouter
) { ) {
operator fun invoke(value: DetailedTransactionData) { operator fun invoke(value: DetailedTransactionData) {
prefillSendUseCase.request(value) prefillSendUseCase.requestFromTransactionDetail(value)
navigationRouter.forward( navigationRouter.forward(
Send( Send(
isScanZip321Enabled = false isScanZip321Enabled = false

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.offset
@ -15,6 +14,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex import androidx.compose.ui.zIndex
@ -128,7 +128,7 @@ private fun NavButtons(
modifier = modifier =
Modifier Modifier
.weight(1f) .weight(1f)
.aspectRatio(1.06f) .minHeight106Percent()
.testTag(HomeTags.RECEIVE), .testTag(HomeTags.RECEIVE),
state = state.firstButton, state = state.firstButton,
) )
@ -136,27 +136,41 @@ private fun NavButtons(
modifier = modifier =
Modifier Modifier
.weight(1f) .weight(1f)
.aspectRatio(1.06f) .minHeight106Percent()
.testTag(HomeTags.SEND), .testTag(HomeTags.SEND),
state = state.secondButton, state = state.secondButton,
) )
ZashiBigIconButton( ZashiBigIconButton(
modifier = modifier =
Modifier Modifier
.aspectRatio(1.06f) .minHeight106Percent()
.weight(1f), .weight(1f),
state = state.thirdButton, state = state.thirdButton,
) )
ZashiBigIconButton( ZashiBigIconButton(
modifier = modifier =
Modifier Modifier
.aspectRatio(1.06f) .minHeight106Percent()
.weight(1f), .weight(1f),
state = state.fourthButton, state = state.fourthButton,
) )
} }
} }
@Suppress("MagicNumber")
fun Modifier.minHeight106Percent(): Modifier =
layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
val minHeight = (placeable.width.toFloat() / (106f / 100f)).toInt()
val newConstraints = constraints.copy(minHeight = minHeight)
val newPlaceable = measurable.measure(newConstraints)
layout(newPlaceable.width, newPlaceable.height) {
newPlaceable.place(0, 0)
}
}
@PreviewScreens @PreviewScreens
@Composable @Composable
private fun Preview() { private fun Preview() {