Updated on 2026-08-14

This commit is contained in:
Tangem 2023-12-22 17:06:53 +03:00
parent 81777ad79e
commit a223c140cf
17 changed files with 890 additions and 24 deletions

View file

@ -265,7 +265,6 @@
<string name="manage_tokens_title">Рыночная капитализация</string>
<string name="manage_tokens_unavailable_description">Выбранный токен не доступен в кошельке на данный момент. Но не переживайте, вы можете выразить свой интерес проголосовав за его добавление.</string>
<string name="manage_tokens_unavailable_vote">Голосовать</string>
<string name="manage_tokens_wallet_does_not_supported_blockchain">Кошелек не поддерживает выбранную монету</string>
<string name="manage_tokens_wallet_selector_title">Выберите кошелек</string>
<string name="manage_tokens_wallet_support_only_one_network_title">Кошелёк не поддерживает более одной сети</string>
<string name="onboarding_access_code_feature_1_description">Вам необходимо установить единый код доступа для защиты всех ваших карт</string>

View file

@ -286,7 +286,6 @@
<string name="manage_tokens_title">Coin market cap</string>
<string name="manage_tokens_unavailable_description">The selected token is currently unavailable for actions within the crypto wallet. But worry not, you can express your interest by upvoting it.</string>
<string name="manage_tokens_unavailable_vote">Upvote</string>
<string name="manage_tokens_wallet_does_not_supported_blockchain">Wallet Incompatible with selected Coin</string>
<string name="manage_tokens_wallet_selector_title">Choose wallet</string>
<string name="manage_tokens_wallet_support_only_one_network_title">The wallet doesn\'t support more than one network</string>
<string name="onboarding_access_code_feature_1_description">You have to set up a single access code to protect all your wallets</string>

View file

@ -5,13 +5,13 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.ButtonColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.tooling.preview.Preview
import com.tangem.core.ui.R
import com.tangem.core.ui.components.buttons.common.*
import com.tangem.core.ui.components.buttons.common.TangemButtonsDefaults
import com.tangem.core.ui.res.TangemTheme
// region TextButton
@ -19,7 +19,13 @@ import com.tangem.core.ui.res.TangemTheme
* [Show in Figma](https://www.figma.com/file/14ISV23YB1yVW1uNVwqrKv/Android?node-id=97%3A103&t=TmfD6UBHPg9uYfev-4)
* */
@Composable
fun TextButton(text: String, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true) {
fun TextButton(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
colors: ButtonColors = TangemButtonsDefaults.defaultTextButtonColors,
enabled: Boolean = true,
) {
TangemButton(
modifier = modifier,
text = text,
@ -27,7 +33,7 @@ fun TextButton(text: String, onClick: () -> Unit, modifier: Modifier = Modifier,
onClick = onClick,
enabled = enabled,
showProgress = false,
colors = TangemButtonsDefaults.defaultTextButtonColors,
colors = colors,
size = TangemButtonSize.Text,
)
}
@ -41,6 +47,7 @@ fun TextButtonIconStart(
@DrawableRes iconResId: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
colors: ButtonColors = TangemButtonsDefaults.defaultTextButtonColors,
enabled: Boolean = true,
) {
TangemButton(
@ -50,7 +57,7 @@ fun TextButtonIconStart(
onClick = onClick,
enabled = enabled,
showProgress = false,
colors = TangemButtonsDefaults.defaultTextButtonColors,
colors = colors,
size = TangemButtonSize.Text,
)
}

View file

@ -7,9 +7,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material.RadioButton
import androidx.compose.material.RadioButtonDefaults
import androidx.compose.material.Text
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.remember
@ -24,6 +22,8 @@ import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.tangem.core.ui.R
import com.tangem.core.ui.components.SelctorDialogParamsProvider.SelectorDialogParams
import com.tangem.core.ui.components.buttons.common.TangemButtonsDefaults
import com.tangem.core.ui.components.fields.SimpleDialogTextField
import com.tangem.core.ui.res.TangemTheme
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
@ -118,6 +118,34 @@ fun TextInputDialog(
)
}
@Composable
fun TextInputDialog(
fieldValue: String,
confirmButton: DialogButton,
onDismissDialog: () -> Unit,
onValueChange: (String) -> Unit,
textFieldParams: AdditionalTextInputDialogParams,
title: String? = null,
dismissButton: DialogButton? = null,
isDismissable: Boolean = true,
) {
TangemDialog(
type = DialogType.SimpleTextInput(
value = fieldValue,
onValueChange = onValueChange,
params = textFieldParams,
),
confirmButton = confirmButton,
onDismissDialog = onDismissDialog,
title = title,
dismissButton = dismissButton,
properties = DialogProperties(
dismissOnBackPress = isDismissable,
dismissOnClickOutside = isDismissable,
),
)
}
@Composable
fun SelectorDialog(
selectedItemIndex: Int,
@ -164,6 +192,7 @@ data class AdditionalTextInputDialogParams(
val caption: String? = null,
val enabled: Boolean = true,
val isError: Boolean = false,
val errorText: String? = null,
)
// region Defaults
@ -194,6 +223,7 @@ private fun TangemDialog(
style = when (type) {
is DialogType.Message -> TangemTheme.typography.h2
is DialogType.TextInput -> TangemTheme.typography.h3
is DialogType.SimpleTextInput -> TangemTheme.typography.h3
is DialogType.Selector -> TangemTheme.typography.h2
},
color = TangemTheme.colors.text.primary1,
@ -231,6 +261,16 @@ private fun DialogContent(type: DialogType, modifier: Modifier = Modifier) {
color = TangemTheme.colors.text.secondary,
)
}
is DialogType.SimpleTextInput -> {
SimpleDialogTextField(
value = type.value,
onValueChange = type.onValueChange,
isError = type.params.isError,
errorText = type.params.errorText,
isEnabled = type.params.enabled,
placeholder = type.params.placeholder,
)
}
is DialogType.TextInput -> {
OutlineTextField(
modifier = Modifier
@ -305,6 +345,7 @@ private fun DialogButton(
text = text,
enabled = enabled,
onClick = onClick,
colors = TangemButtonsDefaults.positiveButtonColors,
)
}
}
@ -371,6 +412,12 @@ private sealed class DialogType {
val params: AdditionalTextInputDialogParams = AdditionalTextInputDialogParams(),
) : DialogType()
data class SimpleTextInput(
val value: String,
val onValueChange: (String) -> Unit,
val params: AdditionalTextInputDialogParams = AdditionalTextInputDialogParams(),
) : DialogType()
data class Selector(
val selectedItemIndex: Int,
val items: ImmutableList<String>,

View file

@ -66,4 +66,14 @@ internal object TangemButtonsDefaults {
disabledBackgroundColor = Color.Transparent,
disabledContentColor = TangemTheme.colors.text.disabled,
)
val positiveButtonColors: ButtonColors
@Composable
@ReadOnlyComposable
get() = TangemButtonColors(
backgroundColor = Color.Transparent,
contentColor = TangemTheme.colors.text.accent,
disabledBackgroundColor = Color.Transparent,
disabledContentColor = TangemTheme.colors.text.disabled,
)
}

View file

@ -0,0 +1,97 @@
package com.tangem.core.ui.components.fields
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.SolidColor
import com.tangem.core.ui.res.TangemTheme
/**
* A simple input field for a basic dialog with input
*
* [Show in Figma] (https://www.figma.com/file/14ISV23YB1yVW1uNVwqrKv/Android?type=design&node-id=48%3A30&mode=design
* &t=OsU3Nqsm9d8WDNuv-1)
*/
@Composable
fun SimpleDialogTextField(
value: String,
onValueChange: (String) -> Unit,
isError: Boolean = false,
errorText: String? = null,
isEnabled: Boolean = true,
placeholder: String? = null,
) {
val strokeColor = if (isError) {
TangemTheme.colors.icon.warning
} else {
TangemTheme.colors.stroke.primary
}
Column {
BasicTextField(
value = value,
onValueChange = onValueChange,
textStyle = TangemTheme.typography.body1,
cursorBrush = SolidColor(TangemTheme.colors.text.primary1),
singleLine = true,
readOnly = !isEnabled,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = TangemTheme.dimens.spacing24)
.drawBehind {
val strokeWidth = 2f
val y = size.height - strokeWidth / 2
drawLine(
strokeColor,
Offset(0f, y),
Offset(size.width, y),
strokeWidth,
)
},
decorationBox = { textValue ->
Box {
this@Column.AnimatedVisibility(
visible = value.isBlank() && placeholder != null,
enter = fadeIn(),
exit = fadeOut(),
) {
if (value.isBlank() && placeholder != null) {
Text(
text = placeholder,
style = TangemTheme.typography.body1,
color = TangemTheme.colors.text.disabled,
)
}
}
textValue()
}
},
)
AnimatedVisibility(
visible = errorText != null,
enter = fadeIn(),
exit = fadeOut(),
) {
if (errorText != null) {
Text(
text = errorText,
style = TangemTheme.typography.caption2,
color = TangemTheme.colors.text.warning,
modifier = Modifier
.padding(
horizontal = TangemTheme.dimens.spacing24,
),
)
}
}
}
}