Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-07 14:56:00 +03:00
parent b5f6af970b
commit 141c7d3936
14 changed files with 66 additions and 64 deletions

View file

@ -121,7 +121,7 @@ class DerivationManagerImpl(
) )
} }
else -> { else -> {
throw IllegalStateException("result result is null") error("result result is null")
} }
} }
} }

View file

@ -93,10 +93,10 @@ class UserWalletManagerImpl(
if (walletManager != null) { if (walletManager != null) {
return walletManager.wallet.address return walletManager.wallet.address
} else { } else {
throw IllegalStateException("no wallet manager found") error("no wallet manager found")
} }
} else { } else {
throw IllegalStateException("no blockchain or card found") error("no blockchain or card found")
} }
} }
@ -119,7 +119,7 @@ class UserWalletManagerImpl(
save = true, save = true,
) )
} else { } else {
throw IllegalStateException("blockchain is not supported") error("blockchain is not supported")
} }
} }
@ -142,7 +142,7 @@ class UserWalletManagerImpl(
save = true, save = true,
) )
} else { } else {
throw IllegalStateException("no card or blockchain found") error("no card or blockchain found")
} }
} }

View file

@ -173,7 +173,7 @@ private fun PrimaryButtonRow(
.fillMaxWidth() .fillMaxWidth()
.height(dimensionResource(R.dimen.size48)), .height(dimensionResource(R.dimen.size48)),
enabled = enabled, enabled = enabled,
shape = RoundedCornerShape(dimensionResource(id = R.dimen.radius12)), shape = RoundedCornerShape(TangemTheme.dimens.radius12),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.buttonColor(type = ButtonColorType.PRIMARY), backgroundColor = MaterialTheme.colors.buttonColor(type = ButtonColorType.PRIMARY),
contentColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2), contentColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2),

View file

@ -47,17 +47,17 @@ fun Preview_SimpleInfoCard_InDarkTheme() {
@Composable @Composable
fun SmallInfoCard(startText: String, endText: String) { fun SmallInfoCard(startText: String, endText: String) {
Surface( Surface(
shape = RoundedCornerShape(dimensionResource(id = R.dimen.radius12)), shape = RoundedCornerShape(TangemTheme.dimens.radius12),
color = MaterialTheme.colors.secondary, color = MaterialTheme.colors.secondary,
elevation = dimensionResource(id = R.dimen.elevation2), elevation = TangemTheme.dimens.elevation2,
) { ) {
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(dimensionResource(R.dimen.size48)) .height(TangemTheme.dimens.size48)
.padding( .padding(
horizontal = dimensionResource(id = R.dimen.spacing16), horizontal = TangemTheme.dimens.spacing16,
vertical = dimensionResource(id = R.dimen.spacing12), vertical = TangemTheme.dimens.spacing12,
), ),
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically

View file

@ -41,15 +41,15 @@ fun AppBarWithAdditionalButtons(
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(dimensionResource(id = R.dimen.size56)) .height(TangemTheme.dimens.size56)
.padding(all = dimensionResource(id = R.dimen.spacing16)), .padding(all = TangemTheme.dimens.spacing16),
) { ) {
if (startButton != null) { if (startButton != null) {
IconButton(modifier = Modifier.align(Alignment.CenterStart), onClick = startButton.onIconClicked) { IconButton(modifier = Modifier.align(Alignment.CenterStart), onClick = startButton.onIconClicked) {
Icon( Icon(
painter = painterResource(id = startButton.iconRes), painter = painterResource(id = startButton.iconRes),
contentDescription = null, contentDescription = null,
modifier = Modifier.size(dimensionResource(id = R.dimen.size24)), modifier = Modifier.size(TangemTheme.dimens.size24),
tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1), tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1),
) )
} }
@ -68,7 +68,7 @@ fun AppBarWithAdditionalButtons(
Icon( Icon(
painter = painterResource(id = endButton.iconRes), painter = painterResource(id = endButton.iconRes),
contentDescription = null, contentDescription = null,
modifier = Modifier.size(dimensionResource(id = R.dimen.size24)), modifier = Modifier.size(TangemTheme.dimens.size24),
tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1), tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1),
) )
} }

View file

@ -29,16 +29,16 @@ fun BottomSheetIndicator() {
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(dimensionResource(id = R.dimen.size20)), .height(TangemTheme.dimens.size20),
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
) { ) {
Box( Box(
modifier = Modifier modifier = Modifier
.width(dimensionResource(id = R.dimen.size32)) .width(TangemTheme.dimens.size32)
.height(dimensionResource(id = R.dimen.size4)) .height(TangemTheme.dimens.size4)
.background( .background(
color = MaterialTheme.colors.iconColor(type = IconColorType.INACTIVE), color = MaterialTheme.colors.iconColor(type = IconColorType.INACTIVE),
shape = RoundedCornerShape(dimensionResource(id = R.dimen.radius2)), shape = RoundedCornerShape(TangemTheme.dimens.radius2),
), ),
) )
} }

View file

@ -22,6 +22,7 @@ data class TangemDimens internal constructor(
val radius2: Dp = 2.dp, val radius2: Dp = 2.dp,
val radius4: Dp = 4.dp, val radius4: Dp = 4.dp,
val radius6: Dp = 6.dp, val radius6: Dp = 6.dp,
val radius8: Dp = 8.dp,
val radius12: Dp = 12.dp, val radius12: Dp = 12.dp,
val radius16: Dp = 16.dp, val radius16: Dp = 16.dp,
val radius28: Dp = 28.dp, val radius28: Dp = 28.dp,
@ -51,11 +52,13 @@ data class TangemDimens internal constructor(
val spacing8: Dp = 8.dp, val spacing8: Dp = 8.dp,
val spacing10: Dp = 10.dp, val spacing10: Dp = 10.dp,
val spacing12: Dp = 12.dp, val spacing12: Dp = 12.dp,
val spacing14: Dp = 14.dp,
val spacing16: Dp = 16.dp, val spacing16: Dp = 16.dp,
val spacing24: Dp = 24.dp, val spacing24: Dp = 24.dp,
val spacing32: Dp = 32.dp, val spacing32: Dp = 32.dp,
val spacing44: Dp = 44.dp, val spacing44: Dp = 44.dp,
val spacing50: Dp = 50.dp, val spacing50: Dp = 50.dp,
val spacing54: Dp = 54.dp, val spacing54: Dp = 54.dp,
val spacing56: Dp = 56.dp,
// endregion Spacing // endregion Spacing
) )

View file

@ -34,7 +34,7 @@ internal class ReferralInteractorImpl(
address = publicAddress, address = publicAddress,
) )
} else { } else {
throw IllegalStateException("tokens for ref is empty") error("tokens for ref is empty")
} }
} }

View file

@ -34,7 +34,7 @@ internal fun AgreementBottomSheetContent(url: String) {
modifier = Modifier modifier = Modifier
.background(color = MaterialTheme.colors.secondary) .background(color = MaterialTheme.colors.secondary)
.fillMaxWidth() .fillMaxWidth()
.height(LocalConfiguration.current.screenHeightDp.dp - dimensionResource(id = R.dimen.spacing16)), .height(LocalConfiguration.current.screenHeightDp.dp - TangemTheme.dimens.spacing16),
) { ) {
BottomSheetIndicator() BottomSheetIndicator()
Column(modifier = Modifier.verticalScroll(rememberScrollState())) { Column(modifier = Modifier.verticalScroll(rememberScrollState())) {

View file

@ -29,7 +29,7 @@ internal fun AgreementText(@StringRes firstPartResId: Int, onClicked: () -> Unit
text = agreementText, text = agreementText,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = dimensionResource(id = R.dimen.spacing54)), .padding(horizontal = TangemTheme.dimens.spacing54),
style = MaterialTheme.typography.caption.copy(textAlign = TextAlign.Center), style = MaterialTheme.typography.caption.copy(textAlign = TextAlign.Center),
maxLines = 2, maxLines = 2,
onClick = { onClick = {

View file

@ -21,7 +21,7 @@ internal fun NonParticipateBottomBlock(onAgreementClicked: () -> Unit, onPartici
onClicked = onAgreementClicked, onClicked = onAgreementClicked,
) )
PrimaryEndIconButton( PrimaryEndIconButton(
modifier = Modifier.padding(all = dimensionResource(id = R.dimen.spacing16)), modifier = Modifier.padding(all = TangemTheme.dimens.spacing16),
text = stringResource(id = R.string.referral_button_participate), text = stringResource(id = R.string.referral_button_participate),
iconResId = R.drawable.ic_tangem, iconResId = R.drawable.ic_tangem,
onClicked = onParticipateClicked, onClicked = onParticipateClicked,

View file

@ -19,7 +19,6 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
@ -42,11 +41,11 @@ internal fun ParticipateBottomBlock(
Column( Column(
modifier = Modifier modifier = Modifier
.padding( .padding(
top = dimensionResource(id = R.dimen.spacing24), top = TangemTheme.dimens.spacing24,
bottom = dimensionResource(id = R.dimen.spacing16), bottom = TangemTheme.dimens.spacing16,
) )
.padding(horizontal = dimensionResource(id = R.dimen.spacing16)), .padding(horizontal = TangemTheme.dimens.spacing16),
verticalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing16)), verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing16),
) { ) {
SmallInfoCard( SmallInfoCard(
startText = stringResource(id = R.string.referral_friends_bought_title), startText = stringResource(id = R.string.referral_friends_bought_title),
@ -66,17 +65,17 @@ private fun PersonalCodeCard(code: String) {
Column( Column(
modifier = Modifier modifier = Modifier
.shadow( .shadow(
elevation = dimensionResource(id = R.dimen.elevation2), elevation = TangemTheme.dimens.elevation2,
shape = RoundedCornerShape(dimensionResource(id = R.dimen.radius12)), shape = RoundedCornerShape(TangemTheme.dimens.radius12),
) )
.background( .background(
color = MaterialTheme.colors.secondary, color = MaterialTheme.colors.secondary,
shape = RoundedCornerShape(dimensionResource(id = R.dimen.radius12)), shape = RoundedCornerShape(TangemTheme.dimens.radius12),
) )
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = dimensionResource(id = R.dimen.spacing12)), .padding(vertical = TangemTheme.dimens.spacing12),
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing4)), verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing4),
) { ) {
Text( Text(
text = stringResource(id = R.string.referral_promo_code_title), text = stringResource(id = R.string.referral_promo_code_title),
@ -100,7 +99,7 @@ private fun AdditionalButtons(code: String, shareLink: String, showCopySnackbar:
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing16)), horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing16),
) { ) {
PrimaryStartIconButton( PrimaryStartIconButton(
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),

View file

@ -56,10 +56,10 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.tangem.core.ui.components.VerticalSpacer import com.tangem.core.ui.components.VerticalSpacer
import com.tangem.core.ui.components.appbar.AppBarWithBackButton import com.tangem.core.ui.components.appbar.AppBarWithBackButton
import com.tangem.core.ui.res.TangemColorPalette.Black
import com.tangem.core.ui.res.ButtonColorType import com.tangem.core.ui.res.ButtonColorType
import com.tangem.core.ui.res.IconColorType import com.tangem.core.ui.res.IconColorType
import com.tangem.core.ui.res.TangemColorPalette import com.tangem.core.ui.res.TangemColorPalette
import com.tangem.core.ui.res.TangemColorPalette.Black
import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TextColorType import com.tangem.core.ui.res.TextColorType
import com.tangem.core.ui.res.buttonColor import com.tangem.core.ui.res.buttonColor
@ -99,11 +99,11 @@ internal fun ReferralScreen(stateHolder: ReferralStateHolder) {
}, },
scaffoldState = bottomSheetScaffoldState, scaffoldState = bottomSheetScaffoldState,
sheetShape = RoundedCornerShape( sheetShape = RoundedCornerShape(
topStart = dimensionResource(id = R.dimen.radius16), topStart = TangemTheme.dimens.radius16,
topEnd = dimensionResource(id = R.dimen.radius16), topEnd = TangemTheme.dimens.radius16,
), ),
sheetElevation = dimensionResource(id = R.dimen.elevation24), sheetElevation = TangemTheme.dimens.elevation24,
sheetPeekHeight = dimensionResource(id = R.dimen.size0), sheetPeekHeight = TangemTheme.dimens.size0,
content = { content = {
ReferralContent( ReferralContent(
stateHolder = stateHolder, stateHolder = stateHolder,
@ -164,7 +164,7 @@ private fun Header() {
painter = painterResource(R.drawable.ill_businessman_3d), painter = painterResource(R.drawable.ill_businessman_3d),
contentDescription = null, contentDescription = null,
modifier = Modifier modifier = Modifier
.padding(horizontal = dimensionResource(id = R.dimen.spacing32)) .padding(horizontal = TangemTheme.dimens.spacing32)
.fillMaxWidth() .fillMaxWidth()
.height(dimensionResource(R.dimen.size200)), .height(dimensionResource(R.dimen.size200)),
) )
@ -255,23 +255,23 @@ private fun LoadingCondition(@DrawableRes iconResId: Int) {
@Composable @Composable
private fun Condition(@DrawableRes iconResId: Int, infoBlock: @Composable () -> Unit) { private fun Condition(@DrawableRes iconResId: Int, infoBlock: @Composable () -> Unit) {
Row( Row(
modifier = Modifier.padding(horizontal = dimensionResource(id = R.dimen.spacing16)), modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing16),
horizontalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing12)), horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing12),
verticalAlignment = Alignment.Top, verticalAlignment = Alignment.Top,
) { ) {
Box( Box(
modifier = Modifier modifier = Modifier
.background( .background(
color = MaterialTheme.colors.buttonColor(type = ButtonColorType.SECONDARY), color = MaterialTheme.colors.buttonColor(type = ButtonColorType.SECONDARY),
shape = RoundedCornerShape(dimensionResource(id = R.dimen.radius16)), shape = RoundedCornerShape(TangemTheme.dimens.radius16),
) )
.size(dimensionResource(id = R.dimen.size56)), .size(TangemTheme.dimens.size56),
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
) { ) {
Icon( Icon(
painter = painterResource(id = iconResId), painter = painterResource(id = iconResId),
contentDescription = null, contentDescription = null,
modifier = Modifier.size(dimensionResource(id = R.dimen.size28)), modifier = Modifier.size(TangemTheme.dimens.size28),
tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1), tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1),
) )
} }
@ -325,7 +325,7 @@ private fun InfoForYourFriend(discount: String) {
@Composable @Composable
private fun ConditionInfo(title: String, subtitleContent: @Composable () -> Unit) { private fun ConditionInfo(title: String, subtitleContent: @Composable () -> Unit) {
Column(verticalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing2))) { Column(verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing2)) {
Text( Text(
text = title, text = title,
color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1), color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1),
@ -340,22 +340,22 @@ private fun ShimmerInfo() {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(top = dimensionResource(id = R.dimen.spacing4)) .padding(top = TangemTheme.dimens.spacing4)
.shimmer(), .shimmer(),
verticalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing10)), verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing10),
) { ) {
Box( Box(
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(dimensionResource(id = R.dimen.radius6))) .clip(RoundedCornerShape(TangemTheme.dimens.radius6))
.width(dimensionResource(id = R.dimen.size102)) .width(TangemTheme.dimens.size102)
.height(dimensionResource(id = R.dimen.size16)) .height(TangemTheme.dimens.size16)
.background(TangemColorPalette.White), .background(TangemColorPalette.White),
) )
Box( Box(
modifier = Modifier modifier = Modifier
.clip(RoundedCornerShape(dimensionResource(id = R.dimen.radius6))) .clip(RoundedCornerShape(TangemTheme.dimens.radius6))
.width(dimensionResource(id = R.dimen.size40)) .width(TangemTheme.dimens.size40)
.height(dimensionResource(id = R.dimen.size11)) .height(TangemTheme.dimens.size11)
.background(TangemColorPalette.White), .background(TangemColorPalette.White),
) )
} }
@ -370,17 +370,17 @@ private fun ErrorSnackbarHost(errorSnackbar: ErrorSnackbar?) {
SnackbarHost( SnackbarHost(
hostState = snackbarHostState, hostState = snackbarHostState,
modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing56)), modifier = Modifier.padding(top = TangemTheme.dimens.spacing56),
snackbar = { snackbar = {
Snackbar( Snackbar(
snackbarData = it, snackbarData = it,
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
actionOnNewLine = true, actionOnNewLine = true,
shape = RoundedCornerShape(size = dimensionResource(id = R.dimen.radius8)), shape = RoundedCornerShape(size = TangemTheme.dimens.radius8),
backgroundColor = Black, backgroundColor = Black,
contentColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2), contentColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2),
actionColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2), actionColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2),
elevation = dimensionResource(id = R.dimen.elevation3), elevation = TangemTheme.dimens.elevation3,
) )
}, },
) )
@ -424,20 +424,20 @@ private fun CopySnackbarHost(isCopyButtonPressed: MutableState<Boolean>) {
SnackbarHost( SnackbarHost(
hostState = snackbarHostState, hostState = snackbarHostState,
modifier = Modifier modifier = Modifier
.padding(top = dimensionResource(id = R.dimen.spacing56), start = (width - snackbarWidth).div(2)) .padding(top = TangemTheme.dimens.spacing56, start = (width - snackbarWidth).div(2))
.fillMaxWidth(), .fillMaxWidth(),
snackbar = { snackbar = {
Box( Box(
modifier = Modifier modifier = Modifier
.onSizeChanged { snackbarSize = it.width } .onSizeChanged { snackbarSize = it.width }
.background(Black, RoundedCornerShape(size = dimensionResource(id = R.dimen.radius8))) .background(Black, RoundedCornerShape(size = TangemTheme.dimens.radius8))
.shadow( .shadow(
dimensionResource(id = R.dimen.elevation3), TangemTheme.dimens.elevation3,
RoundedCornerShape(size = dimensionResource(id = R.dimen.radius8)), RoundedCornerShape(size = TangemTheme.dimens.radius8),
) )
.padding( .padding(
horizontal = dimensionResource(id = R.dimen.spacing16), horizontal = TangemTheme.dimens.spacing16,
vertical = dimensionResource(id = R.dimen.spacing14), vertical = TangemTheme.dimens.spacing14,
), ),
) { ) {
Text( Text(

View file

@ -107,7 +107,7 @@ internal class ReferralViewModel @Inject constructor(
private fun ReferralData.getDiscountValue(): String { private fun ReferralData.getDiscountValue(): String {
val discountSymbol = when (discountType) { val discountSymbol = when (discountType) {
DiscountType.PERCENTAGE -> "%" DiscountType.PERCENTAGE -> "%"
DiscountType.VALUE -> throw java.lang.IllegalStateException("Value doesn't support") DiscountType.VALUE -> error("Value doesn't support")
} }
return "$discount $discountSymbol" return "$discount $discountSymbol"
} }