diff --git a/app/src/main/java/com/tangem/tap/common/compose/Warning.kt b/app/src/main/java/com/tangem/tap/common/compose/Warning.kt new file mode 100644 index 0000000000..8ea4eceef2 --- /dev/null +++ b/app/src/main/java/com/tangem/tap/common/compose/Warning.kt @@ -0,0 +1,53 @@ +package com.tangem.tap.common.compose + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.tangem.common.module.ModuleMessage +import com.tangem.tap.common.moduleMessage.ModuleMessageConverter +import com.tangem.wallet.R + +/** +[REDACTED_AUTHOR] + */ +@Composable +fun AddCustomTokenWarning( + modifier: Modifier = Modifier, + warning: ModuleMessage, + converter: ModuleMessageConverter +) { + Surface( + modifier = modifier, + shape = MaterialTheme.shapes.small, + color = colorResource(id = R.color.warning_warning), + elevation = 4.dp, + ) { + Column( + modifier = Modifier.padding(16.dp), + ) { + Text( + text = stringResource(id = R.string.common_warning), + color = colorResource(id = R.color.white), + fontSize = 14.sp, + fontWeight = FontWeight.Bold + ) + SpacerH8() + Text( + text = converter.convert(warning), + color = colorResource(id = R.color.white), + fontSize = 13.sp, + lineHeight = 18.sp + ) + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/AddCustomTokenScreen.kt b/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/AddCustomTokenScreen.kt index ea27e5137f..8463eba5ac 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/AddCustomTokenScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/AddCustomTokenScreen.kt @@ -12,7 +12,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import com.tangem.domain.AddCustomTokenError import com.tangem.domain.common.form.DataField import com.tangem.domain.common.form.FieldId @@ -22,6 +21,7 @@ import com.tangem.domain.features.addCustomToken.redux.AddCustomTokenState import com.tangem.domain.features.addCustomToken.redux.ScreenState import com.tangem.domain.features.addCustomToken.redux.ViewStates import com.tangem.domain.redux.domainStore +import com.tangem.tap.common.compose.AddCustomTokenWarning import com.tangem.tap.common.compose.ComposeDialogManager import com.tangem.tap.common.compose.ToggledRippleTheme import com.tangem.tap.common.compose.keyboardAsState @@ -51,7 +51,7 @@ fun AddCustomTokenScreen(state: MutableState) { LazyColumn( contentPadding = PaddingValues(bottom = 90.dp) ) { -// item { AddCustomTokenDebugActions() } + item { AddCustomTokenDebugActions() } item { Surface( modifier = Modifier.padding(16.dp), @@ -110,19 +110,11 @@ fun Warnings(warnings: List) { warnings.lastIndex -> Modifier.padding(16.dp, 8.dp, 16.dp, 16.dp) else -> Modifier.padding(16.dp, 8.dp, 16.dp, 0.dp) } - Surface( + AddCustomTokenWarning( modifier = modifier.fillMaxWidth(), - shape = MaterialTheme.shapes.small, - color = colorResource(id = R.color.warning_warning), - elevation = 4.dp, - ) { - Text( - modifier = Modifier.padding(16.dp), - text = warningConverter.convert(item), - color = colorResource(id = R.color.white), - fontSize = 14.sp - ) - } + warning = item, + converter = warningConverter + ) } } } diff --git a/domain/src/main/java/com/tangem/domain/common/form/FieldsValidators.kt b/domain/src/main/java/com/tangem/domain/common/form/FieldsValidators.kt index 259714abca..f526b968ab 100644 --- a/domain/src/main/java/com/tangem/domain/common/form/FieldsValidators.kt +++ b/domain/src/main/java/com/tangem/domain/common/form/FieldsValidators.kt @@ -47,9 +47,13 @@ class TokenContractAddressValidator : CustomTokenValidator() { private fun getAddressService(): AddressService { return when (blockchain) { Blockchain.Solana, Blockchain.SolanaTestnet -> SolanaAddressService() + Blockchain.Unknown -> EthereumAddressService() else -> { - if (blockchain.isEvm()) EthereumAddressService() - else throw UnsupportedOperationException() + if (blockchain.isEvm()) { + EthereumAddressService() + } else { + throw UnsupportedOperationException() + } } } }