diff --git a/app/src/main/java/com/tangem/tap/common/extensions/compose/Color.kt b/app/src/main/java/com/tangem/tap/common/extensions/compose/Color.kt new file mode 100644 index 0000000000..d78a72ead5 --- /dev/null +++ b/app/src/main/java/com/tangem/tap/common/extensions/compose/Color.kt @@ -0,0 +1,16 @@ +package com.tangem.tap.common.extensions.compose + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.toArgb +import androidx.core.graphics.alpha +import androidx.core.graphics.blue +import androidx.core.graphics.green +import androidx.core.graphics.red + +/** +[REDACTED_AUTHOR] + */ +fun Color.argb(): Int { + val argb = this.toArgb() + return android.graphics.Color.argb(argb.alpha, argb.red, argb.green, argb.blue) +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/home/compose/StoriesGeneralContent.kt b/app/src/main/java/com/tangem/tap/features/home/compose/StoriesGeneralContent.kt index b12be36802..8d2577fc01 100644 --- a/app/src/main/java/com/tangem/tap/features/home/compose/StoriesGeneralContent.kt +++ b/app/src/main/java/com/tangem/tap/features/home/compose/StoriesGeneralContent.kt @@ -1,5 +1,11 @@ package com.tangem.tap.features.home.compose +import android.content.Context +import android.graphics.Typeface +import android.util.TypedValue +import android.view.View +import android.view.ViewGroup +import android.widget.TextView import androidx.compose.foundation.Image import androidx.compose.foundation.layout.* import androidx.compose.material.Text @@ -14,6 +20,9 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.compose.ui.viewinterop.AndroidView +import com.tangem.tangem_sdk_new.extensions.dpToPx +import com.tangem.tap.common.extensions.compose.argb import com.tangem.wallet.R @Composable @@ -22,8 +31,9 @@ fun StoriesGeneralContent( subtitleText: String, imageSource: Int?, isDarkBackground: Boolean, + subtitleTextId: Int? = null, imageComposable: (() -> Unit)? = null, - ) { +) { Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center, @@ -45,15 +55,7 @@ fun StoriesGeneralContent( Spacer(modifier = Modifier.size(16.dp)) - Text( - text = subtitleText, - fontSize = 20.sp, - fontWeight = FontWeight.Normal, - modifier = Modifier - .padding(start = 40.dp, end = 40.dp), - color = Color(0xFFA6AAAD), - textAlign = TextAlign.Center - ) + SubtitleText(subtitleText, subtitleTextId) Spacer(modifier = Modifier.size(25.dp)) @@ -61,7 +63,7 @@ fun StoriesGeneralContent( Image( painter = painterResource(id = imageSource), contentDescription = null, - contentScale = if(isDarkBackground) ContentScale.Inside else ContentScale.FillWidth, + contentScale = if (isDarkBackground) ContentScale.Inside else ContentScale.FillWidth, modifier = Modifier.fillMaxWidth() ) } @@ -69,6 +71,34 @@ fun StoriesGeneralContent( } } +@Composable +fun SubtitleText(subtitleText: String, subtitleTextId: Int?) { + val color = Color(0xFFA6AAAD) + + if (subtitleTextId == null) { + Text( + text = subtitleText, + fontSize = 20.sp, + fontWeight = FontWeight.Normal, + modifier = Modifier.padding(start = 40.dp, end = 40.dp), + color = color, + textAlign = TextAlign.Center + ) + } else { + HtmlText(subtitleTextId) { context -> + val padding = context.dpToPx(40f).toInt() + TextView(context).apply { + layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + setPadding(padding, 0, padding, 0) + textAlignment = View.TEXT_ALIGNMENT_CENTER + typeface = Typeface.DEFAULT + setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f) + setTextColor(color.argb()) + } + } + } +} + @Composable fun StoriesRevolutionaryWallet() { StoriesGeneralContent( @@ -85,6 +115,7 @@ fun StoriesUltraSecureBackup() { titleText = stringResource(id = R.string.story_backup_title), subtitleText = stringResource(id = R.string.story_backup_description), imageSource = R.drawable.floating_cards, + subtitleTextId = R.string.story_backup_description, isDarkBackground = false ) } @@ -117,4 +148,13 @@ fun StoriesWalletForEveryone() { imageSource = R.drawable.wallet_for_everyone, isDarkBackground = true ) +} + +@Composable +fun HtmlText( + stringResId: Int, + modifier: Modifier = Modifier, + factory: (Context) -> TextView +) { + AndroidView(factory, modifier) { it.text = it.context.getText(stringResId) } } \ No newline at end of file diff --git a/app/src/main/res/values-de/strings_final.xml b/app/src/main/res/values-de/strings_final.xml index fa5d2dc4b3..4a431cc050 100644 --- a/app/src/main/res/values-de/strings_final.xml +++ b/app/src/main/res/values-de/strings_final.xml @@ -5,7 +5,7 @@ 2 cards Shipping Free - I have a promo code… + I have a promo code... Total Other payment methods Buy now @@ -23,16 +23,17 @@ Revolutionary Hardware Wallet Store your crypto assets secure while keeping private keys contained in your card Ultra Secure Backup - Up to 3 physical cards to one wallet + Up to 3 physical cards to one wallet Thousands of Currencies A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously – all in one card DeFi Compatible Exchange, buy NFT’s, make loans and deposits in more than 100 different decentralized services The Wallet for Everyone Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto. - Order card + Order Search tokens Search tokens You are currently running in Demo mode. All funds are not real. This feature is disabled in Demo mode + Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first. \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings_final.xml b/app/src/main/res/values-fr/strings_final.xml index fa5d2dc4b3..4a431cc050 100644 --- a/app/src/main/res/values-fr/strings_final.xml +++ b/app/src/main/res/values-fr/strings_final.xml @@ -5,7 +5,7 @@ 2 cards Shipping Free - I have a promo code… + I have a promo code... Total Other payment methods Buy now @@ -23,16 +23,17 @@ Revolutionary Hardware Wallet Store your crypto assets secure while keeping private keys contained in your card Ultra Secure Backup - Up to 3 physical cards to one wallet + Up to 3 physical cards to one wallet Thousands of Currencies A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously – all in one card DeFi Compatible Exchange, buy NFT’s, make loans and deposits in more than 100 different decentralized services The Wallet for Everyone Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto. - Order card + Order Search tokens Search tokens You are currently running in Demo mode. All funds are not real. This feature is disabled in Demo mode + Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first. \ No newline at end of file diff --git a/app/src/main/res/values-it/strings_final.xml b/app/src/main/res/values-it/strings_final.xml index fa5d2dc4b3..4a431cc050 100644 --- a/app/src/main/res/values-it/strings_final.xml +++ b/app/src/main/res/values-it/strings_final.xml @@ -5,7 +5,7 @@ 2 cards Shipping Free - I have a promo code… + I have a promo code... Total Other payment methods Buy now @@ -23,16 +23,17 @@ Revolutionary Hardware Wallet Store your crypto assets secure while keeping private keys contained in your card Ultra Secure Backup - Up to 3 physical cards to one wallet + Up to 3 physical cards to one wallet Thousands of Currencies A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously – all in one card DeFi Compatible Exchange, buy NFT’s, make loans and deposits in more than 100 different decentralized services The Wallet for Everyone Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto. - Order card + Order Search tokens Search tokens You are currently running in Demo mode. All funds are not real. This feature is disabled in Demo mode + Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first. \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings_final.xml b/app/src/main/res/values-ru/strings_final.xml index 288761b97c..89595fb93d 100644 --- a/app/src/main/res/values-ru/strings_final.xml +++ b/app/src/main/res/values-ru/strings_final.xml @@ -23,7 +23,7 @@ Революционный аппаратный кошелек Держите свои криптосбережения в безопасности. Приватные ключи надежно хранятся на карте. Все ключи в безопасности - До трех карт с одним кошельком + До трех карт с одним кошельком Тысячи криптовалют Аппаратный кошелек для ваших биткоинов, эфира и многих других валют одновременно — все в одной карте Поддержка DeFi @@ -35,4 +35,5 @@ Поиск токенов Приложение работает в демонстрационном режиме. Средства на всех счетах ненастоящие. Эта функция недоступна в демонстрационном режиме + Недостаточно средств для комиссии на вашем %s кошельке для отправки транзакции. Сначала пополните свой %s кошелек. \ No newline at end of file diff --git a/app/src/main/res/values/strings_final.xml b/app/src/main/res/values/strings_final.xml index fa5d2dc4b3..4a431cc050 100644 --- a/app/src/main/res/values/strings_final.xml +++ b/app/src/main/res/values/strings_final.xml @@ -5,7 +5,7 @@ 2 cards Shipping Free - I have a promo code… + I have a promo code... Total Other payment methods Buy now @@ -23,16 +23,17 @@ Revolutionary Hardware Wallet Store your crypto assets secure while keeping private keys contained in your card Ultra Secure Backup - Up to 3 physical cards to one wallet + Up to 3 physical cards to one wallet Thousands of Currencies A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously – all in one card DeFi Compatible Exchange, buy NFT’s, make loans and deposits in more than 100 different decentralized services The Wallet for Everyone Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto. - Order card + Order Search tokens Search tokens You are currently running in Demo mode. All funds are not real. This feature is disabled in Demo mode + Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first. \ No newline at end of file