Updated on 2026-08-14

This commit is contained in:
Tangem 2025-04-16 11:27:57 +05:00
parent 3d214007f4
commit fd4c93ce8d
7 changed files with 466 additions and 0 deletions

View file

@ -1236,6 +1236,21 @@
<string name="warning_testnet_card_message">This is a Testnet card. It cannot process transactions and should only be used for testing and development purposes.</string>
<string name="warning_testnet_card_title">For testing purposes only</string>
<string name="warning_token_balance_not_updated">Balance may be outdated. Refresh the page.</string>
<string name="wc_alert_audit_unknown_domain">Unknown domain</string>
<string name="wc_alert_connect_anyway">Connect anyway</string>
<string name="wc_alert_connection_timeout_description">Timeout error. Please, try again later.</string>
<string name="wc_alert_connection_timeout_title">Failed to establish WalletConnect</string>
<string name="wc_alert_domain_issues_description">This domain cannot be verified. Check the request carefully approving.</string>
<string name="wc_alert_session_disconnected_description">Go back to your browser and connect via WalletConnect again.</string>
<string name="wc_alert_session_disconnected_title">WalletConnect session was disconnected</string>
<string name="wc_alert_unknown_error_description">Error code: %s. If the problem persists — feel free to contact our support.</string>
<string name="wc_alert_unknown_error_title">We\'ve encountered unknown error</string>
<string name="wc_alert_unsupported_networks_description">Tangem does not currently support a required network by %s.</string>
<string name="wc_alert_unsupported_networks_title">Unsuported networks</string>
<string name="wc_alert_verified_domain_description">Tangem support a required network by %s.</string>
<string name="wc_alert_verified_domain_title">Verified domain</string>
<string name="wc_alert_wrong_card_description">Wrong card or ring selected in Tangem App</string>
<string name="wc_alert_wrong_card_title">We\'ve got some kind of problem</string>
<string name="wc_connections">Connections</string>
<string name="wc_disconnect_all">Disconnect all</string>
<string name="wc_disconnect_all_alert_desc">Text about discnected all dApps</string>

View file

@ -95,6 +95,7 @@ data class TangemDimens internal constructor(
val size142: Dp = 142.dp,
val size158: Dp = 158.dp,
val size164: Dp = 164.dp,
val size180: Dp = 180.dp,
val size200: Dp = 200.dp,
val size248: Dp = 248.dp,
val size350: Dp = 350.dp,

View file

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#0099FF"
android:fillType="evenOdd"
android:pathData="M6.532,6.791C6.532,5.272 7.763,4.041 9.282,4.041C10.801,4.041 12.032,5.272 12.032,6.791C12.032,7.766 11.525,8.622 10.76,9.111L11.04,9.85C11.292,9.773 11.559,9.732 11.836,9.732C12.655,9.732 13.39,10.09 13.894,10.658L14.119,10.418C13.92,10.038 13.808,9.605 13.808,9.146C13.808,7.627 15.039,6.396 16.558,6.396C18.076,6.396 19.308,7.627 19.308,9.146C19.308,10.664 18.076,11.896 16.558,11.896C16.044,11.896 15.563,11.755 15.152,11.509L14.564,12.135C14.579,12.249 14.586,12.365 14.586,12.482C14.586,13.038 14.421,13.556 14.137,13.989L16.034,15.229C16.533,14.724 17.226,14.41 17.992,14.41C19.511,14.41 20.742,15.641 20.742,17.16C20.742,18.679 19.511,19.91 17.992,19.91C16.473,19.91 15.242,18.679 15.242,17.16C15.242,16.95 15.266,16.745 15.311,16.548L12.943,15C12.605,15.149 12.23,15.232 11.836,15.232C11.269,15.232 10.742,15.061 10.304,14.766L8.465,16.455C8.603,16.783 8.68,17.144 8.68,17.522C8.68,19.041 7.448,20.272 5.93,20.272C4.411,20.272 3.18,19.041 3.18,17.522C3.18,16.004 4.411,14.773 5.93,14.773C6.524,14.773 7.074,14.961 7.524,15.282L9.33,13.624L9.337,13.632C9.176,13.283 9.086,12.893 9.086,12.482C9.086,11.796 9.337,11.169 9.753,10.687L9.319,9.541L9.282,9.541C7.763,9.541 6.532,8.31 6.532,6.791ZM9.282,5.541C8.592,5.541 8.032,6.101 8.032,6.791C8.032,7.481 8.592,8.041 9.282,8.041C9.973,8.041 10.532,7.481 10.532,6.791C10.532,6.101 9.973,5.541 9.282,5.541ZM16.558,7.896C15.867,7.896 15.308,8.455 15.308,9.146C15.308,9.836 15.867,10.396 16.558,10.396C17.248,10.396 17.808,9.836 17.808,9.146C17.808,8.455 17.248,7.896 16.558,7.896ZM11.836,11.232C11.146,11.232 10.586,11.792 10.586,12.482C10.586,13.173 11.146,13.732 11.836,13.732C12.526,13.732 13.086,13.173 13.086,12.482C13.086,11.792 12.526,11.232 11.836,11.232ZM4.68,17.522C4.68,16.832 5.239,16.272 5.93,16.272C6.62,16.272 7.18,16.832 7.18,17.522C7.18,18.213 6.62,18.772 5.93,18.772C5.239,18.772 4.68,18.213 4.68,17.522ZM16.742,17.16C16.742,16.47 17.302,15.91 17.992,15.91C18.683,15.91 19.242,16.47 19.242,17.16C19.242,17.851 18.683,18.41 17.992,18.41C17.302,18.41 16.742,17.851 16.742,17.16Z" />
</vector>

View file

@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:autoMirrored="true"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:fillColor="#0099FF"
android:fillType="evenOdd"
android:pathData="M8.807,1.939C9.142,1.683 9.524,1.482 9.999,1.482C10.473,1.482 10.855,1.683 11.191,1.939C11.501,2.176 11.842,2.517 12.231,2.906L12.263,2.938C12.646,3.32 12.967,3.464 13.474,3.464C13.536,3.464 13.617,3.461 13.711,3.459C13.958,3.452 14.291,3.442 14.576,3.466C14.993,3.502 15.537,3.615 15.956,4.03C16.377,4.448 16.494,4.995 16.53,5.415C16.555,5.702 16.545,6.037 16.538,6.286C16.536,6.38 16.534,6.461 16.534,6.523C16.534,6.867 16.572,7.046 16.631,7.181C16.692,7.32 16.803,7.477 17.06,7.734L17.091,7.766C17.481,8.155 17.821,8.496 18.059,8.807C18.315,9.142 18.515,9.524 18.515,9.998C18.515,10.473 18.315,10.855 18.059,11.19C17.821,11.501 17.481,11.842 17.091,12.231L17.06,12.263C16.803,12.52 16.692,12.677 16.631,12.816C16.572,12.951 16.534,13.13 16.534,13.474C16.534,13.536 16.536,13.617 16.538,13.711C16.545,13.96 16.555,14.295 16.53,14.582C16.494,15.002 16.377,15.549 15.956,15.967C15.537,16.382 14.993,16.495 14.576,16.531C14.291,16.555 13.958,16.545 13.711,16.538C13.618,16.535 13.536,16.533 13.474,16.533C13.136,16.533 12.96,16.567 12.828,16.622C12.696,16.676 12.545,16.777 12.305,17.017C12.258,17.065 12.192,17.135 12.115,17.217C11.934,17.411 11.689,17.674 11.467,17.868C11.13,18.163 10.628,18.515 9.999,18.515C9.37,18.515 8.868,18.163 8.531,17.868C8.308,17.674 8.063,17.411 7.882,17.217C7.805,17.135 7.74,17.065 7.692,17.017C7.452,16.777 7.302,16.676 7.17,16.622C7.038,16.567 6.861,16.533 6.524,16.533C6.462,16.533 6.38,16.535 6.287,16.538C6.039,16.545 5.707,16.555 5.422,16.531C5.004,16.495 4.46,16.382 4.042,15.967C3.62,15.549 3.504,15.002 3.468,14.582C3.443,14.295 3.452,13.96 3.459,13.711C3.462,13.617 3.464,13.536 3.464,13.474C3.464,13.13 3.426,12.951 3.367,12.816C3.306,12.677 3.195,12.52 2.938,12.263L2.906,12.231C2.517,11.842 2.176,11.501 1.939,11.19C1.683,10.855 1.482,10.473 1.482,9.998C1.482,9.524 1.683,9.142 1.939,8.807C2.176,8.496 2.517,8.155 2.906,7.766L2.938,7.734C3.321,7.351 3.464,7.03 3.464,6.523C3.464,6.461 3.462,6.38 3.459,6.286C3.452,6.039 3.443,5.706 3.467,5.421C3.502,5.004 3.615,4.46 4.03,4.041C4.448,3.62 4.995,3.504 5.415,3.467C5.703,3.442 6.038,3.452 6.287,3.459C6.38,3.461 6.461,3.464 6.524,3.464C7.03,3.464 7.352,3.32 7.734,2.938L7.766,2.906C8.155,2.517 8.496,2.176 8.807,1.939Z" />
<path
android:fillColor="#ffffff"
android:fillType="evenOdd"
android:pathData="M13.464,8.04C13.821,7.854 13.96,7.414 13.774,7.057C13.587,6.7 13.147,6.561 12.79,6.747C11.373,7.485 10.195,8.914 9.399,10.075C9.087,10.531 8.823,10.96 8.616,11.317C8.408,11.119 8.2,10.95 8.016,10.811C7.8,10.649 7.606,10.521 7.465,10.432C7.394,10.388 7.336,10.354 7.294,10.33C7.273,10.318 7.257,10.308 7.244,10.301L7.23,10.293L7.225,10.29L7.223,10.289L7.222,10.289C6.868,10.097 6.425,10.228 6.233,10.581C6.041,10.935 6.172,11.378 6.526,11.57L6.532,11.573C6.538,11.577 6.549,11.583 6.563,11.592C6.592,11.608 6.637,11.635 6.693,11.67C6.806,11.74 6.964,11.844 7.139,11.976C7.499,12.248 7.888,12.603 8.132,12.992C8.273,13.217 8.526,13.347 8.791,13.332C9.056,13.317 9.292,13.159 9.407,12.92L9.407,12.919L9.411,12.913L9.425,12.884C9.438,12.858 9.457,12.818 9.484,12.767C9.537,12.664 9.616,12.513 9.719,12.328C9.926,11.956 10.227,11.447 10.602,10.9C11.369,9.781 12.379,8.605 13.464,8.04Z" />
</vector>

View file

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:autoMirrored="true"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FFB71B"
android:fillType="evenOdd"
android:pathData="M16.214,1.668C14.03,1.668 12.267,2.448 10.774,3.263C10.303,3.52 9.876,3.769 9.474,4.002C8.525,4.554 7.719,5.023 6.819,5.326C6.683,5.371 6.542,5.416 6.399,5.461C5.631,5.703 4.787,5.969 4.269,6.575C3.799,7.126 3.677,7.846 3.56,8.537L3.543,8.634C2.104,17.057 5.406,26.376 13.794,29.764C14.591,30.086 15.207,30.335 16.218,30.335C17.23,30.335 17.846,30.086 18.643,29.764C27.031,26.376 30.331,17.065 28.889,8.633L28.873,8.537C28.755,7.845 28.633,7.125 28.163,6.575C27.646,5.968 26.801,5.703 26.034,5.461L26.033,5.461C25.889,5.416 25.749,5.371 25.614,5.326C24.713,5.023 23.906,4.554 22.956,4.002C22.554,3.768 22.127,3.52 21.656,3.263C20.163,2.448 18.399,1.668 16.214,1.668ZM14.884,21.634C14.884,20.897 15.48,20.3 16.217,20.3H16.229C16.965,20.3 17.562,20.897 17.562,21.634C17.562,22.37 16.965,22.967 16.229,22.967H16.217C15.48,22.967 14.884,22.37 14.884,21.634ZM15.217,17.634C15.217,18.186 15.665,18.634 16.217,18.634C16.769,18.634 17.217,18.186 17.217,17.634V9.634C17.217,9.081 16.769,8.634 16.217,8.634C15.665,8.634 15.217,9.081 15.217,9.634V17.634Z" />
</vector>

View file

@ -0,0 +1,51 @@
package com.tangem.features.walletconnect.connections.components
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
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.features.walletconnect.connections.ui.AlertsModalBottomSheet
internal class AlertsComponent(
appComponentContext: AppComponentContext,
private val params: Params,
) : AppComponentContext by appComponentContext, ComposableBottomSheetComponent {
override fun dismiss() {
params.alertType.onDismiss()
}
@Composable
override fun BottomSheet() {
AlertsModalBottomSheet(
config = TangemBottomSheetConfig(
isShown = true,
onDismissRequest = params.alertType.onDismiss,
content = params.alertType,
),
)
}
internal data class Params(val alertType: AlertType)
@Immutable
internal sealed class AlertType : TangemBottomSheetConfigContent {
abstract val onDismiss: () -> Unit
data class VerifiedDomain(val appName: String, override val onDismiss: () -> Unit) : AlertType()
data class UnknownDomain(val onConnect: () -> Unit, override val onDismiss: () -> Unit) : AlertType()
data class UnsafeDomain(val onConnect: () -> Unit, override val onDismiss: () -> Unit) : AlertType()
data class UnsupportedNetworks(val appName: String, override val onDismiss: () -> Unit) : AlertType()
data class WcDisconnected(override val onDismiss: () -> Unit) : AlertType()
data class UnknownError(val errorCode: Int, override val onDismiss: () -> Unit) : AlertType()
data class WrongCardSelected(override val onDismiss: () -> Unit) : AlertType()
data class ConnectionTimeout(val onTryAgain: () -> Unit, override val onDismiss: () -> Unit) : AlertType()
data class MaliciousTransaction(
val descriptionMessage: String,
val onConnect: () -> Unit,
override val onDismiss: () -> Unit,
) : AlertType()
}
}

View file

@ -0,0 +1,355 @@
package com.tangem.features.walletconnect.connections.ui
import android.content.res.Configuration
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.R
import com.tangem.core.ui.components.PrimaryButton
import com.tangem.core.ui.components.SecondaryButton
import com.tangem.core.ui.components.SecondaryButtonIconEnd
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheet
import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheetTitle
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.features.walletconnect.connections.components.AlertsComponent
@Composable
internal fun AlertsModalBottomSheet(config: TangemBottomSheetConfig) {
TangemModalBottomSheet<AlertsComponent.AlertType>(
config = config,
title = { alert ->
TangemModalBottomSheetTitle(
endIconRes = R.drawable.ic_close_24,
onEndClick = alert.onDismiss,
)
},
content = { alert -> Content(alert = alert) },
)
}
@Composable
private fun Content(alert: AlertsComponent.AlertType, modifier: Modifier = Modifier) {
Column(modifier = modifier) {
ContentContainer(
modifier = Modifier
.heightIn(min = TangemTheme.dimens.size180)
.fillMaxWidth()
.padding(horizontal = TangemTheme.dimens.spacing16)
.padding(bottom = 32.dp),
alert = alert,
)
ButtonsContainer(modifier = Modifier.fillMaxWidth(), alert = alert)
}
}
@Composable
private fun ContentContainer(alert: AlertsComponent.AlertType, modifier: Modifier = Modifier) {
Column(modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally) {
AlertIcon(alert = alert)
AlertContentTitle(
modifier = Modifier
.fillMaxWidth()
.padding(top = TangemTheme.dimens.spacing24),
alert = alert,
)
AlertContentDescription(
modifier = Modifier
.fillMaxWidth()
.padding(top = TangemTheme.dimens.spacing8),
alert = alert,
)
AlertAudit(alert, modifier = Modifier.padding(top = TangemTheme.dimens.spacing16))
}
}
@Suppress("LongMethod")
@Composable
private fun ButtonsContainer(alert: AlertsComponent.AlertType, modifier: Modifier = Modifier) {
Column(
modifier = modifier.padding(all = TangemTheme.dimens.spacing16),
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8),
) {
val buttonsModifier = Modifier.fillMaxWidth()
when (alert) {
is AlertsComponent.AlertType.UnsafeDomain -> {
PrimaryButton(
modifier = buttonsModifier,
text = stringResourceSafe(R.string.common_cancel),
onClick = alert.onDismiss,
)
SecondaryButton(
modifier = buttonsModifier,
onClick = alert.onConnect,
text = stringResourceSafe(R.string.wc_alert_connect_anyway),
)
}
is AlertsComponent.AlertType.MaliciousTransaction -> {
PrimaryButton(
modifier = buttonsModifier,
text = stringResourceSafe(R.string.common_cancel),
onClick = alert.onDismiss,
)
SecondaryButtonIconEnd(
modifier = buttonsModifier,
onClick = alert.onConnect,
iconResId = R.drawable.ic_tangem_24,
text = stringResourceSafe(R.string.wc_alert_connect_anyway),
)
}
is AlertsComponent.AlertType.UnknownDomain -> {
PrimaryButton(
modifier = buttonsModifier,
text = stringResourceSafe(R.string.common_cancel),
onClick = alert.onDismiss,
)
SecondaryButton(
modifier = buttonsModifier,
onClick = alert.onConnect,
text = stringResourceSafe(R.string.wc_alert_connect_anyway),
)
}
is AlertsComponent.AlertType.VerifiedDomain -> SecondaryButton(
modifier = buttonsModifier,
text = stringResourceSafe(R.string.common_done),
onClick = alert.onDismiss,
)
is AlertsComponent.AlertType.ConnectionTimeout -> {
PrimaryButton(
modifier = buttonsModifier,
onClick = alert.onTryAgain,
text = stringResourceSafe(R.string.alert_button_try_again),
)
SecondaryButton(
modifier = buttonsModifier,
onClick = alert.onDismiss,
text = stringResourceSafe(R.string.balance_hidden_got_it_button),
)
}
is AlertsComponent.AlertType.WrongCardSelected,
is AlertsComponent.AlertType.UnknownError,
-> SecondaryButton(
modifier = buttonsModifier,
onClick = alert.onDismiss,
text = stringResourceSafe(R.string.balance_hidden_got_it_button),
)
is AlertsComponent.AlertType.WcDisconnected,
is AlertsComponent.AlertType.UnsupportedNetworks,
-> PrimaryButton(
modifier = buttonsModifier,
onClick = alert.onDismiss,
text = stringResourceSafe(R.string.balance_hidden_got_it_button),
)
}
}
}
@Composable
private fun AlertIcon(alert: AlertsComponent.AlertType, modifier: Modifier = Modifier) {
val color = when (alert) {
is AlertsComponent.AlertType.VerifiedDomain -> TangemTheme.colors.icon.accent
is AlertsComponent.AlertType.WcDisconnected,
is AlertsComponent.AlertType.ConnectionTimeout,
is AlertsComponent.AlertType.UnsupportedNetworks,
-> TangemTheme.colors.icon.informative
is AlertsComponent.AlertType.WrongCardSelected,
is AlertsComponent.AlertType.UnknownDomain,
is AlertsComponent.AlertType.UnknownError,
-> TangemTheme.colors.icon.attention
is AlertsComponent.AlertType.MaliciousTransaction,
is AlertsComponent.AlertType.UnsafeDomain,
-> TangemTheme.colors.icon.warning
}
@DrawableRes val drawableId = when (alert) {
is AlertsComponent.AlertType.WcDisconnected,
is AlertsComponent.AlertType.ConnectionTimeout,
-> R.drawable.ic_wallet_connect_24
is AlertsComponent.AlertType.MaliciousTransaction -> R.drawable.img_knight_shield_32
is AlertsComponent.AlertType.UnknownDomain,
is AlertsComponent.AlertType.UnsafeDomain,
-> R.drawable.img_knight_shield_32
is AlertsComponent.AlertType.UnsupportedNetworks -> R.drawable.ic_network_new_24
is AlertsComponent.AlertType.WrongCardSelected,
is AlertsComponent.AlertType.UnknownError,
-> R.drawable.img_attention_20
is AlertsComponent.AlertType.VerifiedDomain -> R.drawable.img_approvale2_20
}
val iconTint = when (alert) {
is AlertsComponent.AlertType.UnknownDomain,
is AlertsComponent.AlertType.UnsafeDomain,
is AlertsComponent.AlertType.MaliciousTransaction,
is AlertsComponent.AlertType.UnsupportedNetworks,
is AlertsComponent.AlertType.ConnectionTimeout,
is AlertsComponent.AlertType.WcDisconnected,
-> color
is AlertsComponent.AlertType.VerifiedDomain,
is AlertsComponent.AlertType.UnknownError,
is AlertsComponent.AlertType.WrongCardSelected,
-> Color.Unspecified
}
Box(
modifier = modifier
.size(TangemTheme.dimens.size56)
.clip(CircleShape)
.background(color.copy(alpha = 0.1F)),
contentAlignment = Alignment.Center,
content = {
Icon(
modifier = Modifier.size(TangemTheme.dimens.size32),
painter = painterResource(drawableId),
contentDescription = null,
tint = iconTint,
)
},
)
}
@Composable
private fun AlertContentTitle(alert: AlertsComponent.AlertType, modifier: Modifier = Modifier) {
@StringRes val titleRes: Int = when (alert) {
is AlertsComponent.AlertType.UnknownDomain,
is AlertsComponent.AlertType.UnsafeDomain,
is AlertsComponent.AlertType.MaliciousTransaction,
-> R.string.security_alert_title
is AlertsComponent.AlertType.ConnectionTimeout -> R.string.wc_alert_connection_timeout_title
is AlertsComponent.AlertType.UnknownError -> R.string.wc_alert_unknown_error_title
is AlertsComponent.AlertType.UnsupportedNetworks -> R.string.wc_alert_unsupported_networks_title
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
}
Text(
modifier = modifier,
text = stringResourceSafe(titleRes),
style = TangemTheme.typography.h3,
color = TangemTheme.colors.text.primary1,
textAlign = TextAlign.Center,
)
}
@Composable
private fun AlertContentDescription(alert: AlertsComponent.AlertType, modifier: Modifier = Modifier) {
val message = when (alert) {
is AlertsComponent.AlertType.ConnectionTimeout -> stringResourceSafe(
R.string.wc_alert_connection_timeout_description,
)
is AlertsComponent.AlertType.MaliciousTransaction -> alert.descriptionMessage
is AlertsComponent.AlertType.UnknownDomain,
is AlertsComponent.AlertType.UnsafeDomain,
-> stringResourceSafe(R.string.wc_alert_domain_issues_description)
is AlertsComponent.AlertType.UnknownError -> stringResourceSafe(
R.string.wc_alert_unknown_error_description,
alert.errorCode,
)
is AlertsComponent.AlertType.UnsupportedNetworks -> stringResourceSafe(
R.string.wc_alert_unsupported_networks_description,
alert.appName,
)
is AlertsComponent.AlertType.VerifiedDomain -> stringResourceSafe(
R.string.wc_alert_verified_domain_description,
alert.appName,
)
is AlertsComponent.AlertType.WcDisconnected -> stringResourceSafe(
R.string.wc_alert_session_disconnected_description,
)
is AlertsComponent.AlertType.WrongCardSelected -> stringResourceSafe(R.string.wc_alert_wrong_card_description)
}
Text(
modifier = modifier,
text = message,
style = TangemTheme.typography.body2,
color = TangemTheme.colors.text.secondary,
textAlign = TextAlign.Center,
)
}
@Composable
private fun AlertAudit(alert: AlertsComponent.AlertType, modifier: Modifier = Modifier) {
when (alert) {
is AlertsComponent.AlertType.UnknownDomain -> Text(
modifier = modifier
.background(
shape = RoundedCornerShape(TangemTheme.dimens.radius16),
color = TangemTheme.colors.text.primary1.copy(alpha = 0.1F),
)
.padding(vertical = TangemTheme.dimens.spacing4, horizontal = TangemTheme.dimens.spacing12),
text = stringResourceSafe(R.string.wc_alert_audit_unknown_domain),
style = TangemTheme.typography.caption1,
color = TangemTheme.colors.text.primary1,
)
is AlertsComponent.AlertType.UnsafeDomain -> Text(
modifier = Modifier
.padding(top = TangemTheme.dimens.spacing16)
.background(
shape = RoundedCornerShape(TangemTheme.dimens.radius16),
color = TangemTheme.colors.text.warning.copy(alpha = 0.1F),
)
.padding(vertical = TangemTheme.dimens.spacing4, horizontal = TangemTheme.dimens.spacing12),
text = stringResourceSafe(R.string.wc_alert_audit_unknown_domain),
style = TangemTheme.typography.caption1,
color = TangemTheme.colors.text.warning,
)
is AlertsComponent.AlertType.ConnectionTimeout,
is AlertsComponent.AlertType.MaliciousTransaction,
is AlertsComponent.AlertType.UnknownError,
is AlertsComponent.AlertType.UnsupportedNetworks,
is AlertsComponent.AlertType.VerifiedDomain,
is AlertsComponent.AlertType.WcDisconnected,
is AlertsComponent.AlertType.WrongCardSelected,
-> Unit
}
}
@Preview(showBackground = true)
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun AlertsModalBottomSheet_Preview(
@PreviewParameter(AlertTypesProvider::class) alert: AlertsComponent.AlertType,
) {
TangemThemePreview {
AlertsModalBottomSheet(
config = TangemBottomSheetConfig(
isShown = true,
onDismissRequest = {},
content = alert,
),
)
}
}
private class AlertTypesProvider : CollectionPreviewParameterProvider<AlertsComponent.AlertType>(
collection = listOf(
AlertsComponent.AlertType.VerifiedDomain(appName = "React App", onDismiss = {}),
AlertsComponent.AlertType.UnknownDomain(onConnect = {}, onDismiss = {}),
AlertsComponent.AlertType.UnsafeDomain(onConnect = {}, onDismiss = {}),
AlertsComponent.AlertType.MaliciousTransaction(
descriptionMessage = "The transaction approves erc20 tokens to a known malicious address",
onConnect = {},
onDismiss = {},
),
AlertsComponent.AlertType.UnsupportedNetworks(appName = "React App", onDismiss = {}),
AlertsComponent.AlertType.WcDisconnected(onDismiss = {}),
AlertsComponent.AlertType.UnknownError(errorCode = 8005, onDismiss = {}),
AlertsComponent.AlertType.WrongCardSelected(onDismiss = {}),
AlertsComponent.AlertType.ConnectionTimeout(onTryAgain = {}, onDismiss = {}),
),
)