Updated on 2026-08-14
This commit is contained in:
parent
95c2457832
commit
11748e9d19
3 changed files with 22 additions and 20 deletions
|
|
@ -77,11 +77,10 @@ interface FragmentOnBackPressedHandler {
|
|||
fun Fragment.addBackPressHandler(handler: FragmentOnBackPressedHandler) {
|
||||
requireActivity().onBackPressedDispatcher.addCallback(
|
||||
owner = this,
|
||||
onBackPressed = { handler.handleOnBackPressed() }
|
||||
onBackPressed = { handler.handleOnBackPressed() },
|
||||
)
|
||||
|
||||
view?.findViewById<Toolbar>(R.id.toolbar)?.setNavigationOnClickListener {
|
||||
handler.handleOnBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.components.*
|
||||
import com.tangem.core.ui.components.atoms.Hand
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -44,10 +43,6 @@ private fun SwapPermissionBottomSheetContent(content: GivePermissionBottomSheetC
|
|||
.padding(horizontal = TangemTheme.dimens.spacing16),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Hand()
|
||||
|
||||
SpacerH10()
|
||||
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
Text(
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
|
|
|
|||
|
|
@ -200,14 +200,17 @@ internal class SwapViewModel @Inject constructor(
|
|||
toToken: CryptoCurrencyStatus,
|
||||
amount: String,
|
||||
toProvidersList: List<SwapProvider>,
|
||||
isSilent: Boolean = false,
|
||||
) {
|
||||
singleTaskScheduler.cancelTask()
|
||||
uiState = stateBuilder.createQuotesLoadingState(
|
||||
uiState,
|
||||
fromToken.currency,
|
||||
toToken.currency,
|
||||
initialCryptoCurrency.id.value,
|
||||
)
|
||||
if (!isSilent) {
|
||||
uiState = stateBuilder.createQuotesLoadingState(
|
||||
uiState,
|
||||
fromToken.currency,
|
||||
toToken.currency,
|
||||
initialCryptoCurrency.id.value,
|
||||
)
|
||||
}
|
||||
singleTaskScheduler.scheduleTask(
|
||||
viewModelScope,
|
||||
loadQuotesTask(
|
||||
|
|
@ -219,7 +222,7 @@ internal class SwapViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun startLoadingQuotesFromLastState() {
|
||||
private fun startLoadingQuotesFromLastState(isSilent: Boolean = false) {
|
||||
val fromCurrency = dataState.fromCryptoCurrency
|
||||
val toCurrency = dataState.toCryptoCurrency
|
||||
val amount = dataState.amount
|
||||
|
|
@ -228,6 +231,7 @@ internal class SwapViewModel @Inject constructor(
|
|||
fromToken = fromCurrency,
|
||||
toToken = toCurrency,
|
||||
amount = amount,
|
||||
isSilent = isSilent,
|
||||
toProvidersList = findSwapProviders(fromCurrency, toCurrency),
|
||||
)
|
||||
}
|
||||
|
|
@ -429,6 +433,12 @@ internal class SwapViewModel @Inject constructor(
|
|||
private fun givePermissionsToSwap() {
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
runCatching(dispatchers.io) {
|
||||
val feeForPermission = when (val fee = dataState.approveDataModel?.fee) {
|
||||
TxFeeState.Empty -> error("Fee should not be Empty")
|
||||
is TxFeeState.MultipleFeeState -> fee.priorityFee
|
||||
is TxFeeState.SingleFeeState -> fee.fee
|
||||
null -> error("Fee should not be null")
|
||||
}
|
||||
swapInteractor.givePermissionToSwap(
|
||||
networkId = dataState.networkId,
|
||||
permissionOptions = PermissionOptions(
|
||||
|
|
@ -444,9 +454,7 @@ internal class SwapViewModel @Inject constructor(
|
|||
approveType = requireNotNull(dataState.approveType) {
|
||||
"uiState.permissionState should not be null"
|
||||
}.toDomainApproveType(),
|
||||
txFee = requireNotNull(dataState.selectedFee) {
|
||||
"dataState.selectedFee shouldn't be null"
|
||||
},
|
||||
txFee = feeForPermission,
|
||||
spenderAddress = requireNotNull(dataState.approveDataModel?.spenderAddress) {
|
||||
"dataState.approveDataModel.spenderAddress shouldn't be null"
|
||||
},
|
||||
|
|
@ -664,9 +672,9 @@ internal class SwapViewModel @Inject constructor(
|
|||
singleTaskScheduler.cancelTask()
|
||||
analyticsEventHandler.send(SwapEvents.ButtonGivePermissionClicked)
|
||||
uiState = stateBuilder.showPermissionBottomSheet(uiState) {
|
||||
startLoadingQuotesFromLastState()
|
||||
startLoadingQuotesFromLastState(isSilent = true)
|
||||
analyticsEventHandler.send(SwapEvents.ButtonPermissionCancelClicked)
|
||||
stateBuilder.dismissBottomSheet(uiState)
|
||||
uiState = stateBuilder.dismissBottomSheet(uiState)
|
||||
}
|
||||
},
|
||||
onAmountSelected = { onAmountSelected(it) },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue