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 -> {
throw IllegalStateException("result result is null")
error("result result is null")
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -29,16 +29,16 @@ fun BottomSheetIndicator() {
Box(
modifier = Modifier
.fillMaxWidth()
.height(dimensionResource(id = R.dimen.size20)),
.height(TangemTheme.dimens.size20),
contentAlignment = Alignment.Center,
) {
Box(
modifier = Modifier
.width(dimensionResource(id = R.dimen.size32))
.height(dimensionResource(id = R.dimen.size4))
.width(TangemTheme.dimens.size32)
.height(TangemTheme.dimens.size4)
.background(
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 radius4: Dp = 4.dp,
val radius6: Dp = 6.dp,
val radius8: Dp = 8.dp,
val radius12: Dp = 12.dp,
val radius16: Dp = 16.dp,
val radius28: Dp = 28.dp,
@ -51,11 +52,13 @@ data class TangemDimens internal constructor(
val spacing8: Dp = 8.dp,
val spacing10: Dp = 10.dp,
val spacing12: Dp = 12.dp,
val spacing14: Dp = 14.dp,
val spacing16: Dp = 16.dp,
val spacing24: Dp = 24.dp,
val spacing32: Dp = 32.dp,
val spacing44: Dp = 44.dp,
val spacing50: Dp = 50.dp,
val spacing54: Dp = 54.dp,
val spacing56: Dp = 56.dp,
// endregion Spacing
)

View file

@ -34,7 +34,7 @@ internal class ReferralInteractorImpl(
address = publicAddress,
)
} 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
.background(color = MaterialTheme.colors.secondary)
.fillMaxWidth()
.height(LocalConfiguration.current.screenHeightDp.dp - dimensionResource(id = R.dimen.spacing16)),
.height(LocalConfiguration.current.screenHeightDp.dp - TangemTheme.dimens.spacing16),
) {
BottomSheetIndicator()
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {

View file

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

View file

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

View file

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

View file

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