Updated on 2026-08-14
This commit is contained in:
parent
ce602107bb
commit
443560a5fd
4 changed files with 29 additions and 8 deletions
|
|
@ -313,7 +313,12 @@ internal sealed class AddCustomTokenWarning(val description: TextReference) {
|
|||
/**
|
||||
* Floating button of add custom token screen
|
||||
*
|
||||
* @property isEnabled button availability
|
||||
* @property onClick lambda be invoked when button is been pressed
|
||||
* @property isEnabled button availability
|
||||
* @property showProgress whether circle progress indication is enabled
|
||||
* @property onClick lambda be invoked when button is been pressed
|
||||
*/
|
||||
internal data class AddCustomTokenFloatingButton(val isEnabled: Boolean, val onClick: () -> Unit)
|
||||
internal data class AddCustomTokenFloatingButton(
|
||||
val isEnabled: Boolean,
|
||||
val showProgress: Boolean,
|
||||
val onClick: () -> Unit
|
||||
)
|
||||
|
|
@ -91,7 +91,11 @@ internal object AddCustomTokenPreviewData {
|
|||
),
|
||||
form = createDefaultForm(),
|
||||
warnings = createWarnings(),
|
||||
floatingButton = AddCustomTokenFloatingButton(isEnabled = false, onClick = {}),
|
||||
floatingButton = AddCustomTokenFloatingButton(
|
||||
isEnabled = false,
|
||||
showProgress = false,
|
||||
onClick = {}
|
||||
),
|
||||
testBlock = AddCustomTokenTestBlock(
|
||||
chooseTokenButtonText = "Choose token",
|
||||
clearButtonText = "Clear address",
|
||||
|
|
@ -112,7 +116,10 @@ internal object AddCustomTokenPreviewData {
|
|||
),
|
||||
form = createDefaultForm(),
|
||||
warnings = createWarnings(),
|
||||
floatingButton = AddCustomTokenFloatingButton(isEnabled = false, onClick = {}),
|
||||
floatingButton = AddCustomTokenFloatingButton(
|
||||
isEnabled = false,
|
||||
showProgress = false,
|
||||
onClick = {}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ internal fun AddCustomTokenFloatingButton(model: AddCustomTokenFloatingButton, m
|
|||
text = stringResource(id = R.string.custom_token_add_token),
|
||||
iconResId = R.drawable.ic_plus_24,
|
||||
enabled = model.isEnabled,
|
||||
showProgress = model.showProgress,
|
||||
onClick = model.onClick,
|
||||
)
|
||||
}
|
||||
|
|
@ -48,7 +49,7 @@ private fun Preview_AddCustomTokenFloatingButton(
|
|||
|
||||
private class AddCustomTokenFloatingButtonProvider : CollectionPreviewParameterProvider<AddCustomTokenFloatingButton>(
|
||||
listOf(
|
||||
AddCustomTokenFloatingButton(isEnabled = true, onClick = {}),
|
||||
AddCustomTokenFloatingButton(isEnabled = false, onClick = {}),
|
||||
AddCustomTokenFloatingButton(isEnabled = true, showProgress = false, onClick = {}),
|
||||
AddCustomTokenFloatingButton(isEnabled = false, showProgress = false, onClick = {}),
|
||||
),
|
||||
)
|
||||
|
|
@ -142,7 +142,10 @@ internal class AddCustomTokenViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun createFloatingButton(): AddCustomTokenFloatingButton {
|
||||
return AddCustomTokenFloatingButton(isEnabled = false, onClick = actionsHandler::onAddCustomTokenClick)
|
||||
return AddCustomTokenFloatingButton(
|
||||
isEnabled = true,
|
||||
showProgress = false,
|
||||
onClick = actionsHandler::onAddCustomTokenClick)
|
||||
}
|
||||
|
||||
private inner class FormStateBuilder {
|
||||
|
|
@ -852,9 +855,14 @@ internal class AddCustomTokenViewModel @Inject constructor(
|
|||
analyticsSender.sendWhenAddTokenButtonClicked(currency)
|
||||
|
||||
viewModelScope.launch(dispatchers.io) {
|
||||
val oldButtonState = uiState.floatingButton
|
||||
uiState = uiState.copySealed(
|
||||
floatingButton = uiState.floatingButton.copy(isEnabled = false, showProgress = true)
|
||||
)
|
||||
runCatching { featureInteractor.saveToken(currency) }
|
||||
.onSuccess { featureRouter.openWalletScreen() }
|
||||
.onFailure {
|
||||
uiState = uiState.copySealed(floatingButton = oldButtonState)
|
||||
Timber.e(it)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue