Updated on 2026-08-14

This commit is contained in:
Tangem 2023-01-18 18:05:18 +08:00
parent e98780ff93
commit 479d142807
283 changed files with 2338 additions and 2730 deletions

View file

@ -232,6 +232,7 @@ fun SecondaryButtonIconLeft(
}
// region Defaults
@Suppress("LongParameterList")
@Composable
private fun TangemButton(
modifier: Modifier = Modifier,
@ -286,29 +287,31 @@ private fun ButtonContent(
)
}
if (showProgress) Box(
modifier = Modifier.wrapContentSize(),
) {
CircularProgressIndicator(
modifier = Modifier
.align(Alignment.Center)
.size(TangemTheme.dimens.size24),
color = colors.contentColor(enabled = enabled).value,
strokeWidth = TangemTheme.dimens.size4,
)
} else Row {
if (buttonIcon is TangemButtonIcon.Left) {
icon(buttonIcon.painter)
Spacer(modifier = Modifier.width(TangemTheme.dimens.size8))
if (showProgress) {
Box(modifier = Modifier.wrapContentSize()) {
CircularProgressIndicator(
modifier = Modifier
.align(Alignment.Center)
.size(TangemTheme.dimens.size24),
color = colors.contentColor(enabled = enabled).value,
strokeWidth = TangemTheme.dimens.size4,
)
}
Text(
text = text,
style = TangemTypography.button,
color = colors.contentColor(enabled = enabled).value,
)
if (buttonIcon is TangemButtonIcon.Right) {
Spacer(modifier = Modifier.width(TangemTheme.dimens.size8))
icon(buttonIcon.painter)
} else {
Row {
if (buttonIcon is TangemButtonIcon.Left) {
icon(buttonIcon.painter)
Spacer(modifier = Modifier.width(TangemTheme.dimens.size8))
}
Text(
text = text,
style = TangemTypography.button,
color = colors.contentColor(enabled = enabled).value,
)
if (buttonIcon is TangemButtonIcon.Right) {
Spacer(modifier = Modifier.width(TangemTheme.dimens.size8))
icon(buttonIcon.painter)
}
}
}
}

View file

@ -142,7 +142,8 @@ fun SmallInfoCardWithWarning(
* @param icon icon to the left
* @param additionalContent shown at the right edge of the card
*
* @see <a href = "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A4040&t=izokIIb9WWetO32R-1"
* @see <a href =
* "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A4040&t=izokIIb9WWetO32R-1"
* >Figma component</a>
*/
@Composable
@ -177,7 +178,8 @@ fun CardWithIcon(
* @param icon icon to the left
* @param additionalContent shown at the right edge of the card
*
* @see <a href = "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A4040&t=izokIIb9WWetO32R-1"
* @see <a href =
* "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A4040&t=izokIIb9WWetO32R-1"
* >Figma component</a>
*/
@Composable
@ -290,6 +292,7 @@ private fun CardInfoBox(
// region Preview
@Suppress("MagicNumber")
@Composable
private fun CardsPreview() {
Column(modifier = Modifier.fillMaxWidth()) {
@ -300,8 +303,8 @@ private fun CardsPreview() {
SmallInfoCardWithWarning(
startText = "Balance",
endText = "0.4405434 BTC",
warningText =
"Not enough funds for fee on your Polygon wallet to create a transaction. Top up your Polygon wallet first.",
warningText = "Not enough funds for fee on your Polygon wallet to create a transaction. " +
"Top up your Polygon wallet first.",
)
SpacerH32()

View file

@ -102,7 +102,8 @@ private fun SimpleOkDialogPreview() = SimpleOkDialog(
@Composable
private fun BasicDialogPreview() = BasicDialog(
message = "All protected passwords will be deleted from the secure storage, you must enter the wallet password to work with the app",
message = "All protected passwords will be deleted from the secure storage, you must enter the wallet password " +
"to work with the app",
title = "Attention",
confirmButton = DialogButton {},
dismissButton = DialogButton {},

View file

@ -18,6 +18,7 @@ sealed class Keyboard {
/**
* Allows to subscribe to a soft keyboard to detect when it's open/closed
*/
@Suppress("MagicNumber")
@Composable
fun keyboardAsState(): State<Keyboard> {
val keyboardState: MutableState<Keyboard> = remember { mutableStateOf(Keyboard.Closed) }

View file

@ -12,6 +12,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp
@Suppress("MagicNumber")
@Composable
fun ResizableText(
text: String,

View file

@ -1,4 +1,4 @@
@file:Suppress("unused")
@file:Suppress("TooManyFunctions")
package com.tangem.core.ui.components
@ -88,6 +88,7 @@ fun ColumnScope.SpacerHMax(modifier: Modifier = Modifier) {
}
// TODO: Refactor with context receivers
@Suppress("MagicNumber")
@Composable
fun ColumnScope.SpacerHHalf(modifier: Modifier = Modifier) {
Spacer(modifier = modifier.weight(.5f))

View file

@ -40,7 +40,8 @@ import com.tangem.core.ui.res.TangemTheme
* @param onSecondaryButtonClick action on clicking secondary button
* @param onButtonClick action on clicking "Done" button
*
* @see <a href = "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A3863&t=wwR84h5IsMaMsDhq-1"
* @see <a href =
* "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A3863&t=wwR84h5IsMaMsDhq-1"
* >Figma component</a>
*/
@Composable
@ -113,8 +114,7 @@ fun SuccessImage(
Box(
modifier = Modifier
.background(
color = (resultColor)
.copy(alpha = 0.2f),
color = resultColor.copy(alpha = 0.2f),
shape = CircleShape,
),
contentAlignment = Alignment.Center,

View file

@ -79,6 +79,7 @@ fun OutlineTextField(
}
// region Defaults
@Suppress("LongMethod")
@Composable
private fun TangemTextField(
modifier: Modifier = Modifier,

View file

@ -48,7 +48,8 @@ import com.tangem.core.ui.res.TangemTheme
* @param onSearchChanged action when search is modified
* @param onSearchDisplayClosed action when search is closed
*
* @see <a href = "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A4068&t=xj8BBj5DfCWn2Mli-1"
* @see <a href =
* "https://www.figma.com/file/Vs6SkVsFnUPsSCNwlnVf5U/Android-%E2%80%93-UI?node-id=1123%3A4068&t=xj8BBj5DfCWn2Mli-1"
* >Figma component</a>
*/
@Composable
@ -89,15 +90,6 @@ fun ExpandableSearchView(
}
}
@Composable
private fun SearchIcon(iconTint: Color) {
Icon(
painter = painterResource(id = R.drawable.ic_search_24),
contentDescription = null,
tint = iconTint,
)
}
@Composable
private fun CollapsedSearchView(
modifier: Modifier = Modifier,
@ -151,16 +143,13 @@ private fun ExpandedSearchView(
tint: Color = TangemTheme.colors.background.primary,
) {
val focusManager = LocalFocusManager.current
val textFieldFocusRequester = remember { FocusRequester() }
SideEffect {
textFieldFocusRequester.requestFocus()
}
var textFieldValue by remember {
mutableStateOf(TextFieldValue("", TextRange("".length)))
}
var textFieldValue by remember { mutableStateOf(TextFieldValue("", TextRange("".length))) }
Row(
modifier = modifier
@ -194,22 +183,17 @@ private fun ExpandedSearchView(
placeholder = {
Text(text = placeholderSearchText)
},
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done,
),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
},
onDone = { focusManager.clearFocus() },
),
colors = TangemTextFieldsDefault.defaultTextFieldColors.copy(
placeholderColor = TangemTheme.colors.text.disabled,
cursorColor = TangemTheme.colors.text.tertiary,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent,
),
colors = TangemTextFieldsDefault.defaultTextFieldColors
.copy(
placeholderColor = TangemTheme.colors.text.disabled,
cursorColor = TangemTheme.colors.text.tertiary,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent,
),
)
}
}

View file

@ -3,6 +3,7 @@ package com.tangem.core.ui.extensions
import androidx.annotation.DrawableRes
import com.tangem.core.ui.R
@Suppress("ComplexMethod")
@DrawableRes
fun getActiveIconRes(blockchainId: String): Int {
return when (blockchainId) {

View file

@ -21,4 +21,4 @@ enum class ButtonColorType(val lightColor: Color, val darkColor: Color) {
}
@Composable
fun Colors.buttonColor(type: ButtonColorType): Color = if (isSystemInDarkTheme) type.darkColor else type.lightColor
fun Colors.buttonColor(type: ButtonColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor

View file

@ -28,4 +28,4 @@ enum class IconColorType(val lightColor: Color, val darkColor: Color) {
}
@Composable
fun Colors.iconColor(type: IconColorType): Color = if (isSystemInDarkTheme) type.darkColor else type.lightColor
fun Colors.iconColor(type: IconColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor

View file

@ -6,7 +6,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
@Suppress("unused", "MemberVisibilityCanBePrivate")
@Suppress("LongParameterList")
@Stable
class TangemColors internal constructor(
text: Text,

View file

@ -4,6 +4,7 @@ import androidx.compose.runtime.Immutable
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Suppress("ConstructorParameterNaming")
@Immutable
data class TangemDimens internal constructor(
// region Elevation

View file

@ -11,7 +11,8 @@ import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
internal val isSystemInDarkTheme: Boolean = false // TODO: use isSystemInDarkTheme() for automatic color detection
// TODO: use isSystemInDarkTheme() for automatic color detection
internal const val IS_SYSTEM_IN_DARK_THEME: Boolean = false
@Composable
fun TangemTheme(

View file

@ -28,4 +28,4 @@ enum class TextColorType(val lightColor: Color, val darkColor: Color) {
}
@Composable
fun Colors.textColor(type: TextColorType): Color = if (isSystemInDarkTheme) type.darkColor else type.lightColor
fun Colors.textColor(type: TextColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor