Skip to content

Commit

Permalink
Update UtxoExpertMode page
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Jun 18, 2024
1 parent 54a94ef commit 9c6b09b
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ fun SendBitcoinNavHost(
UtxoExpertModeScreen(
adapter = viewModel.adapter,
token = viewModel.wallet.token,
address = viewModel.uiState.address,
memo = viewModel.uiState.memo,
value = viewModel.uiState.amount,
feeRate = viewModel.uiState.feeRate,
customUnspentOutputs = viewModel.customUnspentOutputs,
updateUnspentOutputs = {
viewModel.updateCustomUnspentOutputs(it)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package io.horizontalsystems.bankwallet.modules.send.bitcoin.utxoexpert

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Divider
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -21,33 +24,26 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.ISendBitcoinAdapter
import io.horizontalsystems.bankwallet.core.shorten
import io.horizontalsystems.bankwallet.entities.Address
import io.horizontalsystems.bankwallet.modules.evmfee.ButtonsGroupWithShade
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryYellow
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonSecondaryTransparent
import io.horizontalsystems.bankwallet.ui.compose.components.CellUniversalLawrenceSection
import io.horizontalsystems.bankwallet.ui.compose.components.HSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton
import io.horizontalsystems.bankwallet.ui.compose.components.HsCheckbox
import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal
import io.horizontalsystems.bankwallet.ui.compose.components.SectionItemBorderedRowUniversalClear
import io.horizontalsystems.bankwallet.ui.compose.components.SectionUniversalItem
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_leah
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_lucian
import io.horizontalsystems.bitcoincore.storage.UnspentOutputInfo
import io.horizontalsystems.marketkit.models.Token
import java.math.BigDecimal

@Composable
fun UtxoExpertModeScreen(
adapter: ISendBitcoinAdapter,
token: Token,
address: Address?,
memo: String?,
value: BigDecimal?,
feeRate: Int?,
customUnspentOutputs: List<UnspentOutputInfo>?,
updateUnspentOutputs: (List<UnspentOutputInfo>) -> Unit,
onBackClick: () -> Unit
Expand All @@ -57,10 +53,6 @@ fun UtxoExpertModeScreen(
factory = UtxoExpertModeModule.Factory(
adapter,
token,
address,
memo,
value,
feeRate,
customUnspentOutputs
)
)
Expand All @@ -83,13 +75,11 @@ fun UtxoExpertModeScreen(
.padding(it)
.fillMaxSize()
) {
Column(
modifier = Modifier.background(ComposeAppTheme.colors.lawrence)
) {
UtxoInfoSection(
uiState.sendToInfo,
uiState.changeInfo,
uiState.feeInfo,
CellUniversalLawrenceSection {
UtxoInfoCell(
title = stringResource(R.string.Send_Utxo_AvailableBalance),
value = uiState.availableBalanceInfo.value,
subValue = uiState.availableBalanceInfo.subValue
)
}
Box(
Expand All @@ -103,14 +93,39 @@ fun UtxoExpertModeScreen(
}
)
}
ButtonsGroupWithShade {
ButtonPrimaryYellow(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp),
title = stringResource(R.string.Button_Done),
onClick = onBackClick,
Box(
modifier = Modifier
.height(62.dp)
.fillMaxWidth()
){
Divider(
modifier = Modifier.fillMaxWidth(),
thickness = 1.dp,
color = ComposeAppTheme.colors.steel10
)
Row(
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxSize(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
ButtonSecondaryTransparent(
title = stringResource(id = R.string.Send_Utxo_UnselectAll),
enabled = uiState.unselectAllIsEnabled,
onClick = {
viewModel.unselectAll()
updateUnspentOutputs(viewModel.customOutputs)
}
)
ButtonSecondaryTransparent(
title = stringResource(id = R.string.Send_Utxo_SelectAll),
onClick = {
viewModel.selectAll()
updateUnspentOutputs(viewModel.customOutputs)
}
)
}
}
}
}
Expand Down Expand Up @@ -150,53 +165,9 @@ private fun UtxoList(
}
}

@Composable
private fun UtxoInfoSection(
sendToInfo: UtxoExpertModeModule.InfoItem,
changeInfo: UtxoExpertModeModule.InfoItem?,
feeInfo: UtxoExpertModeModule.InfoItem
) {
val infoItems = buildList<@Composable () -> Unit> {
add {
UtxoInfoCell(
title = stringResource(R.string.Send_Utxo_SendTo),
subtitle = sendToInfo.subTitle,
value = sendToInfo.value,
subValue = sendToInfo.subValue
)
}
changeInfo?.let {
add {
UtxoInfoCell(
title = stringResource(R.string.Send_Utxo_Change),
subtitle = changeInfo.subTitle,
value = changeInfo.value,
subValue = changeInfo.subValue
)
}
}
add {
UtxoInfoCell(
title = stringResource(R.string.Send_Fee),
subtitle = feeInfo.subTitle,
value = feeInfo.value,
subValue = feeInfo.subValue
)
}
}
infoItems.forEachIndexed { index, composable ->
SectionUniversalItem(
borderTop = index != 0,
) {
composable()
}
}
}

@Composable
private fun UtxoInfoCell(
title: String,
subtitle: String?,
value: String?,
subValue: String?
) {
Expand All @@ -211,9 +182,6 @@ private fun UtxoInfoCell(
modifier = Modifier.weight(1f)
) {
subhead2_leah(text = title)
subtitle?.let {
subhead2_grey(text = it)
}
}
Column(
horizontalAlignment = Alignment.End
Expand Down
Loading

0 comments on commit 9c6b09b

Please sign in to comment.