Updated on 2026-08-14
This commit is contained in:
parent
5037fabe32
commit
fa934e9847
3 changed files with 63 additions and 37 deletions
|
|
@ -24,6 +24,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import com.tangem.common.ui.navigationButtons.preview.NavigationButtonsPreview
|
||||
import com.tangem.core.ui.components.HoldToConfirmButton
|
||||
import com.tangem.core.ui.components.Keyboard
|
||||
import com.tangem.core.ui.components.SecondaryButtonIconStart
|
||||
import com.tangem.core.ui.components.buttons.common.TangemButton
|
||||
|
|
@ -98,34 +99,48 @@ fun NavigationPrimaryButton(primaryButton: NavigationButton?, modifier: Modifier
|
|||
modifier = modifier.fillMaxWidth(),
|
||||
) { button ->
|
||||
if (button != null && button.textReference != TextReference.EMPTY) {
|
||||
val icon = if (button.iconRes != null && button.isIconVisible) {
|
||||
TangemButtonIconPosition.End(iconResId = button.iconRes)
|
||||
} else {
|
||||
TangemButtonIconPosition.None
|
||||
}
|
||||
val color = if (button.isDimmed) {
|
||||
TangemButtonsDefaults.secondaryButtonColors
|
||||
.copy(contentColor = TangemTheme.colors.text.tertiary)
|
||||
} else {
|
||||
TangemButtonsDefaults.primaryButtonColors
|
||||
}
|
||||
TangemButton(
|
||||
text = button.textReference.resolveReference(),
|
||||
enabled = button.isEnabled,
|
||||
onClick = {
|
||||
GlobalMultipleClickPreventer.processEvent {
|
||||
if (button.isHapticClick) {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
if (button.isHoldToConfirm) {
|
||||
HoldToConfirmButton(
|
||||
text = button.textReference.resolveReference(),
|
||||
enabled = button.isEnabled,
|
||||
isLoading = button.shouldShowProgress,
|
||||
onConfirm = {
|
||||
GlobalMultipleClickPreventer.processEvent {
|
||||
button.onClick()
|
||||
}
|
||||
button.onClick()
|
||||
}
|
||||
},
|
||||
showProgress = button.shouldShowProgress,
|
||||
colors = color,
|
||||
textStyle = TangemTheme.typography.subtitle1,
|
||||
icon = icon,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
} else {
|
||||
val icon = if (button.iconRes != null && button.isIconVisible) {
|
||||
TangemButtonIconPosition.End(iconResId = button.iconRes)
|
||||
} else {
|
||||
TangemButtonIconPosition.None
|
||||
}
|
||||
val color = if (button.isDimmed) {
|
||||
TangemButtonsDefaults.secondaryButtonColors
|
||||
.copy(contentColor = TangemTheme.colors.text.tertiary)
|
||||
} else {
|
||||
TangemButtonsDefaults.primaryButtonColors
|
||||
}
|
||||
TangemButton(
|
||||
text = button.textReference.resolveReference(),
|
||||
enabled = button.isEnabled,
|
||||
onClick = {
|
||||
GlobalMultipleClickPreventer.processEvent {
|
||||
if (button.isHapticClick) {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
}
|
||||
button.onClick()
|
||||
}
|
||||
},
|
||||
showProgress = button.shouldShowProgress,
|
||||
colors = color,
|
||||
textStyle = TangemTheme.typography.subtitle1,
|
||||
icon = icon,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Spacer(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,5 +34,6 @@ data class NavigationButton(
|
|||
val isEnabled: Boolean = true,
|
||||
val isDimmed: Boolean = false,
|
||||
val isHapticClick: Boolean = false,
|
||||
val isHoldToConfirm: Boolean = false,
|
||||
val onClick: () -> Unit,
|
||||
)
|
||||
|
|
@ -18,8 +18,11 @@ import com.tangem.core.decompose.di.ModelScoped
|
|||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.express.models.ExpressOperationType
|
||||
import com.tangem.domain.models.wallet.isHotWallet
|
||||
import com.tangem.domain.express.models.ExpressProviderType
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
|
|
@ -486,6 +489,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
}.onEach { (state, _) ->
|
||||
val confirmUM = state.confirmUM
|
||||
val isReadyToSend = confirmUM is ConfirmUM.Content && !confirmUM.isTransactionInProcess
|
||||
val isHoldToConfirm = params.userWallet.isHotWallet && confirmUM is ConfirmUM.Content
|
||||
params.callback.onResult(
|
||||
route = SendWithSwapRoute.Confirm,
|
||||
sendWithSwapUM = state.copy(
|
||||
|
|
@ -496,18 +500,11 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
backIconRes = R.drawable.ic_back_24,
|
||||
backIconClick = router::pop,
|
||||
primaryButton = NavigationButton(
|
||||
textReference = when (confirmUM) {
|
||||
is ConfirmUM.Success -> resourceReference(R.string.common_close)
|
||||
is ConfirmUM.Content -> if (confirmUM.isTransactionInProcess) {
|
||||
resourceReference(R.string.send_sending)
|
||||
} else {
|
||||
resourceReference(R.string.common_send)
|
||||
}
|
||||
else -> resourceReference(R.string.common_send)
|
||||
},
|
||||
textReference = getPrimaryButtonText(confirmUM, isHoldToConfirm),
|
||||
iconRes = walletInterationIcon(params.userWallet),
|
||||
isIconVisible = isReadyToSend,
|
||||
isIconVisible = isReadyToSend && !isHoldToConfirm,
|
||||
isHapticClick = isReadyToSend,
|
||||
isHoldToConfirm = isHoldToConfirm,
|
||||
isEnabled = confirmUM.isPrimaryButtonEnabled,
|
||||
onClick = {
|
||||
when (confirmUM) {
|
||||
|
|
@ -525,4 +522,17 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
)
|
||||
}.launchIn(modelScope)
|
||||
}
|
||||
|
||||
private fun getPrimaryButtonText(confirmUM: ConfirmUM, isHoldToConfirm: Boolean): TextReference {
|
||||
return when {
|
||||
isHoldToConfirm -> resourceReference(
|
||||
id = com.tangem.core.ui.R.string.common_hold_to,
|
||||
formatArgs = wrappedList(resourceReference(R.string.common_send)),
|
||||
)
|
||||
confirmUM is ConfirmUM.Success -> resourceReference(R.string.common_close)
|
||||
confirmUM is ConfirmUM.Content && confirmUM.isTransactionInProcess ->
|
||||
resourceReference(R.string.send_sending)
|
||||
else -> resourceReference(R.string.common_send)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue