Code cleanup
This commit is contained in:
parent
8c6d873d04
commit
463b16e349
|
@ -32,18 +32,20 @@ fun ZashiBigIconButton(
|
|||
) {
|
||||
Surface(
|
||||
modifier =
|
||||
modifier
|
||||
modifier,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
color = ZashiColors.Surfaces.bgSecondary
|
||||
) {
|
||||
Column(
|
||||
modifier =
|
||||
Modifier
|
||||
.clickable(
|
||||
indication = ripple(),
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
onClick = state.onClick,
|
||||
role = Role.Button,
|
||||
),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
color = ZashiColors.Surfaces.bgSecondary
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
)
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Icon(
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package co.electriccoin.zcash.ui.fixture
|
||||
|
||||
import cash.z.ecc.android.sdk.fixture.WalletFixture
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.type.AddressType
|
||||
import co.electriccoin.zcash.ui.common.model.SerializableAddress
|
||||
import co.electriccoin.zcash.ui.screen.send.Send
|
||||
|
||||
internal object SendArgumentsWrapperFixture {
|
||||
val RECIPIENT_ADDRESS =
|
||||
SerializableAddress(
|
||||
address = WalletFixture.Alice.getAddresses(ZcashNetwork.Testnet).unified,
|
||||
type = AddressType.Unified
|
||||
)
|
||||
|
||||
fun new(recipientAddress: SerializableAddress? = RECIPIENT_ADDRESS) =
|
||||
Send(
|
||||
recipientAddress = recipientAddress?.toRecipient(),
|
||||
)
|
||||
}
|
|
@ -9,15 +9,16 @@ import androidx.compose.ui.test.onNodeWithText
|
|||
import androidx.test.filters.MediumTest
|
||||
import cash.z.ecc.android.sdk.ext.collectWith
|
||||
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
|
||||
import cash.z.ecc.android.sdk.fixture.WalletFixture
|
||||
import cash.z.ecc.android.sdk.model.Memo
|
||||
import cash.z.ecc.android.sdk.model.MonetarySeparators
|
||||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.ZecSend
|
||||
import cash.z.ecc.sdk.fixture.ZecRequestFixture
|
||||
import cash.z.ecc.sdk.fixture.ZecSendFixture
|
||||
import co.electriccoin.zcash.test.UiTestPrerequisites
|
||||
import co.electriccoin.zcash.ui.R
|
||||
import co.electriccoin.zcash.ui.fixture.SendArgumentsWrapperFixture
|
||||
import co.electriccoin.zcash.ui.screen.send.SendTag
|
||||
import co.electriccoin.zcash.ui.screen.send.SendViewTestSetup
|
||||
import co.electriccoin.zcash.ui.screen.send.assertOnForm
|
||||
|
@ -379,7 +380,7 @@ class SendViewTest : UiTestPrerequisites() {
|
|||
composeTestRule.onNodeWithText(getStringResource(R.string.send_address_hint)).also {
|
||||
it.assertTextEquals(
|
||||
getStringResource(R.string.send_address_hint),
|
||||
SendArgumentsWrapperFixture.RECIPIENT_ADDRESS.address,
|
||||
WalletFixture.Alice.getAddresses(ZcashNetwork.Testnet).unified,
|
||||
includeEditableText = true
|
||||
)
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ fun ZashiTopAppBarWithAccountSelection(
|
|||
windowInsets = WindowInsets.systemBars.only(WindowInsetsSides.Top),
|
||||
hamburgerMenuActions = {
|
||||
if (showHideBalances) {
|
||||
Crossfade(state.balanceVisibilityButton, label = "") {
|
||||
Crossfade(state.balanceVisibilityButton, label = "BalanceVisibility") {
|
||||
ZashiIconButton(it, modifier = Modifier.size(40.dp))
|
||||
}
|
||||
Spacer(Modifier.width(4.dp))
|
||||
|
|
|
@ -35,7 +35,7 @@ fun ZashiTopAppbar(
|
|||
},
|
||||
regularActions = {
|
||||
if (state?.balanceVisibilityButton != null && showHideBalances) {
|
||||
Crossfade(state.balanceVisibilityButton, label = "") {
|
||||
Crossfade(state.balanceVisibilityButton, label = "BalanceVisibility") {
|
||||
ZashiIconButton(it, modifier = Modifier.size(40.dp))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package co.electriccoin.zcash.ui.common.model
|
||||
|
||||
import cash.z.ecc.android.sdk.model.WalletAddress
|
||||
import cash.z.ecc.android.sdk.type.AddressType
|
||||
import co.electriccoin.zcash.ui.common.extension.AddressTypeAsStringSerializer
|
||||
import co.electriccoin.zcash.ui.screen.send.model.RecipientAddressState
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class SerializableAddress(
|
||||
val address: String,
|
||||
@Serializable(with = AddressTypeAsStringSerializer::class)
|
||||
val type: AddressType
|
||||
) {
|
||||
init {
|
||||
// Basic validation to support the class properties type-safeness
|
||||
require(address.isNotEmpty()) {
|
||||
"Address parameter $address can not be empty"
|
||||
}
|
||||
}
|
||||
|
||||
internal fun toRecipient() = RecipientAddressState(address, type)
|
||||
|
||||
// Calling the conversion inside the blocking coroutine is ok, as we do not expect it to be time-consuming
|
||||
internal fun toWalletAddress() =
|
||||
runBlocking {
|
||||
when (type) {
|
||||
AddressType.Unified -> WalletAddress.Unified.new(address)
|
||||
AddressType.Shielded -> WalletAddress.Sapling.new(address)
|
||||
AddressType.Transparent -> WalletAddress.Transparent.new(address)
|
||||
AddressType.Tex -> WalletAddress.Tex.new(address)
|
||||
is AddressType.Invalid -> error("Invalid address type")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue