Updated on 2026-08-14
This commit is contained in:
parent
f27a28f0b7
commit
4c8537529a
8 changed files with 78 additions and 39 deletions
|
|
@ -2,24 +2,21 @@ package com.tangem.features.walletconnect.connections.components
|
|||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.decompose.ComposableBottomSheetComponent
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
import com.tangem.features.walletconnect.connections.ui.AlertsModalBottomSheet
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
internal class AlertsComponent(
|
||||
appComponentContext: AppComponentContext,
|
||||
private val params: Params,
|
||||
) : AppComponentContext by appComponentContext, ComposableBottomSheetComponent {
|
||||
|
||||
override fun dismiss() {
|
||||
params.alertType.onDismiss()
|
||||
}
|
||||
) : AppComponentContext by appComponentContext, ComposableContentComponent {
|
||||
|
||||
@Composable
|
||||
override fun BottomSheet() {
|
||||
override fun Content(modifier: Modifier) {
|
||||
AlertsModalBottomSheet(
|
||||
config = TangemBottomSheetConfig(
|
||||
isShown = true,
|
||||
|
|
@ -48,6 +45,9 @@ internal class AlertsComponent(
|
|||
@Serializable
|
||||
data class UnsupportedNetworks(val appName: String, override val onDismiss: () -> Unit) : AlertType()
|
||||
|
||||
@Serializable
|
||||
data class UnsupportedMethod(override val onDismiss: () -> Unit) : AlertType()
|
||||
|
||||
@Serializable
|
||||
data class WcDisconnected(override val onDismiss: () -> Unit) : AlertType()
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.tangem.core.decompose.context.childByContext
|
|||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
import com.tangem.features.walletconnect.components.WcRoutingComponent
|
||||
import com.tangem.features.walletconnect.connections.components.AlertsComponent
|
||||
import com.tangem.features.walletconnect.connections.components.WcAppInfoContainerComponent
|
||||
import com.tangem.features.walletconnect.transaction.components.WcSignTransactionContainerComponent
|
||||
import dagger.assisted.Assisted
|
||||
|
|
@ -67,6 +68,12 @@ internal class DefaultWcRoutingComponent @AssistedInject constructor(
|
|||
source = config.request.source,
|
||||
),
|
||||
)
|
||||
is WcInnerRoute.Alert -> AlertsComponent(
|
||||
childContext,
|
||||
AlertsComponent.Params(
|
||||
alertType = config.alertType,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.features.walletconnect.connections.routing
|
|||
import com.tangem.core.decompose.navigation.Route
|
||||
import com.tangem.domain.walletconnect.model.WcPairRequest
|
||||
import com.tangem.domain.walletconnect.model.sdkcopy.WcSdkSessionRequest
|
||||
import com.tangem.features.walletconnect.connections.components.AlertsComponent
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
|
|
@ -18,4 +19,7 @@ internal sealed interface WcInnerRoute : Route {
|
|||
|
||||
@Serializable
|
||||
data class Pair(val request: WcPairRequest) : WcInnerRoute
|
||||
|
||||
@Serializable
|
||||
data class Alert(val alertType: AlertsComponent.AlertType) : WcInnerRoute
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import com.tangem.domain.walletconnect.model.WcEthMethodName
|
|||
import com.tangem.domain.walletconnect.model.WcMethodName
|
||||
import com.tangem.domain.walletconnect.model.WcSolanaMethodName
|
||||
import com.tangem.features.walletconnect.components.WalletConnectFeatureToggles
|
||||
import com.tangem.features.walletconnect.connections.components.AlertsComponent
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.*
|
||||
import javax.inject.Inject
|
||||
|
|
@ -49,12 +50,15 @@ internal class WcRoutingModel @Inject constructor(
|
|||
WcEthMethodName.SignTypeDataV4,
|
||||
WcSolanaMethodName.SignMessage,
|
||||
-> WcInnerRoute.SignMessage(rawRequest)
|
||||
WcEthMethodName.SignTransaction -> TODO()
|
||||
WcEthMethodName.SendTransaction -> TODO()
|
||||
WcSolanaMethodName.SignTransaction -> TODO()
|
||||
WcSolanaMethodName.SendAllTransaction -> TODO()
|
||||
WcEthMethodName.AddEthereumChain -> TODO()
|
||||
is WcMethodName.Unsupported -> TODO()
|
||||
WcEthMethodName.SignTransaction,
|
||||
WcEthMethodName.SendTransaction,
|
||||
WcSolanaMethodName.SignTransaction,
|
||||
WcSolanaMethodName.SendAllTransaction,
|
||||
WcEthMethodName.AddEthereumChain,
|
||||
is WcMethodName.Unsupported,
|
||||
-> WcInnerRoute.Alert(
|
||||
alertType = AlertsComponent.AlertType.UnsupportedMethod { innerRouter.pop() },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ private fun ButtonsContainer(alert: AlertsComponent.AlertType, modifier: Modifie
|
|||
}
|
||||
is AlertsComponent.AlertType.WrongCardSelected,
|
||||
is AlertsComponent.AlertType.UnknownError,
|
||||
is AlertsComponent.AlertType.UnsupportedMethod,
|
||||
-> SecondaryButton(
|
||||
modifier = buttonsModifier,
|
||||
onClick = alert.onDismiss,
|
||||
|
|
@ -173,6 +174,7 @@ private fun AlertIcon(alert: AlertsComponent.AlertType, modifier: Modifier = Mod
|
|||
is AlertsComponent.AlertType.WrongCardSelected,
|
||||
is AlertsComponent.AlertType.UnknownDomain,
|
||||
is AlertsComponent.AlertType.UnknownError,
|
||||
is AlertsComponent.AlertType.UnsupportedMethod,
|
||||
-> TangemTheme.colors.icon.attention
|
||||
is AlertsComponent.AlertType.MaliciousTransaction,
|
||||
is AlertsComponent.AlertType.UnsafeDomain,
|
||||
|
|
@ -190,6 +192,7 @@ private fun AlertIcon(alert: AlertsComponent.AlertType, modifier: Modifier = Mod
|
|||
is AlertsComponent.AlertType.UnsupportedNetworks -> R.drawable.ic_network_new_24
|
||||
is AlertsComponent.AlertType.WrongCardSelected,
|
||||
is AlertsComponent.AlertType.UnknownError,
|
||||
is AlertsComponent.AlertType.UnsupportedMethod,
|
||||
-> R.drawable.img_attention_20
|
||||
is AlertsComponent.AlertType.VerifiedDomain -> R.drawable.img_approvale2_20
|
||||
}
|
||||
|
|
@ -204,6 +207,7 @@ private fun AlertIcon(alert: AlertsComponent.AlertType, modifier: Modifier = Mod
|
|||
is AlertsComponent.AlertType.VerifiedDomain,
|
||||
is AlertsComponent.AlertType.UnknownError,
|
||||
is AlertsComponent.AlertType.WrongCardSelected,
|
||||
is AlertsComponent.AlertType.UnsupportedMethod,
|
||||
-> Color.Unspecified
|
||||
}
|
||||
Box(
|
||||
|
|
@ -236,6 +240,7 @@ private fun AlertContentTitle(alert: AlertsComponent.AlertType, modifier: Modifi
|
|||
is AlertsComponent.AlertType.VerifiedDomain -> R.string.wc_alert_verified_domain_title
|
||||
is AlertsComponent.AlertType.WcDisconnected -> R.string.wc_alert_session_disconnected_title
|
||||
is AlertsComponent.AlertType.WrongCardSelected -> R.string.wc_alert_wrong_card_title
|
||||
is AlertsComponent.AlertType.UnsupportedMethod -> R.string.wc_alert_unsupported_method_title
|
||||
}
|
||||
Text(
|
||||
modifier = modifier,
|
||||
|
|
@ -272,6 +277,9 @@ private fun AlertContentDescription(alert: AlertsComponent.AlertType, modifier:
|
|||
R.string.wc_alert_session_disconnected_description,
|
||||
)
|
||||
is AlertsComponent.AlertType.WrongCardSelected -> stringResourceSafe(R.string.wc_alert_wrong_card_description)
|
||||
is AlertsComponent.AlertType.UnsupportedMethod -> stringResourceSafe(
|
||||
R.string.wc_alert_unsupported_method_description,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
modifier = modifier,
|
||||
|
|
@ -315,6 +323,7 @@ private fun AlertAudit(alert: AlertsComponent.AlertType, modifier: Modifier = Mo
|
|||
is AlertsComponent.AlertType.VerifiedDomain,
|
||||
is AlertsComponent.AlertType.WcDisconnected,
|
||||
is AlertsComponent.AlertType.WrongCardSelected,
|
||||
is AlertsComponent.AlertType.UnsupportedMethod,
|
||||
-> Unit
|
||||
}
|
||||
}
|
||||
|
|
@ -351,5 +360,6 @@ private class AlertTypesProvider : CollectionPreviewParameterProvider<AlertsComp
|
|||
AlertsComponent.AlertType.UnknownError(errorCode = 8005, onDismiss = {}),
|
||||
AlertsComponent.AlertType.WrongCardSelected(onDismiss = {}),
|
||||
AlertsComponent.AlertType.ConnectionTimeout(onTryAgain = {}, onDismiss = {}),
|
||||
AlertsComponent.AlertType.UnsupportedMethod(onDismiss = {}),
|
||||
),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue