Updated on 2026-08-14

This commit is contained in:
Tangem 2022-03-17 20:36:41 +03:00
parent 7eefb1782c
commit 6adb9c4006
7 changed files with 85 additions and 24 deletions

View file

@ -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)
}

View file

@ -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) }
}

View file

@ -5,7 +5,7 @@
<string name="shop_2_cards">2 cards</string>
<string name="shop_shipping">Shipping</string>
<string name="shop_free">Free</string>
<string name="shop_i_have_a_promo_code">I have a promo code</string>
<string name="shop_i_have_a_promo_code">I have a promo code...</string>
<string name="shop_total">Total</string>
<string name="shop_other_payment_methods">Other payment methods</string>
<string name="shop_buy_now">Buy now</string>
@ -23,16 +23,17 @@
<string name="story_awe_title">Revolutionary Hardware Wallet</string>
<string name="story_awe_description">Store your crypto assets secure while keeping private keys contained in your card</string>
<string name="story_backup_title">Ultra Secure Backup</string>
<string name="story_backup_description">Up to 3 physical cards to one wallet</string>
<string name="story_backup_description">Up to <b>3 physical cards</b> to one wallet</string>
<string name="story_currencies_title">Thousands of Currencies</string>
<string name="story_currencies_description">A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously all in one card</string>
<string name="story_web3_title">DeFi Compatible</string>
<string name="story_web3_description">Exchange, buy NFTs, make loans and deposits in more than 100 different decentralized services</string>
<string name="story_finish_title">The Wallet for Everyone</string>
<string name="story_finish_description">Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto.</string>
<string name="home_button_order">Order card</string>
<string name="home_button_order">Order</string>
<string name="home_button_search_tokens">Search tokens</string>
<string name="search_tokens_title">Search tokens</string>
<string name="alert_demo_message">You are currently running in Demo mode. All funds are not real.</string>
<string name="alert_demo_feature_disabled">This feature is disabled in Demo mode</string>
<string name="token_details_send_blocked_fee_format">Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first.</string>
</resources>

View file

@ -5,7 +5,7 @@
<string name="shop_2_cards">2 cards</string>
<string name="shop_shipping">Shipping</string>
<string name="shop_free">Free</string>
<string name="shop_i_have_a_promo_code">I have a promo code</string>
<string name="shop_i_have_a_promo_code">I have a promo code...</string>
<string name="shop_total">Total</string>
<string name="shop_other_payment_methods">Other payment methods</string>
<string name="shop_buy_now">Buy now</string>
@ -23,16 +23,17 @@
<string name="story_awe_title">Revolutionary Hardware Wallet</string>
<string name="story_awe_description">Store your crypto assets secure while keeping private keys contained in your card</string>
<string name="story_backup_title">Ultra Secure Backup</string>
<string name="story_backup_description">Up to 3 physical cards to one wallet</string>
<string name="story_backup_description">Up to <b>3 physical cards</b> to one wallet</string>
<string name="story_currencies_title">Thousands of Currencies</string>
<string name="story_currencies_description">A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously all in one card</string>
<string name="story_web3_title">DeFi Compatible</string>
<string name="story_web3_description">Exchange, buy NFTs, make loans and deposits in more than 100 different decentralized services</string>
<string name="story_finish_title">The Wallet for Everyone</string>
<string name="story_finish_description">Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto.</string>
<string name="home_button_order">Order card</string>
<string name="home_button_order">Order</string>
<string name="home_button_search_tokens">Search tokens</string>
<string name="search_tokens_title">Search tokens</string>
<string name="alert_demo_message">You are currently running in Demo mode. All funds are not real.</string>
<string name="alert_demo_feature_disabled">This feature is disabled in Demo mode</string>
<string name="token_details_send_blocked_fee_format">Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first.</string>
</resources>

View file

@ -5,7 +5,7 @@
<string name="shop_2_cards">2 cards</string>
<string name="shop_shipping">Shipping</string>
<string name="shop_free">Free</string>
<string name="shop_i_have_a_promo_code">I have a promo code</string>
<string name="shop_i_have_a_promo_code">I have a promo code...</string>
<string name="shop_total">Total</string>
<string name="shop_other_payment_methods">Other payment methods</string>
<string name="shop_buy_now">Buy now</string>
@ -23,16 +23,17 @@
<string name="story_awe_title">Revolutionary Hardware Wallet</string>
<string name="story_awe_description">Store your crypto assets secure while keeping private keys contained in your card</string>
<string name="story_backup_title">Ultra Secure Backup</string>
<string name="story_backup_description">Up to 3 physical cards to one wallet</string>
<string name="story_backup_description">Up to <b>3 physical cards</b> to one wallet</string>
<string name="story_currencies_title">Thousands of Currencies</string>
<string name="story_currencies_description">A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously all in one card</string>
<string name="story_web3_title">DeFi Compatible</string>
<string name="story_web3_description">Exchange, buy NFTs, make loans and deposits in more than 100 different decentralized services</string>
<string name="story_finish_title">The Wallet for Everyone</string>
<string name="story_finish_description">Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto.</string>
<string name="home_button_order">Order card</string>
<string name="home_button_order">Order</string>
<string name="home_button_search_tokens">Search tokens</string>
<string name="search_tokens_title">Search tokens</string>
<string name="alert_demo_message">You are currently running in Demo mode. All funds are not real.</string>
<string name="alert_demo_feature_disabled">This feature is disabled in Demo mode</string>
<string name="token_details_send_blocked_fee_format">Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first.</string>
</resources>

View file

@ -23,7 +23,7 @@
<string name="story_awe_title">Революционный аппаратный кошелек</string>
<string name="story_awe_description">Держите свои криптосбережения в безопасности. Приватные ключи надежно хранятся на карте.</string>
<string name="story_backup_title">Все ключи в безопасности</string>
<string name="story_backup_description">До трех карт с одним кошельком</string>
<string name="story_backup_description">До <b>трех карт</b> с одним кошельком</string>
<string name="story_currencies_title">Тысячи криптовалют</string>
<string name="story_currencies_description">Аппаратный кошелек для ваших биткоинов, эфира и многих других валют одновременно — все в одной карте</string>
<string name="story_web3_title">Поддержка DeFi</string>
@ -35,4 +35,5 @@
<string name="search_tokens_title">Поиск токенов</string>
<string name="alert_demo_message">Приложение работает в демонстрационном режиме. Средства на всех счетах ненастоящие.</string>
<string name="alert_demo_feature_disabled">Эта функция недоступна в демонстрационном режиме</string>
<string name="token_details_send_blocked_fee_format">Недостаточно средств для комиссии на вашем %s кошельке для отправки транзакции. Сначала пополните свой %s кошелек.</string>
</resources>

View file

@ -5,7 +5,7 @@
<string name="shop_2_cards">2 cards</string>
<string name="shop_shipping">Shipping</string>
<string name="shop_free">Free</string>
<string name="shop_i_have_a_promo_code">I have a promo code</string>
<string name="shop_i_have_a_promo_code">I have a promo code...</string>
<string name="shop_total">Total</string>
<string name="shop_other_payment_methods">Other payment methods</string>
<string name="shop_buy_now">Buy now</string>
@ -23,16 +23,17 @@
<string name="story_awe_title">Revolutionary Hardware Wallet</string>
<string name="story_awe_description">Store your crypto assets secure while keeping private keys contained in your card</string>
<string name="story_backup_title">Ultra Secure Backup</string>
<string name="story_backup_description">Up to 3 physical cards to one wallet</string>
<string name="story_backup_description">Up to <b>3 physical cards</b> to one wallet</string>
<string name="story_currencies_title">Thousands of Currencies</string>
<string name="story_currencies_description">A hardware wallet for your Bitcoin, Ethereum and many more currencies simultaneously all in one card</string>
<string name="story_web3_title">DeFi Compatible</string>
<string name="story_web3_description">Exchange, buy NFTs, make loans and deposits in more than 100 different decentralized services</string>
<string name="story_finish_title">The Wallet for Everyone</string>
<string name="story_finish_description">Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto.</string>
<string name="home_button_order">Order card</string>
<string name="home_button_order">Order</string>
<string name="home_button_search_tokens">Search tokens</string>
<string name="search_tokens_title">Search tokens</string>
<string name="alert_demo_message">You are currently running in Demo mode. All funds are not real.</string>
<string name="alert_demo_feature_disabled">This feature is disabled in Demo mode</string>
<string name="token_details_send_blocked_fee_format">Not enough funds for fee on your %s wallet to send a transaction. Top up your %s wallet first.</string>
</resources>