Updated on 2026-08-14
This commit is contained in:
parent
5d9d08abe0
commit
0b32fcb925
4 changed files with 16 additions and 3 deletions
|
|
@ -77,6 +77,7 @@ internal sealed class SendStates {
|
|||
val rate: BigDecimal?,
|
||||
val appCurrency: AppCurrency,
|
||||
val isFeeApproximate: Boolean,
|
||||
val isCustomSelected: Boolean,
|
||||
val notifications: ImmutableList<SendNotification>,
|
||||
) : SendStates()
|
||||
|
||||
|
|
|
|||
|
|
@ -56,18 +56,26 @@ internal class FeeStateFactory(
|
|||
fun onFeeOnLoadedState(fees: TransactionFee): SendUiState {
|
||||
val state = currentStateProvider()
|
||||
val feeState = state.feeState ?: return state
|
||||
val feeSelectorState = (feeState.feeSelectorState as? FeeSelectorState.Content)?.copy(
|
||||
val feeSelectorState = feeState.feeSelectorState as? FeeSelectorState.Content
|
||||
|
||||
val isCustomWasSelected = if (feeState.isCustomSelected) {
|
||||
feeSelectorState?.customValues ?: persistentListOf()
|
||||
} else {
|
||||
customFeeFieldConverter.convert(fees.normal)
|
||||
}
|
||||
val updatedFeeSelectorState = feeSelectorState?.copy(
|
||||
fees = fees,
|
||||
customValues = isCustomWasSelected,
|
||||
) ?: FeeSelectorState.Content(
|
||||
fees = fees,
|
||||
customValues = customFeeFieldConverter.convert(fees.normal),
|
||||
)
|
||||
|
||||
val fee = feeConverter.convert(feeSelectorState)
|
||||
val fee = feeConverter.convert(updatedFeeSelectorState)
|
||||
return state.copy(
|
||||
amountState = state.amountState?.copy(isFeeLoading = false),
|
||||
feeState = feeState.copy(
|
||||
feeSelectorState = feeSelectorState,
|
||||
feeSelectorState = updatedFeeSelectorState,
|
||||
fee = fee,
|
||||
isFeeApproximate = isFeeApproximate(fee),
|
||||
),
|
||||
|
|
@ -91,9 +99,11 @@ internal class FeeStateFactory(
|
|||
|
||||
val updatedFeeSelectorState = feeSelectorState.copy(selectedFee = feeType)
|
||||
val fee = feeConverter.convert(updatedFeeSelectorState)
|
||||
val isCustomFeeWasSelected = feeState.isCustomSelected || updatedFeeSelectorState.selectedFee == FeeType.Custom
|
||||
return state.copy(
|
||||
feeState = feeState.copy(
|
||||
fee = fee,
|
||||
isCustomSelected = isCustomFeeWasSelected,
|
||||
feeSelectorState = updatedFeeSelectorState,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ internal class SendFeeStateConverter(
|
|||
rate = feeCryptoCurrencyStatusProvider().value.fiatRate,
|
||||
appCurrency = appCurrencyProvider(),
|
||||
isFeeApproximate = false,
|
||||
isCustomSelected = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -48,6 +48,7 @@ internal object FeeStatePreviewData {
|
|||
),
|
||||
isFeeApproximate = false,
|
||||
notifications = persistentListOf(),
|
||||
isCustomSelected = false,
|
||||
)
|
||||
|
||||
val errorFeeState = feeState.copy(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue