Updated on 2026-08-14
This commit is contained in:
parent
d630852c29
commit
30ed01cb2f
6 changed files with 13 additions and 273 deletions
|
|
@ -1,176 +0,0 @@
|
|||
package com.tangem.core.ui.components
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.res.ButtonColorType
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TextColorType
|
||||
import com.tangem.core.ui.res.buttonColor
|
||||
import com.tangem.core.ui.res.textColor
|
||||
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true)
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun Preview_PrimaryStartIconButton_Enabled() {
|
||||
TangemThemePreview {
|
||||
PrimaryStartIconButton(
|
||||
text = "Manage tokens",
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
enabled = true,
|
||||
onClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true)
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun Preview_PrimaryStartIconButton_Disabled() {
|
||||
TangemThemePreview {
|
||||
PrimaryStartIconButton(
|
||||
text = "Manage tokens",
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
enabled = false,
|
||||
onClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true)
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun Preview_PrimaryEndIconButton_Enabled() {
|
||||
TangemThemePreview {
|
||||
PrimaryEndIconButton(
|
||||
text = "Manage tokens",
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
enabled = true,
|
||||
onClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true)
|
||||
@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun Preview_PrimaryEndIconButton_Disabled() {
|
||||
TangemThemePreview {
|
||||
PrimaryEndIconButton(
|
||||
text = "Manage tokens",
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
enabled = false,
|
||||
onClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary button with an icon at the beginning of the layout
|
||||
*
|
||||
* @param modifier button modifier
|
||||
* @param text button text
|
||||
* @param iconResId button icon res id
|
||||
* @param enabled controls the enabled state of the button
|
||||
* @param onClick the lambda to be invoked when this button is pressed
|
||||
*
|
||||
* @see <a href = "https://www.figma.com/file/14ISV23YB1yVW1uNVwqrKv/Android?node-id=233%3A258&t=WdN5XpixzZLlQAZO-4"
|
||||
* >Figma component</a>
|
||||
*/
|
||||
@Deprecated("Use PrimaryButtonIconRight instead")
|
||||
@Composable
|
||||
fun PrimaryStartIconButton(
|
||||
text: String,
|
||||
@DrawableRes iconResId: Int,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
) {
|
||||
PrimaryButtonRow(
|
||||
modifier = modifier,
|
||||
enabled = enabled,
|
||||
onClick = onClick,
|
||||
content = {
|
||||
Icon(
|
||||
painter = painterResource(id = iconResId),
|
||||
contentDescription = null,
|
||||
)
|
||||
SpacerW8()
|
||||
Text(text = text)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary button with an icon at the end of the layout
|
||||
*
|
||||
* @param modifier button modifier
|
||||
* @param text button text
|
||||
* @param iconResId button icon res id
|
||||
* @param enabled controls the enabled state of the button
|
||||
* @param onClick the lambda to be invoked when this button is pressed
|
||||
*
|
||||
* @see <a href = "https://www.figma.com/file/14ISV23YB1yVW1uNVwqrKv/Android?node-id=68%3A47&t=WdN5XpixzZLlQAZO-4"
|
||||
* >Figma component</a>
|
||||
*/
|
||||
@Deprecated("Use PrimaryButtonIconLeft instead")
|
||||
@Composable
|
||||
fun PrimaryEndIconButton(
|
||||
text: String,
|
||||
@DrawableRes iconResId: Int,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
) {
|
||||
PrimaryButtonRow(
|
||||
modifier = modifier,
|
||||
enabled = enabled,
|
||||
onClick = onClick,
|
||||
content = {
|
||||
Text(text = text)
|
||||
SpacerW8()
|
||||
Icon(
|
||||
painter = painterResource(id = iconResId),
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PrimaryButtonRow(
|
||||
enabled: Boolean,
|
||||
onClick: () -> Unit,
|
||||
content: @Composable (RowScope.() -> Unit),
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Button(
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.height(TangemTheme.dimens.size48),
|
||||
enabled = enabled,
|
||||
shape = RoundedCornerShape(TangemTheme.dimens.radius12),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = MaterialTheme.colors.buttonColor(type = ButtonColorType.PRIMARY),
|
||||
contentColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2),
|
||||
disabledBackgroundColor = MaterialTheme.colors.buttonColor(type = ButtonColorType.DISABLED),
|
||||
disabledContentColor = MaterialTheme.colors.textColor(type = TextColorType.DISABLED),
|
||||
),
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.tangem.core.ui.res
|
||||
|
||||
import androidx.compose.material.Colors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark5
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark6
|
||||
import com.tangem.core.ui.res.TangemColorPalette.DarkGreen
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Light1
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Light2
|
||||
import com.tangem.core.ui.res.TangemColorPalette.MagicMint
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Meadow
|
||||
|
||||
@Deprecated("Use TangemTheme.colors")
|
||||
enum class ButtonColorType(val lightColor: Color, val darkColor: Color) {
|
||||
PRIMARY(lightColor = Dark6, darkColor = Light1),
|
||||
SECONDARY(lightColor = Light2, darkColor = Dark5),
|
||||
DISABLED(lightColor = Light2, darkColor = Dark6),
|
||||
POSITIVE(lightColor = Meadow, darkColor = Meadow),
|
||||
POSITIVE_DISABLED(lightColor = MagicMint, darkColor = DarkGreen),
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Colors.buttonColor(type: ButtonColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package com.tangem.core.ui.res
|
||||
|
||||
import androidx.compose.material.Colors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Amaranth
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Azure
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Black
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark1
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark2
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark4
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark6
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Light4
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Light5
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Mustard
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Tangerine
|
||||
import com.tangem.core.ui.res.TangemColorPalette.White
|
||||
|
||||
@Deprecated("Use TangemTheme.colors")
|
||||
enum class IconColorType(val lightColor: Color, val darkColor: Color) {
|
||||
PRIMARY1(lightColor = Black, darkColor = White),
|
||||
PRIMARY2(lightColor = White, darkColor = Dark6),
|
||||
SECONDARY(lightColor = Dark2, darkColor = Dark1),
|
||||
INFORMATIVE(lightColor = Light5, darkColor = Dark2),
|
||||
INACTIVE(lightColor = Light4, darkColor = Dark4),
|
||||
ACCENT(lightColor = Azure, darkColor = Azure),
|
||||
WARNING(lightColor = Amaranth, darkColor = Amaranth),
|
||||
ATTENTION(lightColor = Tangerine, darkColor = Mustard),
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Colors.iconColor(type: IconColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package com.tangem.core.ui.res
|
||||
|
||||
import androidx.compose.material.Colors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Amaranth
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark1
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark2
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark3
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark6
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Light4
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Light5
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Meadow
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Mustard
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Tangerine
|
||||
import com.tangem.core.ui.res.TangemColorPalette.White
|
||||
|
||||
@Deprecated("Use TangemTheme.colors")
|
||||
enum class TextColorType(val lightColor: Color, val darkColor: Color) {
|
||||
PRIMARY1(lightColor = Dark6, darkColor = White),
|
||||
PRIMARY2(lightColor = White, darkColor = Dark6),
|
||||
SECONDARY(lightColor = Dark2, darkColor = Light5),
|
||||
TERTIARY(lightColor = Dark1, darkColor = Dark1),
|
||||
DISABLED(lightColor = Light4, darkColor = Dark3),
|
||||
ACCENT(lightColor = Meadow, darkColor = Meadow),
|
||||
WARNING(lightColor = Amaranth, darkColor = Amaranth),
|
||||
ATTENTION(lightColor = Tangerine, darkColor = Mustard),
|
||||
CONSTANT_WHITE(lightColor = White, darkColor = White),
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Colors.textColor(type: TextColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor
|
||||
Loading…
Add table
Add a link
Reference in a new issue