Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-01 09:30:03 +02:00
parent e2af488b32
commit 8ffbfc27e7
9 changed files with 510 additions and 6 deletions

View file

@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
@ -35,6 +36,7 @@ import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.core.ui.test.AddCustomTokenScreenTestTags
import com.tangem.features.managetokens.component.preview.PreviewCustomTokenFormComponent
import com.tangem.features.managetokens.entity.customtoken.ClickableFieldUM
import com.tangem.features.managetokens.entity.customtoken.CustomTokenFormUM
@ -122,11 +124,15 @@ private fun FormContent(model: CustomTokenFormUM, modifier: Modifier = Modifier)
val derivationPath = model.derivationPath
if (derivationPath != null) {
ClickableField(model = derivationPath)
ClickableField(
modifier = Modifier.testTag(AddCustomTokenScreenTestTags.DERIVATION_SELECTOR_FIELD),
model = derivationPath,
)
}
model.notifications.fastForEach { notification ->
Notification(
modifier = Modifier.testTag(AddCustomTokenScreenTestTags.WARNING_NOTIFICATION),
config = notification.config,
containerColor = TangemTheme.colors.button.disabled,
)
@ -143,14 +149,19 @@ private fun TokenForm(tokenForm: CustomTokenFormUM.TokenFormUM, modifier: Modifi
shape = TangemTheme.shapes.roundedCornersXMedium,
),
) {
tokenForm.fields.values.forEach { field ->
TextField(model = field)
tokenForm.fields.forEach { (key, field) ->
TextField(
model = field,
fieldTestTag = AddCustomTokenScreenTestTags.CONTRACT_ADDRESS_FIELD.takeIf {
key == Field.CONTRACT_ADDRESS
},
)
}
}
}
@Composable
private fun TextField(model: TextInputFieldUM, modifier: Modifier = Modifier) {
private fun TextField(model: TextInputFieldUM, modifier: Modifier = Modifier, fieldTestTag: String? = null) {
InformationBlock(
modifier = modifier,
title = {
@ -192,6 +203,7 @@ private fun TextField(model: TextInputFieldUM, modifier: Modifier = Modifier) {
modifier = Modifier
.padding(bottom = TangemTheme.dimens.spacing12)
.fillMaxWidth()
.then(if (fieldTestTag != null) Modifier.testTag(fieldTestTag) else Modifier)
.onFocusChanged {
model.onFocusChange(it.isFocused)
},

View file

@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
@ -30,6 +31,7 @@ import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.core.ui.test.AddCustomTokenScreenTestTags
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.features.managetokens.component.AddCustomTokenMode
@ -50,6 +52,7 @@ internal fun CustomTokenSelectorContent(model: CustomTokenSelectorUM, modifier:
LazyColumn(
modifier = modifier
.testTag(AddCustomTokenScreenTestTags.SELECTOR_LIST)
.background(color = TangemTheme.colors.background.secondary)
.bottomFade(),
contentPadding = PaddingValues(
@ -92,7 +95,7 @@ internal fun CustomTokenSelectorContent(model: CustomTokenSelectorUM, modifier:
when (item) {
is CurrencyNetworkUM -> {
NetworkItem(
modifier = itemModifier,
modifier = itemModifier.testTag(AddCustomTokenScreenTestTags.networkRow(item.name)),
model = item,
)
}
@ -112,7 +115,9 @@ private fun Header(header: CustomTokenSelectorUM.HeaderUM, modifier: Modifier =
when (header) {
is CustomTokenSelectorUM.HeaderUM.CustomDerivationButton -> {
CustomDerivationButton(
modifier = modifier.padding(vertical = TangemTheme.dimens.spacing16),
modifier = modifier
.padding(vertical = TangemTheme.dimens.spacing16)
.testTag(AddCustomTokenScreenTestTags.CUSTOM_DERIVATION_BUTTON),
enteredDerivationPath = header.value,
isSelected = header.value != null,
onClick = header.onClick,