[#1195] Integrate Current Balances widget to Send

- Closes #1195
- The fixture recipient address type changed from the unified to the sapling on several tests to avoid temporary address TODO text obtained from the SDK fixture
- WalletDisplayValues have the updateAvailable optional with false as a default value
- Changelog updated
This commit is contained in:
Honza Rychnovský 2024-01-26 12:44:46 +01:00 committed by GitHub
parent 1944916606
commit 7e27bdddff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 82 additions and 45 deletions

View File

@ -12,6 +12,7 @@ directly impact users rather than highlighting other key architectural updates.*
### Added ### Added
- The current balance UI on top of the Account screen has been reworked. It now displays the currently available - The current balance UI on top of the Account screen has been reworked. It now displays the currently available
balance as well. balance as well.
- The same current balance UI was also incorporated into the Send Form screen.
## [0.2.0 (530)] - 2024-01-16 ## [0.2.0 (530)] - 2024-01-16

View File

@ -7,7 +7,7 @@ import cash.z.ecc.android.sdk.model.Zatoshi
import cash.z.ecc.android.sdk.model.ZecSend import cash.z.ecc.android.sdk.model.ZecSend
object ZecSendFixture { object ZecSendFixture {
const val ADDRESS: String = WalletAddressFixture.UNIFIED_ADDRESS_STRING const val ADDRESS: String = WalletAddressFixture.SAPLING_ADDRESS_STRING
@Suppress("MagicNumber") @Suppress("MagicNumber")
val AMOUNT = Zatoshi(123) val AMOUNT = Zatoshi(123)

View File

@ -52,7 +52,8 @@ internal fun ComposeContentTestRule.setAmount(amount: String) {
internal fun ComposeContentTestRule.setValidAddress() { internal fun ComposeContentTestRule.setValidAddress() {
onNodeWithText(getStringResource(R.string.send_to)).also { onNodeWithText(getStringResource(R.string.send_to)).also {
it.performTextClearance() it.performTextClearance()
it.performTextInput(WalletAddressFixture.UNIFIED_ADDRESS_STRING) // Using sapling address here, as the unified is not available in the fixture. This will change.
it.performTextInput(WalletAddressFixture.SAPLING_ADDRESS_STRING)
} }
} }

View File

@ -5,10 +5,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.ComposeContentTestRule
import cash.z.ecc.android.sdk.model.WalletBalance
import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.Zatoshi
import cash.z.ecc.android.sdk.model.ZecSend import cash.z.ecc.android.sdk.model.ZecSend
import cash.z.ecc.sdk.fixture.ZatoshiFixture
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
import co.electriccoin.zcash.ui.screen.send.ext.Saver import co.electriccoin.zcash.ui.screen.send.ext.Saver
import co.electriccoin.zcash.ui.screen.send.model.SendArgumentsWrapper import co.electriccoin.zcash.ui.screen.send.model.SendArgumentsWrapper
import co.electriccoin.zcash.ui.screen.send.model.SendStage import co.electriccoin.zcash.ui.screen.send.model.SendStage
@ -96,13 +97,24 @@ class SendViewTestSetup(
ZcashTheme { ZcashTheme {
Send( Send(
mySpendableBalance = ZatoshiFixture.new(Zatoshi.MAX_INCLUSIVE), walletSnapshot =
WalletSnapshotFixture.new(
saplingBalance =
WalletBalance(
total = Zatoshi(Zatoshi.MAX_INCLUSIVE.div(100)),
available = Zatoshi(Zatoshi.MAX_INCLUSIVE.div(100))
)
),
sendStage = sendStage, sendStage = sendStage,
sendArgumentsWrapper = initialSendArgumentWrapper, sendArgumentsWrapper = initialSendArgumentWrapper,
onSendStageChange = setSendStage, onSendStageChange = setSendStage,
zecSend = zecSend, zecSend = zecSend,
onZecSendChange = setZecSend, onZecSendChange = setZecSend,
onBack = onBackAction, onBack = onBackAction,
goBalances = {
// TODO [#1194]: Cover Current balances UI widget with tests
// TODO [#1194]: https://github.com/Electric-Coin-Company/zashi-android/issues/1194
},
onSettings = { onSettingsCount.incrementAndGet() }, onSettings = { onSettingsCount.incrementAndGet() },
onCreateAndSend = { onCreateAndSend = {
onCreateCount.incrementAndGet() onCreateCount.incrementAndGet()

View File

@ -6,12 +6,13 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.test.filters.MediumTest import androidx.test.filters.MediumTest
import cash.z.ecc.android.sdk.fixture.WalletFixture import cash.z.ecc.android.sdk.fixture.WalletFixture
import cash.z.ecc.android.sdk.model.WalletBalance
import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.Zatoshi
import cash.z.ecc.android.sdk.model.ZcashNetwork import cash.z.ecc.android.sdk.model.ZcashNetwork
import cash.z.ecc.sdk.fixture.ZatoshiFixture
import cash.z.ecc.sdk.fixture.ZecSendFixture import cash.z.ecc.sdk.fixture.ZecSendFixture
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.fixture.MockSynchronizer import co.electriccoin.zcash.ui.fixture.MockSynchronizer
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
import co.electriccoin.zcash.ui.screen.send.WrapSend import co.electriccoin.zcash.ui.screen.send.WrapSend
import co.electriccoin.zcash.ui.screen.send.assertOnConfirmation import co.electriccoin.zcash.ui.screen.send.assertOnConfirmation
import co.electriccoin.zcash.ui.screen.send.assertOnForm import co.electriccoin.zcash.ui.screen.send.assertOnForm
@ -39,7 +40,14 @@ class SendViewIntegrationTest {
) )
} }
private val synchronizer = MockSynchronizer.new() private val synchronizer = MockSynchronizer.new()
private val balance = ZatoshiFixture.new(Zatoshi.MAX_INCLUSIVE) private val walletSnapshot =
WalletSnapshotFixture.new(
saplingBalance =
WalletBalance(
total = Zatoshi(Zatoshi.MAX_INCLUSIVE.div(100)),
available = Zatoshi(Zatoshi.MAX_INCLUSIVE.div(100))
)
)
@Test @Test
@MediumTest @MediumTest
@ -54,10 +62,11 @@ class SendViewIntegrationTest {
WrapSend( WrapSend(
sendArgumentsWrapper = null, sendArgumentsWrapper = null,
synchronizer = synchronizer, synchronizer = synchronizer,
spendableBalance = balance, walletSnapshot = walletSnapshot,
spendingKey = spendingKey, spendingKey = spendingKey,
goToQrScanner = {}, goToQrScanner = {},
goBack = {}, goBack = {},
goBalances = {},
hasCameraFeature = true, hasCameraFeature = true,
goSettings = {} goSettings = {}
) )

View File

@ -107,7 +107,7 @@ class SendViewTest : UiTestPrerequisites() {
launch { launch {
testSetup.getLastZecSend().also { testSetup.getLastZecSend().also {
assertNotNull(it) assertNotNull(it)
assertEquals(WalletAddressFixture.unified(), it.destination) assertEquals(WalletAddressFixture.sapling(), it.destination)
assertEquals(Zatoshi(12345678900000), it.amount) assertEquals(Zatoshi(12345678900000), it.amount)
assertEquals(ZecRequestFixture.MESSAGE.value, it.memo.value) assertEquals(ZecRequestFixture.MESSAGE.value, it.memo.value)
} }
@ -143,7 +143,7 @@ class SendViewTest : UiTestPrerequisites() {
launch { launch {
testSetup.getLastZecSend().also { testSetup.getLastZecSend().also {
assertNotNull(it) assertNotNull(it)
assertEquals(WalletAddressFixture.unified(), it.destination) assertEquals(WalletAddressFixture.sapling(), it.destination)
assertEquals(Zatoshi(12345678900000), it.amount) assertEquals(Zatoshi(12345678900000), it.amount)
assertEquals(ZecRequestFixture.MESSAGE.value, it.memo.value) assertEquals(ZecRequestFixture.MESSAGE.value, it.memo.value)
} }
@ -201,7 +201,7 @@ class SendViewTest : UiTestPrerequisites() {
launch { launch {
testSetup.getLastZecSend().also { testSetup.getLastZecSend().also {
assertNotNull(it) assertNotNull(it)
assertEquals(WalletAddressFixture.unified(), it.destination) assertEquals(WalletAddressFixture.sapling(), it.destination)
assertEquals(Zatoshi(12345678900000), it.amount) assertEquals(Zatoshi(12345678900000), it.amount)
assertEquals(ZecRequestFixture.MESSAGE.value, it.memo.value) assertEquals(ZecRequestFixture.MESSAGE.value, it.memo.value)
} }
@ -280,7 +280,7 @@ class SendViewTest : UiTestPrerequisites() {
launch { launch {
testSetup.getLastZecSend().also { testSetup.getLastZecSend().also {
assertNotNull(it) assertNotNull(it)
assertEquals(WalletAddressFixture.unified(), it.destination) assertEquals(WalletAddressFixture.sapling(), it.destination)
assertEquals(Zatoshi(12345600000), it.amount) assertEquals(Zatoshi(12345600000), it.amount)
assertTrue(it.memo.value.isEmpty()) assertTrue(it.memo.value.isEmpty())
} }

View File

@ -27,7 +27,7 @@ data class WalletDisplayValues(
internal fun getNextValues( internal fun getNextValues(
context: Context, context: Context,
walletSnapshot: WalletSnapshot, walletSnapshot: WalletSnapshot,
updateAvailable: Boolean updateAvailable: Boolean = false
): WalletDisplayValues { ): WalletDisplayValues {
var progress = PercentDecimal.ZERO_PERCENT var progress = PercentDecimal.ZERO_PERCENT
val zecAmountText = walletSnapshot.totalBalance().toZecString() val zecAmountText = walletSnapshot.totalBalance().toZecString()

View File

@ -166,8 +166,6 @@ private fun Status(
.testTag(AccountTag.STATUS_VIEWS), .testTag(AccountTag.STATUS_VIEWS),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault))
if (walletDisplayValues.zecAmountText.isNotEmpty()) { if (walletDisplayValues.zecAmountText.isNotEmpty()) {
BalanceWidget( BalanceWidget(
walletSnapshot = walletSnapshot, walletSnapshot = walletSnapshot,

View File

@ -102,6 +102,7 @@ internal fun WrapHome(
activity = activity, activity = activity,
goToQrScanner = goScan, goToQrScanner = goScan,
goBack = homeGoBack, goBack = homeGoBack,
goBalances = { forceHomePageIndexFlow.tryEmit(ForcePage(HomeScreenIndex.BALANCES)) },
goSettings = goSettings, goSettings = goSettings,
sendArgumentsWrapper = sendArgumentsWrapper sendArgumentsWrapper = sendArgumentsWrapper
) )

View File

@ -14,11 +14,10 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.Synchronizer
import cash.z.ecc.android.sdk.model.UnifiedSpendingKey import cash.z.ecc.android.sdk.model.UnifiedSpendingKey
import cash.z.ecc.android.sdk.model.Zatoshi
import cash.z.ecc.android.sdk.model.ZecSend import cash.z.ecc.android.sdk.model.ZecSend
import cash.z.ecc.sdk.extension.send import cash.z.ecc.sdk.extension.send
import co.electriccoin.zcash.spackle.Twig import co.electriccoin.zcash.spackle.Twig
import co.electriccoin.zcash.ui.common.model.spendableBalance import co.electriccoin.zcash.ui.common.model.WalletSnapshot
import co.electriccoin.zcash.ui.common.viewmodel.WalletViewModel import co.electriccoin.zcash.ui.common.viewmodel.WalletViewModel
import co.electriccoin.zcash.ui.design.component.CircularScreenProgressIndicator import co.electriccoin.zcash.ui.design.component.CircularScreenProgressIndicator
import co.electriccoin.zcash.ui.screen.send.ext.Saver import co.electriccoin.zcash.ui.screen.send.ext.Saver
@ -28,11 +27,13 @@ import co.electriccoin.zcash.ui.screen.send.view.Send
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@Composable @Composable
@Suppress("LongParameterList")
internal fun WrapSend( internal fun WrapSend(
activity: ComponentActivity, activity: ComponentActivity,
sendArgumentsWrapper: SendArgumentsWrapper?, sendArgumentsWrapper: SendArgumentsWrapper?,
goToQrScanner: () -> Unit, goToQrScanner: () -> Unit,
goBack: () -> Unit, goBack: () -> Unit,
goBalances: () -> Unit,
goSettings: () -> Unit, goSettings: () -> Unit,
) { ) {
val hasCameraFeature = activity.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY) val hasCameraFeature = activity.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)
@ -41,17 +42,18 @@ internal fun WrapSend(
val synchronizer = walletViewModel.synchronizer.collectAsStateWithLifecycle().value val synchronizer = walletViewModel.synchronizer.collectAsStateWithLifecycle().value
val spendableBalance = walletViewModel.walletSnapshot.collectAsStateWithLifecycle().value?.spendableBalance() val walletSnapshot = walletViewModel.walletSnapshot.collectAsStateWithLifecycle().value
val spendingKey = walletViewModel.spendingKey.collectAsStateWithLifecycle().value val spendingKey = walletViewModel.spendingKey.collectAsStateWithLifecycle().value
WrapSend( WrapSend(
sendArgumentsWrapper, sendArgumentsWrapper,
synchronizer, synchronizer,
spendableBalance, walletSnapshot,
spendingKey, spendingKey,
goToQrScanner, goToQrScanner,
goBack, goBack,
goBalances,
goSettings, goSettings,
hasCameraFeature hasCameraFeature
) )
@ -63,10 +65,11 @@ internal fun WrapSend(
internal fun WrapSend( internal fun WrapSend(
sendArgumentsWrapper: SendArgumentsWrapper?, sendArgumentsWrapper: SendArgumentsWrapper?,
synchronizer: Synchronizer?, synchronizer: Synchronizer?,
spendableBalance: Zatoshi?, walletSnapshot: WalletSnapshot?,
spendingKey: UnifiedSpendingKey?, spendingKey: UnifiedSpendingKey?,
goToQrScanner: () -> Unit, goToQrScanner: () -> Unit,
goBack: () -> Unit, goBack: () -> Unit,
goBalances: () -> Unit,
goSettings: () -> Unit, goSettings: () -> Unit,
hasCameraFeature: Boolean hasCameraFeature: Boolean
) { ) {
@ -99,14 +102,14 @@ internal fun WrapSend(
onBackAction() onBackAction()
} }
if (null == synchronizer || null == spendableBalance || null == spendingKey) { if (null == synchronizer || null == walletSnapshot || null == spendingKey) {
// TODO [#1146]: Consider moving CircularScreenProgressIndicator from Android layer to View layer // TODO [#1146]: Consider moving CircularScreenProgressIndicator from Android layer to View layer
// TODO [#1146]: Improve this by allowing screen composition and updating it after the data is available // TODO [#1146]: Improve this by allowing screen composition and updating it after the data is available
// TODO [#1146]: https://github.com/Electric-Coin-Company/zashi-android/issues/1146 // TODO [#1146]: https://github.com/Electric-Coin-Company/zashi-android/issues/1146
CircularScreenProgressIndicator() CircularScreenProgressIndicator()
} else { } else {
Send( Send(
mySpendableBalance = spendableBalance, walletSnapshot = walletSnapshot,
sendArgumentsWrapper = sendArgumentsWrapper, sendArgumentsWrapper = sendArgumentsWrapper,
sendStage = sendStage, sendStage = sendStage,
onSendStageChange = setSendStage, onSendStageChange = setSendStage,
@ -129,6 +132,7 @@ internal fun WrapSend(
} }
}, },
onQrScannerOpen = goToQrScanner, onQrScannerOpen = goToQrScanner,
goBalances = goBalances,
hasCameraFeature = hasCameraFeature hasCameraFeature = hasCameraFeature
) )
} }

View File

@ -7,10 +7,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
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.imePadding
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
@ -55,6 +53,9 @@ import cash.z.ecc.sdk.fixture.MemoFixture
import cash.z.ecc.sdk.fixture.ZatoshiFixture import cash.z.ecc.sdk.fixture.ZatoshiFixture
import co.electriccoin.zcash.spackle.Twig import co.electriccoin.zcash.spackle.Twig
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.BalanceWidget
import co.electriccoin.zcash.ui.common.model.WalletSnapshot
import co.electriccoin.zcash.ui.common.model.spendableBalance
import co.electriccoin.zcash.ui.common.test.CommonTag import co.electriccoin.zcash.ui.common.test.CommonTag
import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT
import co.electriccoin.zcash.ui.design.component.Body import co.electriccoin.zcash.ui.design.component.Body
@ -65,6 +66,8 @@ import co.electriccoin.zcash.ui.design.component.PrimaryButton
import co.electriccoin.zcash.ui.design.component.SmallTopAppBar import co.electriccoin.zcash.ui.design.component.SmallTopAppBar
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.theme.ZcashTheme.dimens import co.electriccoin.zcash.ui.design.theme.ZcashTheme.dimens
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
import co.electriccoin.zcash.ui.screen.account.model.WalletDisplayValues
import co.electriccoin.zcash.ui.screen.send.SendTag import co.electriccoin.zcash.ui.screen.send.SendTag
import co.electriccoin.zcash.ui.screen.send.ext.ABBREVIATION_INDEX import co.electriccoin.zcash.ui.screen.send.ext.ABBREVIATION_INDEX
import co.electriccoin.zcash.ui.screen.send.ext.abbreviated import co.electriccoin.zcash.ui.screen.send.ext.abbreviated
@ -80,7 +83,7 @@ private fun PreviewSendForm() {
ZcashTheme(forceDarkMode = false) { ZcashTheme(forceDarkMode = false) {
GradientSurface { GradientSurface {
Send( Send(
mySpendableBalance = ZatoshiFixture.new(), walletSnapshot = WalletSnapshotFixture.new(),
sendArgumentsWrapper = null, sendArgumentsWrapper = null,
sendStage = SendStage.Form, sendStage = SendStage.Form,
onSendStageChange = {}, onSendStageChange = {},
@ -90,6 +93,7 @@ private fun PreviewSendForm() {
onQrScannerOpen = {}, onQrScannerOpen = {},
onBack = {}, onBack = {},
onSettings = {}, onSettings = {},
goBalances = {},
hasCameraFeature = true hasCameraFeature = true
) )
} }
@ -153,7 +157,7 @@ private fun PreviewSendConfirmation() {
@Suppress("LongParameterList") @Suppress("LongParameterList")
@Composable @Composable
fun Send( fun Send(
mySpendableBalance: Zatoshi, walletSnapshot: WalletSnapshot,
sendArgumentsWrapper: SendArgumentsWrapper?, sendArgumentsWrapper: SendArgumentsWrapper?,
sendStage: SendStage, sendStage: SendStage,
onSendStageChange: (SendStage) -> Unit, onSendStageChange: (SendStage) -> Unit,
@ -163,6 +167,7 @@ fun Send(
onSettings: () -> Unit, onSettings: () -> Unit,
onCreateAndSend: (ZecSend) -> Unit, onCreateAndSend: (ZecSend) -> Unit,
onQrScannerOpen: () -> Unit, onQrScannerOpen: () -> Unit,
goBalances: () -> Unit,
hasCameraFeature: Boolean hasCameraFeature: Boolean
) { ) {
Scaffold(topBar = { Scaffold(topBar = {
@ -173,7 +178,7 @@ fun Send(
) )
}) { paddingValues -> }) { paddingValues ->
SendMainContent( SendMainContent(
myBalance = mySpendableBalance, walletSnapshot = walletSnapshot,
sendArgumentsWrapper = sendArgumentsWrapper, sendArgumentsWrapper = sendArgumentsWrapper,
onBack = onBack, onBack = onBack,
sendStage = sendStage, sendStage = sendStage,
@ -182,6 +187,7 @@ fun Send(
onZecSendChange = onZecSendChange, onZecSendChange = onZecSendChange,
onSendSubmit = onCreateAndSend, onSendSubmit = onCreateAndSend,
onQrScannerOpen = onQrScannerOpen, onQrScannerOpen = onQrScannerOpen,
goBalances = goBalances,
hasCameraFeature = hasCameraFeature, hasCameraFeature = hasCameraFeature,
modifier = modifier =
Modifier Modifier
@ -228,7 +234,7 @@ private fun SendTopAppBar(
@Suppress("LongParameterList") @Suppress("LongParameterList")
@Composable @Composable
private fun SendMainContent( private fun SendMainContent(
myBalance: Zatoshi, walletSnapshot: WalletSnapshot,
sendArgumentsWrapper: SendArgumentsWrapper?, sendArgumentsWrapper: SendArgumentsWrapper?,
zecSend: ZecSend?, zecSend: ZecSend?,
onZecSendChange: (ZecSend) -> Unit, onZecSendChange: (ZecSend) -> Unit,
@ -237,13 +243,14 @@ private fun SendMainContent(
onSendStageChange: (SendStage) -> Unit, onSendStageChange: (SendStage) -> Unit,
onSendSubmit: (ZecSend) -> Unit, onSendSubmit: (ZecSend) -> Unit,
onQrScannerOpen: () -> Unit, onQrScannerOpen: () -> Unit,
goBalances: () -> Unit,
hasCameraFeature: Boolean, hasCameraFeature: Boolean,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
when { when {
(sendStage == SendStage.Form || null == zecSend) -> { (sendStage == SendStage.Form || null == zecSend) -> {
SendForm( SendForm(
myBalance = myBalance, walletSnapshot = walletSnapshot,
sendArgumentsWrapper = sendArgumentsWrapper, sendArgumentsWrapper = sendArgumentsWrapper,
previousZecSend = zecSend, previousZecSend = zecSend,
onCreateZecSend = { onCreateZecSend = {
@ -251,6 +258,7 @@ private fun SendMainContent(
onZecSendChange(it) onZecSendChange(it)
}, },
onQrScannerOpen = onQrScannerOpen, onQrScannerOpen = onQrScannerOpen,
goBalances = goBalances,
hasCameraFeature = hasCameraFeature, hasCameraFeature = hasCameraFeature,
modifier = modifier modifier = modifier
) )
@ -296,11 +304,12 @@ private fun SendMainContent(
@Suppress("LongMethod", "LongParameterList", "CyclomaticComplexMethod") @Suppress("LongMethod", "LongParameterList", "CyclomaticComplexMethod")
@Composable @Composable
private fun SendForm( private fun SendForm(
myBalance: Zatoshi, walletSnapshot: WalletSnapshot,
sendArgumentsWrapper: SendArgumentsWrapper?, sendArgumentsWrapper: SendArgumentsWrapper?,
previousZecSend: ZecSend?, previousZecSend: ZecSend?,
onCreateZecSend: (ZecSend) -> Unit, onCreateZecSend: (ZecSend) -> Unit,
onQrScannerOpen: () -> Unit, onQrScannerOpen: () -> Unit,
goBalances: () -> Unit,
hasCameraFeature: Boolean, hasCameraFeature: Boolean,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
@ -340,24 +349,28 @@ private fun SendForm(
Column( Column(
modifier = modifier =
Modifier Modifier
.imePadding() .fillMaxHeight()
.fillMaxSize()
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState())
.then(modifier), .then(modifier),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Header( val walletDisplayValues =
text = stringResource(id = R.string.send_balance, myBalance.toZecString()), WalletDisplayValues.getNextValues(
textAlign = TextAlign.Center, context = LocalContext.current,
modifier = Modifier.fillMaxWidth() walletSnapshot = walletSnapshot
) )
Body(
text = stringResource(id = R.string.send_balance_subtitle),
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(dimens.spacingLarge)) Spacer(modifier = Modifier.height(dimens.spacingDefault))
if (walletDisplayValues.zecAmountText.isNotEmpty()) {
BalanceWidget(
walletSnapshot = walletSnapshot,
isReferenceToBalances = true,
onReferenceClick = goBalances
)
}
Spacer(modifier = Modifier.height(dimens.spacingXlarge))
FormTextField( FormTextField(
value = recipientAddressString, value = recipientAddressString,
@ -487,7 +500,7 @@ private fun SendForm(
val sendButtonEnabled = val sendButtonEnabled =
amountZecString.isNotBlank() && amountZecString.isNotBlank() &&
sendValueCheck > 0L && sendValueCheck > 0L &&
myBalance.value >= (sendValueCheck + ZcashSdk.MINERS_FEE.value) && walletSnapshot.spendableBalance().value >= (sendValueCheck + ZcashSdk.MINERS_FEE.value) &&
recipientAddressString.length > ABBREVIATION_INDEX recipientAddressString.length > ABBREVIATION_INDEX
PrimaryButton( PrimaryButton(

View File

@ -3,8 +3,6 @@
<string name="send_back">Back</string> <string name="send_back">Back</string>
<string name="send_back_content_description">Back</string> <string name="send_back_content_description">Back</string>
<string name="send_scan_content_description">Scan</string> <string name="send_scan_content_description">Scan</string>
<string name="send_balance" formatted="true"><xliff:g id="balance" example="12.345">%1$s</xliff:g> ZEC Available</string>
<string name="send_balance_subtitle">Additional funds may be in transit.</string>
<string name="send_to">Who would you like to send ZEC to?</string> <string name="send_to">Who would you like to send ZEC to?</string>
<string name="send_amount">How much?</string> <string name="send_amount">How much?</string>
<string name="send_memo">Memo</string> <string name="send_memo">Memo</string>