Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions app/src/main/java/to/bitkit/ui/ContentView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ import to.bitkit.ui.screens.transfer.TransferIntroScreen
import to.bitkit.ui.screens.transfer.external.ExternalAmountScreen
import to.bitkit.ui.screens.transfer.external.ExternalConfirmScreen
import to.bitkit.ui.screens.transfer.external.ExternalConnectionScreen
import to.bitkit.ui.screens.transfer.external.ExternalFeeCustomScreen
import to.bitkit.ui.screens.transfer.external.ExternalNodeViewModel
import to.bitkit.ui.screens.transfer.external.ExternalSuccessScreen
import to.bitkit.ui.screens.transfer.external.LnurlChannelScreen
Expand Down Expand Up @@ -735,7 +734,6 @@ private fun RootNavHost(
walletViewModel.refreshState()
navController.navigate(Routes.ExternalSuccess)
},
onNetworkFeeClick = { navController.navigate(Routes.ExternalFeeCustom) },
onBackClick = { navController.popBackStack() },
)
}
Expand All @@ -752,15 +750,6 @@ private fun RootNavHost(
onContinue = { navController.popBackStack<Routes.TransferRoot>(inclusive = true) },
)
}
composableWithDefaultTransitions<Routes.ExternalFeeCustom> {
val parentEntry = remember(it) { navController.getBackStackEntry(Routes.ExternalNav) }
val viewModel = hiltViewModel<ExternalNodeViewModel>(parentEntry)

ExternalFeeCustomScreen(
viewModel = viewModel,
onBack = { navController.popBackStack() },
)
}
}
}
}
Expand Down Expand Up @@ -1913,9 +1902,6 @@ sealed interface Routes {
@Serializable
data object ExternalSuccess : Routes

@Serializable
data object ExternalFeeCustom : Routes

@Serializable
data class LnurlChannel(val uri: String, val callback: String, val k1: String) : Routes

Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
package to.bitkit.ui.screens.transfer.external

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import to.bitkit.R
import to.bitkit.ui.components.Caption13Up
import to.bitkit.ui.components.Display
import to.bitkit.ui.components.FeeInfo
import to.bitkit.ui.components.MoneySSB
import to.bitkit.ui.components.SwipeToConfirm
import to.bitkit.ui.scaffold.AppTopBar
import to.bitkit.ui.scaffold.DrawerNavIcon
import to.bitkit.ui.scaffold.ScreenColumn
import to.bitkit.ui.screens.transfer.external.ExternalNodeContract.SideEffect
import to.bitkit.ui.shared.modifiers.clickableAlpha
import to.bitkit.ui.theme.AppThemeSurface
import to.bitkit.ui.theme.Colors
import to.bitkit.ui.utils.withAccent
Expand All @@ -50,7 +39,6 @@ import to.bitkit.ui.utils.withAccent
fun ExternalConfirmScreen(
viewModel: ExternalNodeViewModel,
onConfirm: () -> Unit,
onNetworkFeeClick: () -> Unit,
onBackClick: () -> Unit,
) {
val uiState by viewModel.uiState.collectAsState()
Expand All @@ -67,7 +55,6 @@ fun ExternalConfirmScreen(
Content(
uiState = uiState,
onConfirm = viewModel::onConfirm,
onNetworkFeeClick = onNetworkFeeClick,
onBackClick = onBackClick,
)
}
Expand All @@ -76,7 +63,6 @@ fun ExternalConfirmScreen(
private fun Content(
uiState: ExternalNodeContract.UiState,
onConfirm: () -> Unit = {},
onNetworkFeeClick: () -> Unit = {},
onBackClick: () -> Unit = {},
) {
ScreenColumn {
Expand All @@ -103,32 +89,10 @@ private fun Content(
horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier.height(IntrinsicSize.Min)
) {
Column(
modifier = Modifier
.fillMaxHeight()
.weight(1f)
.padding(top = 16.dp)
.clickableAlpha(onClick = onNetworkFeeClick)
.testTag("SetCustomFee")
) {
Caption13Up(
text = stringResource(R.string.lightning__spending_confirm__network_fee),
color = Colors.White64,
)
Spacer(modifier = Modifier.height(8.dp))

AnimatedVisibility(visible = networkFee > 0L, enter = fadeIn(), exit = fadeOut()) {
Row(verticalAlignment = Alignment.CenterVertically) {
MoneySSB(sats = networkFee)
Spacer(modifier = Modifier.width(4.dp))
Icon(
painterResource(R.drawable.ic_pencil_simple),
contentDescription = null,
modifier = Modifier.size(16.dp)
)
}
}
}
FeeInfo(
label = stringResource(R.string.lightning__spending_confirm__network_fee),
amount = networkFee,
)
FeeInfo(
label = stringResource(R.string.lightning__spending_confirm__lsp_fee),
amount = serviceFee,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import to.bitkit.ext.WatchResult
import to.bitkit.ext.of
import to.bitkit.ext.watchUntil
import to.bitkit.models.Toast
import to.bitkit.models.TransactionSpeed
import to.bitkit.models.TransferType
import to.bitkit.models.formatToModernDisplay
import to.bitkit.repositories.LightningRepo
Expand Down Expand Up @@ -118,34 +117,13 @@ class ExternalNodeViewModel @Inject constructor(
fun onAmountContinue() {
viewModelScope.launch {
val speed = settingsStore.data.first().defaultTransactionSpeed
val defaultSatsPerVbyte = lightningRepo.getFeeRateForSpeed(speed).getOrThrow().toUInt()
_uiState.update {
it.copy(
customFeeRate = defaultSatsPerVbyte,
networkFee = 0L,
)
}
updateNetworkFee()
}
}

fun onCustomFeeRateChange(feeRate: UInt) {
_uiState.update { it.copy(customFeeRate = feeRate) }
updateNetworkFee()
}

private fun updateNetworkFee() {
viewModelScope.launch {
val amountSats = _uiState.value.amount.sats
val customFeeRate = _uiState.value.customFeeRate

if (amountSats <= 0 || customFeeRate == 0u) {
if (amountSats <= 0) {
_uiState.update { it.copy(networkFee = 0L) }
return@launch
}

val speed = customFeeRate?.let { TransactionSpeed.Custom(it) }

val fee = lightningRepo.calculateTotalFee(
amountSats = amountSats.toULong(),
speed = speed,
Expand Down Expand Up @@ -219,7 +197,6 @@ interface ExternalNodeContract {
val peer: PeerDetails? = null,
val amount: Amount = Amount(),
val networkFee: Long = 0,
val customFeeRate: UInt? = null,
) {
data class Amount(
val sats: Long = 0,
Expand Down
2 changes: 1 addition & 1 deletion docs/e2e-test-ids.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ Legend:
| Send | ✅ |
| SendAmountNumberPad | ✅ |
| SendSuccess | ✅ |
| SetCustomFee | |
| SetCustomFee | 🚫 |
| SpendingAdvanced | ✅ |
| SpendingAdvancedContinue | ✅ |
| SpendingAdvancedDefault | ✅ |
Expand Down
Loading