Updated on 2026-08-14
This commit is contained in:
parent
b0386eb54b
commit
9c68c9ff00
10 changed files with 78 additions and 12 deletions
|
|
@ -12,6 +12,7 @@ internal class AlertsComponentV2(
|
|||
) : AppComponentContext by appComponentContext, ComposableBottomSheetComponent {
|
||||
|
||||
override fun dismiss() {
|
||||
messageUM.onDismissRequest()
|
||||
router.pop()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,8 +115,11 @@ internal class WcPairComponent(
|
|||
is Alert.Type.Verified -> WcAlertsFactory.createVerifiedDomainAlert(alertType.appName)
|
||||
is Alert.Type.UnknownDomain -> WcAlertsFactory.createUnknownDomainAlert(model::connectFromAlert)
|
||||
is Alert.Type.UnsafeDomain -> WcAlertsFactory.createUnsafeDomainAlert(model::connectFromAlert)
|
||||
is Alert.Type.UnsupportedDApp -> WcAlertsFactory.createUnsupportedDomainAlert(alertType.appName)
|
||||
is Alert.Type.UnsupportedNetwork -> WcAlertsFactory.createUnsupportedChainAlert(alertType.appName)
|
||||
is Alert.Type.UnsupportedDApp ->
|
||||
WcAlertsFactory.createUnsupportedDomainAlert(alertType.appName, model::errorAlertOnDismiss)
|
||||
is Alert.Type.UnsupportedNetwork ->
|
||||
WcAlertsFactory.createUnsupportedChainAlert(alertType.appName, model::errorAlertOnDismiss)
|
||||
is Alert.Type.UriAlreadyUsed -> WcAlertsFactory.createUriAlreadyUsedAlert(model::errorAlertOnDismiss)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,10 @@ internal class WcPairModel @Inject constructor(
|
|||
connect()
|
||||
}
|
||||
|
||||
fun errorAlertOnDismiss() {
|
||||
router.pop()
|
||||
}
|
||||
|
||||
private fun onConnect(securityStatus: CheckDAppResult) {
|
||||
when (securityStatus) {
|
||||
CheckDAppResult.SAFE -> connect()
|
||||
|
|
@ -193,16 +197,23 @@ internal class WcPairModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun processError(error: WcPairError) {
|
||||
when (error) {
|
||||
val alert = when (error) {
|
||||
is WcPairError.UnsupportedDApp -> {
|
||||
WcAppInfoRoutes.Alert.Type.UnsupportedDApp(error.appName)
|
||||
}
|
||||
is WcPairError.UnsupportedBlockchains -> {
|
||||
WcAppInfoRoutes.Alert.Type.UnsupportedNetwork(error.appName)
|
||||
}
|
||||
else -> null
|
||||
}?.let { stackNavigation.pushNew(WcAppInfoRoutes.Alert(it)) }
|
||||
?: run { messageSender.send(ToastMessage(message = stringReference(error.message))) }
|
||||
is WcPairError.UriAlreadyUsed -> {
|
||||
WcAppInfoRoutes.Alert.Type.UriAlreadyUsed
|
||||
}
|
||||
else -> {
|
||||
messageSender.send(ToastMessage(message = stringReference(error.message)))
|
||||
router.pop()
|
||||
null
|
||||
}
|
||||
}
|
||||
alert?.let { stackNavigation.pushNew(WcAppInfoRoutes.Alert(it)) }
|
||||
}
|
||||
|
||||
override fun onWalletSelected(userWalletId: UserWalletId) {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ internal sealed class WcAppInfoRoutes : TangemBottomSheetConfigContent, Route {
|
|||
data object UnsafeDomain : Type()
|
||||
data class UnsupportedDApp(val appName: String) : Type()
|
||||
data class UnsupportedNetwork(val appName: String) : Type()
|
||||
data object UriAlreadyUsed : Type()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,11 +74,11 @@ internal object WcAlertsFactory {
|
|||
}
|
||||
}
|
||||
|
||||
fun createUnsupportedDomainAlert(appName: String): MessageBottomSheetUMV2 {
|
||||
fun createUnsupportedDomainAlert(appName: String, onDismiss: () -> Unit): MessageBottomSheetUMV2 {
|
||||
return messageBottomSheetUM {
|
||||
infoBlock {
|
||||
icon(R.drawable.ic_wallet_connect_24) {
|
||||
type = MessageBottomSheetUMV2.Icon.Type.Informative
|
||||
type = Type.Informative
|
||||
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.SameAsTint
|
||||
}
|
||||
title = resourceReference(R.string.wc_alert_unsupported_dapps_title)
|
||||
|
|
@ -86,16 +86,34 @@ internal object WcAlertsFactory {
|
|||
}
|
||||
primaryButton {
|
||||
text = resourceReference(R.string.common_got_it)
|
||||
onClick { closeBs() }
|
||||
onClick { onDismiss() }
|
||||
}
|
||||
onDismissRequest = onDismiss
|
||||
}
|
||||
}
|
||||
|
||||
fun createUriAlreadyUsedAlert(onDismiss: () -> Unit): MessageBottomSheetUMV2 {
|
||||
return messageBottomSheetUM {
|
||||
infoBlock {
|
||||
icon(R.drawable.ic_wallet_connect_24) {
|
||||
type = Type.Informative
|
||||
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.SameAsTint
|
||||
}
|
||||
title = resourceReference(R.string.wc_uri_already_used_title)
|
||||
body = resourceReference(R.string.wc_uri_already_used_description)
|
||||
}
|
||||
primaryButton {
|
||||
text = resourceReference(R.string.common_got_it)
|
||||
onClick { onDismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun createUnsupportedChainAlert(appName: String): MessageBottomSheetUMV2 {
|
||||
fun createUnsupportedChainAlert(appName: String, onDismiss: () -> Unit): MessageBottomSheetUMV2 {
|
||||
return messageBottomSheetUM {
|
||||
infoBlock {
|
||||
icon(R.drawable.ic_network_new_24) {
|
||||
type = MessageBottomSheetUMV2.Icon.Type.Informative
|
||||
type = Type.Informative
|
||||
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.SameAsTint
|
||||
}
|
||||
title = resourceReference(R.string.wc_alert_unsupported_networks_title)
|
||||
|
|
@ -103,8 +121,9 @@ internal object WcAlertsFactory {
|
|||
}
|
||||
primaryButton {
|
||||
text = resourceReference(R.string.common_got_it)
|
||||
onClick { closeBs() }
|
||||
onClick { onDismiss() }
|
||||
}
|
||||
onDismissRequest = onDismiss
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +147,7 @@ internal object WcAlertsFactory {
|
|||
text = resourceReference(R.string.balance_hidden_got_it_button)
|
||||
onClick { onDismiss() }
|
||||
}
|
||||
onDismissRequest = onDismiss
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue