diff --git a/app/src/main/java/com/tangem/tap/MainActivity.kt b/app/src/main/java/com/tangem/tap/MainActivity.kt index 5ef7c985a6..da2ecd172f 100644 --- a/app/src/main/java/com/tangem/tap/MainActivity.kt +++ b/app/src/main/java/com/tangem/tap/MainActivity.kt @@ -84,6 +84,7 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac context = applicationContext, tangemSdkManager = tangemSdkManager, ) + appStateHolder.userWalletsListManager = userWalletsListManager userWalletsListManagerSafe = userWalletsListManager lockUserWalletsTimer = LockUserWalletsTimer(owner = this) diff --git a/app/src/main/java/com/tangem/tap/TapApplication.kt b/app/src/main/java/com/tangem/tap/TapApplication.kt index 0d483b43ee..50ded416e6 100644 --- a/app/src/main/java/com/tangem/tap/TapApplication.kt +++ b/app/src/main/java/com/tangem/tap/TapApplication.kt @@ -128,7 +128,6 @@ class TapApplication : Application(), ImageLoaderFactory { middleware = AppState.getMiddleware(), state = AppState(), ) - appStateHolder.mainStore = store if (BuildConfig.DEBUG) { Timber.plant(Timber.DebugTree()) @@ -155,7 +154,9 @@ class TapApplication : Application(), ImageLoaderFactory { context = this, tangemTechService = store.state.domainNetworks.tangemTechService, ) + appStateHolder.mainStore = store appStateHolder.userTokensRepository = userTokensRepository + appStateHolder.walletStoresManager = walletStoresManager } //todo refactor: move to datasource and provide via DI diff --git a/app/src/main/java/com/tangem/tap/domain/extensions/Card.kt b/app/src/main/java/com/tangem/tap/domain/extensions/Card.kt index fd46ad2fde..486a9f6b89 100644 --- a/app/src/main/java/com/tangem/tap/domain/extensions/Card.kt +++ b/app/src/main/java/com/tangem/tap/domain/extensions/Card.kt @@ -31,6 +31,12 @@ val CardDTO.isMultiwalletAllowed: Boolean val CardDTO.isHdWalletAllowedByApp: Boolean get() = settings.isHDWalletAllowed && !isSaltPay +val CardDTO.isTangemWallet: Boolean + get() = settings.isBackupAllowed + && settings.isHDWalletAllowed + && firmwareVersion >= FirmwareVersion.MultiWalletAvailable + && !isSaltPay + fun CardDTO.hasSignedHashes(): Boolean { return wallets.any { (it.totalSignedHashes ?: 0) > 0 } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt index 319524eccd..f6b932c755 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt @@ -11,6 +11,7 @@ import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.common.redux.navigation.AppScreen import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.extensions.isMultiwalletAllowed +import com.tangem.tap.domain.extensions.isTangemWallet import com.tangem.tap.features.details.redux.DetailsAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.features.disclaimer.redux.DisclaimerAction @@ -39,6 +40,7 @@ class DetailsViewModel(private val store: Store) { SettingsElement.AppSettings -> if (state.isBiometricsAvailable) it else null SettingsElement.AppCurrency -> if (state.scanResponse?.card?.isMultiwalletAllowed != true) it else null SettingsElement.TermsOfUse -> if (state.scanResponse?.card?.isStart2Coin == true) it else null + // SettingsElement.ReferralProgram -> if (state.scanResponse?.card?.isTangemWallet == true) it else null else -> it } } diff --git a/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt b/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt index 11cfdee61f..cfe9b9cb17 100644 --- a/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt +++ b/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt @@ -5,6 +5,8 @@ import com.tangem.domain.common.ScanResponse import com.tangem.tap.common.redux.AppState import com.tangem.tap.domain.TangemSdkManager import com.tangem.tap.domain.tokens.UserTokensRepository +import com.tangem.tap.domain.userWalletList.UserWalletsListManager +import com.tangem.tap.domain.walletStores.WalletStoresManager import com.tangem.tap.features.wallet.redux.WalletState import org.rekotlin.Store @@ -19,6 +21,8 @@ class AppStateHolder { var userTokensRepository: UserTokensRepository? = null var mainStore: Store? = null var tangemSdkManager: TangemSdkManager? = null + var walletStoresManager: WalletStoresManager? = null + var userWalletsListManager: UserWalletsListManager? = null fun getActualCard(): CardDTO? { return scanResponse?.card diff --git a/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt b/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt index 7be322fc1e..265b0aa182 100644 --- a/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt +++ b/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt @@ -89,6 +89,8 @@ class DerivationManagerImpl( } scope.launch { + val selectedWallet = appStateHolder.userWalletsListManager?.selectedUserWalletSync + val result = appStateHolder.tangemSdkManager?.derivePublicKeys( scanResponse.card.cardId, derivations, @@ -108,6 +110,14 @@ class DerivationManagerImpl( val updatedScanResponse = scanResponse.copy( derivedKeys = updatedDerivedKeys, ) + if (selectedWallet != null) { + val userWallet = selectedWallet.copy( + scanResponse = updatedScanResponse, + ) + + appStateHolder.userWalletsListManager?.save(userWallet, canOverride = true) + appStateHolder.walletStoresManager?.fetch(userWallet, true) + } appStateHolder.mainStore?.dispatchOnMain(GlobalAction.SaveScanResponse(updatedScanResponse)) delay(DELAY_SDK_DIALOG_CLOSE) onSuccess(updatedScanResponse) @@ -115,8 +125,7 @@ class DerivationManagerImpl( is CompletionResult.Failure -> { appStateHolder.mainStore?.dispatchDebugErrorNotification( TapError.CustomError( - "Error adding " + - "tokens", + "Error derivation", ), ) } diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/referral/models/ReferralResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/referral/models/ReferralResponse.kt index 3066ab45a7..f58c6570f6 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/referral/models/ReferralResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/referral/models/ReferralResponse.kt @@ -1,8 +1,6 @@ package com.tangem.datasource.api.referral.models import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import org.joda.time.DateTime /** * Main response class for referral API diff --git a/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt b/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt index d662a98721..522c6dd904 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt @@ -60,7 +60,7 @@ class NetworkModule { .build(), ), ) - .baseUrl(DEV_TANGEM_TECH_BASE_URL) + .baseUrl(PROD_TANGEM_TECH_BASE_URL) .client(okHttpClient) .build() .create(ReferralApi::class.java) diff --git a/core/res/src/main/res/values/strings_plurals.xml b/core/res/src/main/res/values/strings_plurals.xml index 72449e9325..f7c61fa277 100644 --- a/core/res/src/main/res/values/strings_plurals.xml +++ b/core/res/src/main/res/values/strings_plurals.xml @@ -16,5 +16,6 @@ %d wallets %d wallet + %d wallets diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt index 90d5ee1ce4..0ece569d8d 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt @@ -6,18 +6,13 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.tooling.preview.Preview -import com.tangem.core.ui.R import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TextColorType -import com.tangem.core.ui.res.textColor @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable @@ -48,7 +43,7 @@ fun Preview_SimpleInfoCard_InDarkTheme() { fun SmallInfoCard(startText: String, endText: String) { Surface( shape = RoundedCornerShape(TangemTheme.dimens.radius12), - color = MaterialTheme.colors.secondary, + color = TangemTheme.colors.background.secondary, elevation = TangemTheme.dimens.elevation2, ) { Row( @@ -60,19 +55,19 @@ fun SmallInfoCard(startText: String, endText: String) { vertical = TangemTheme.dimens.spacing12, ), horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically + verticalAlignment = Alignment.CenterVertically, ) { Text( text = startText, - color = MaterialTheme.colors.textColor(type = TextColorType.TERTIARY), + color = TangemTheme.colors.text.tertiary, maxLines = 1, - style = MaterialTheme.typography.subtitle2 + style = TangemTheme.typography.subtitle2, ) Text( text = endText, - color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1), + color = TangemTheme.colors.text.primary1, maxLines = 1, - style = MaterialTheme.typography.body2 + style = TangemTheme.typography.body2, ) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt index 6416a8343f..c4a74e3fb9 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt @@ -7,21 +7,15 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material.Icon import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.components.appbar.models.AdditionalButton -import com.tangem.core.ui.res.IconColorType import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TextColorType -import com.tangem.core.ui.res.iconColor -import com.tangem.core.ui.res.textColor /** * App bar with title and two additional buttons @@ -50,7 +44,7 @@ fun AppBarWithAdditionalButtons( painter = painterResource(id = startButton.iconRes), contentDescription = null, modifier = Modifier.size(TangemTheme.dimens.size24), - tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1), + tint = TangemTheme.colors.icon.primary1, ) } } @@ -58,9 +52,9 @@ fun AppBarWithAdditionalButtons( Text( text = text, modifier = Modifier.align(Alignment.Center), - color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1), + color = TangemTheme.colors.text.primary1, maxLines = 1, - style = MaterialTheme.typography.subtitle1, + style = TangemTheme.typography.subtitle1, ) if (endButton != null) { @@ -69,7 +63,7 @@ fun AppBarWithAdditionalButtons( painter = painterResource(id = endButton.iconRes), contentDescription = null, modifier = Modifier.size(TangemTheme.dimens.size24), - tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1), + tint = TangemTheme.colors.icon.primary1, ) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt index 3f4c5efa9e..376c242719 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt @@ -1,6 +1,5 @@ package com.tangem.core.ui.components.appbar -import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row @@ -8,7 +7,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -29,10 +27,9 @@ import com.tangem.core.ui.res.TangemTheme * >Figma component */ @Composable -fun AppBarWithBackButton(text: String? = null, onBackClick: () -> Unit) { +fun AppBarWithBackButton(text: String? = null, onBackClick: () -> Unit, modifier: Modifier = Modifier) { Row( - modifier = Modifier - .background(MaterialTheme.colors.primary) + modifier = modifier .fillMaxWidth() .padding(all = dimensionResource(R.dimen.spacing16)), horizontalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.spacing16)), @@ -44,14 +41,14 @@ fun AppBarWithBackButton(text: String? = null, onBackClick: () -> Unit) { modifier = Modifier .size(size = dimensionResource(R.dimen.size24)) .clickable { onBackClick() }, - tint = MaterialTheme.colors.onPrimary, + tint = TangemTheme.colors.icon.primary1, ) if (!text.isNullOrBlank()) { Text( text = text, - color = MaterialTheme.colors.onPrimary, + color = TangemTheme.colors.text.primary1, maxLines = 1, - style = MaterialTheme.typography.subtitle1, + style = TangemTheme.typography.subtitle1, ) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/BottomSheetIndicator.kt b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/BottomSheetIndicator.kt deleted file mode 100644 index 907e68d0a2..0000000000 --- a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/BottomSheetIndicator.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.tangem.core.ui.components.atoms - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.MaterialTheme -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.dimensionResource -import androidx.compose.ui.tooling.preview.Preview -import com.tangem.core.ui.R -import com.tangem.core.ui.res.IconColorType -import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.iconColor - -/** - * Bottom sheet indicator - * - * @see - * Figma Component - */ -@Deprecated(message = "Use Hand component instead") -@Composable -fun BottomSheetIndicator() { - Box( - modifier = Modifier - .fillMaxWidth() - .height(TangemTheme.dimens.size20), - contentAlignment = Alignment.Center, - ) { - Box( - modifier = Modifier - .width(TangemTheme.dimens.size32) - .height(TangemTheme.dimens.size4) - .background( - color = MaterialTheme.colors.iconColor(type = IconColorType.INACTIVE), - shape = RoundedCornerShape(TangemTheme.dimens.radius2), - ), - ) - } -} - -@Preview(heightDp = 20, showBackground = true) -@Composable -fun Preview_BottomSheetIndicator_InLightTheme() { - TangemTheme(isDark = false) { - BottomSheetIndicator() - } -} - -@Preview(heightDp = 20, showBackground = true) -@Composable -fun Preview_BottomSheetIndicator_InDarkTheme() { - TangemTheme(isDark = true) { - BottomSheetIndicator() - } -} \ No newline at end of file diff --git a/features/referral/data/src/main/java/com/tangem/feature/referral/converters/ReferralConverter.kt b/features/referral/data/src/main/java/com/tangem/feature/referral/converters/ReferralConverter.kt index 7e468c0500..00925bfd13 100644 --- a/features/referral/data/src/main/java/com/tangem/feature/referral/converters/ReferralConverter.kt +++ b/features/referral/data/src/main/java/com/tangem/feature/referral/converters/ReferralConverter.kt @@ -19,7 +19,7 @@ class ReferralConverter @Inject constructor() : Converter Unit modifier = Modifier .fillMaxWidth() .padding(horizontal = TangemTheme.dimens.spacing54), - style = MaterialTheme.typography.caption.copy(textAlign = TextAlign.Center), + style = TangemTheme.typography.caption.copy(textAlign = TextAlign.Center), maxLines = 2, onClick = { val clickableSpanStyle = requireNotNull(agreementText.spanStyles.getOrNull(1)) @@ -44,13 +40,13 @@ internal fun AgreementText(@StringRes firstPartResId: Int, onClicked: () -> Unit @Composable private fun annotatedAgreementString(firstPart: String): AnnotatedString { return buildAnnotatedString { - withStyle(SpanStyle(color = MaterialTheme.colors.textColor(type = TextColorType.TERTIARY))) { + withStyle(SpanStyle(color = TangemTheme.colors.text.tertiary)) { append("$firstPart ") } - withStyle(SpanStyle(color = MaterialTheme.colors.textColor(type = TextColorType.ACCENT))) { + withStyle(SpanStyle(color = TangemTheme.colors.text.accent)) { append(stringResource(id = R.string.common_terms_and_conditions)) } - withStyle(SpanStyle(color = MaterialTheme.colors.textColor(type = TextColorType.TERTIARY))) { + withStyle(SpanStyle(color = TangemTheme.colors.text.tertiary)) { append(" ${stringResource(id = R.string.referral_tos_suffix)}") } } @@ -60,7 +56,7 @@ private fun annotatedAgreementString(firstPart: String): AnnotatedString { @Composable fun Preview_AgreementText_InLightTheme() { TangemTheme(isDark = false) { - Box(modifier = Modifier.background(MaterialTheme.colors.primary)) { + Box(modifier = Modifier.background(TangemTheme.colors.background.primary)) { AgreementText(firstPartResId = R.string.referral_tos_not_enroled_prefix, onClicked = {}) } } @@ -70,7 +66,7 @@ fun Preview_AgreementText_InLightTheme() { @Composable fun Preview_AgreementText_InDarkTheme() { TangemTheme(isDark = true) { - Box(modifier = Modifier.background(MaterialTheme.colors.primary)) { + Box(modifier = Modifier.background(TangemTheme.colors.background.primary)) { AgreementText(firstPartResId = R.string.referral_tos_not_enroled_prefix, onClicked = {}) } } diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt index 29e86058e8..5fcbfc52ed 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt @@ -3,10 +3,8 @@ package com.tangem.feature.referral.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding -import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.PrimaryEndIconButton @@ -33,7 +31,7 @@ internal fun NonParticipateBottomBlock(onAgreementClicked: () -> Unit, onPartici @Composable fun Preview_NonParticipateBottomBlock_InLightTheme() { TangemTheme(isDark = false) { - Column(Modifier.background(MaterialTheme.colors.primary)) { + Column(Modifier.background(TangemTheme.colors.background.primary)) { NonParticipateBottomBlock(onAgreementClicked = {}, onParticipateClicked = {}) } } @@ -43,7 +41,7 @@ fun Preview_NonParticipateBottomBlock_InLightTheme() { @Composable fun Preview_NonParticipateBottomBlock_InDarkTheme() { TangemTheme(isDark = true) { - Column(Modifier.background(MaterialTheme.colors.primary)) { + Column(Modifier.background(TangemTheme.colors.background.primary)) { NonParticipateBottomBlock(onAgreementClicked = {}, onParticipateClicked = {}) } } diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt index 0027b80634..33e376ad8b 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -28,8 +27,6 @@ import androidx.core.content.ContextCompat.startActivity import com.tangem.core.ui.components.PrimaryStartIconButton import com.tangem.core.ui.components.SmallInfoCard import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TextColorType -import com.tangem.core.ui.res.textColor import com.tangem.feature.referral.presentation.R @OptIn(ExperimentalComposeUiApi::class) @@ -55,7 +52,7 @@ internal fun ParticipateBottomBlock( endText = pluralStringResource( id = R.plurals.referral_wallets_purchased_count, count = purchasedWalletCount, - purchasedWalletCount + purchasedWalletCount, ), ) PersonalCodeCard(code = code) @@ -73,7 +70,7 @@ private fun PersonalCodeCard(code: String) { shape = RoundedCornerShape(TangemTheme.dimens.radius12), ) .background( - color = MaterialTheme.colors.secondary, + color = TangemTheme.colors.background.secondary, shape = RoundedCornerShape(TangemTheme.dimens.radius12), ) .fillMaxWidth() @@ -83,15 +80,15 @@ private fun PersonalCodeCard(code: String) { ) { Text( text = stringResource(id = R.string.referral_promo_code_title), - color = MaterialTheme.colors.textColor(type = TextColorType.TERTIARY), + color = TangemTheme.colors.text.tertiary, maxLines = 1, - style = MaterialTheme.typography.subtitle2, + style = TangemTheme.typography.subtitle2, ) Text( text = code, - color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1), + color = TangemTheme.colors.text.primary1, maxLines = 1, - style = MaterialTheme.typography.h2, + style = TangemTheme.typography.h2, ) } } @@ -143,7 +140,7 @@ private fun Context.shareText(text: String) { @Composable fun Preview_ParticipateBottomBlock_InLightTheme() { TangemTheme(isDark = false) { - Column(Modifier.background(MaterialTheme.colors.primary)) { + Column(Modifier.background(TangemTheme.colors.background.primary)) { ParticipateBottomBlock( purchasedWalletCount = 3, code = "x4JdK", @@ -159,7 +156,7 @@ fun Preview_ParticipateBottomBlock_InLightTheme() { @Composable fun Preview_ParticipateBottomBlock_InDarkTheme() { TangemTheme(isDark = true) { - Column(Modifier.background(MaterialTheme.colors.primary)) { + Column(Modifier.background(TangemTheme.colors.background.primary)) { ParticipateBottomBlock( purchasedWalletCount = 3, code = "x4JdK", diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt index 39d5296a12..361157353b 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt @@ -7,8 +7,10 @@ import androidx.compose.foundation.LocalOverscrollConfiguration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -21,7 +23,6 @@ import androidx.compose.material.BottomSheetState import androidx.compose.material.BottomSheetValue import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme import androidx.compose.material.Snackbar import androidx.compose.material.SnackbarDuration import androidx.compose.material.SnackbarHost @@ -56,15 +57,8 @@ 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.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 -import com.tangem.core.ui.res.iconColor -import com.tangem.core.ui.res.textColor import com.tangem.feature.referral.models.ReferralStateHolder import com.tangem.feature.referral.models.ReferralStateHolder.ErrorSnackbar import com.tangem.feature.referral.models.ReferralStateHolder.ReferralInfoContentState @@ -131,14 +125,15 @@ private fun ReferralContent(stateHolder: ReferralStateHolder, onAgreementClicked CompositionLocalProvider(LocalOverscrollConfiguration provides null) { LazyColumn( modifier = Modifier - .background(color = MaterialTheme.colors.primary) - .fillMaxWidth(), + .background(color = TangemTheme.colors.background.secondary) + .fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, ) { stickyHeader { AppBarWithBackButton( text = stringResource(R.string.details_referral_title), onBackClick = stateHolder.headerState.onBackClicked, + modifier = Modifier.background(color = TangemTheme.colors.background.secondary), ) } item { Header() } @@ -172,10 +167,10 @@ private fun Header() { Text( text = stringResource(id = R.string.referral_title), modifier = Modifier.padding(horizontal = dimensionResource(R.dimen.spacing50)), - color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1), + color = TangemTheme.colors.text.primary1, textAlign = TextAlign.Center, maxLines = 2, - style = MaterialTheme.typography.h2, + style = TangemTheme.typography.h2, ) VerticalSpacer(spaceResId = R.dimen.spacing16) } @@ -262,7 +257,7 @@ private fun Condition(@DrawableRes iconResId: Int, infoBlock: @Composable () -> Box( modifier = Modifier .background( - color = MaterialTheme.colors.buttonColor(type = ButtonColorType.SECONDARY), + color = TangemTheme.colors.button.secondary, shape = RoundedCornerShape(TangemTheme.dimens.radius16), ) .size(TangemTheme.dimens.size56), @@ -272,7 +267,7 @@ private fun Condition(@DrawableRes iconResId: Int, infoBlock: @Composable () -> painter = painterResource(id = iconResId), contentDescription = null, modifier = Modifier.size(TangemTheme.dimens.size28), - tint = MaterialTheme.colors.iconColor(type = IconColorType.PRIMARY1), + tint = TangemTheme.colors.icon.primary1, ) } infoBlock() @@ -285,7 +280,7 @@ private fun InfoForYou(award: String, networkName: String, address: String? = nu Text( text = buildAnnotatedString { append(stringResource(id = R.string.referral_point_currencies_description_prefix)) - withStyle(SpanStyle(color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1))) { + withStyle(SpanStyle(color = TangemTheme.colors.text.primary1)) { append(" $award ") } append( @@ -296,8 +291,8 @@ private fun InfoForYou(award: String, networkName: String, address: String? = nu ), ) }, - color = MaterialTheme.colors.textColor(type = TextColorType.TERTIARY), - style = MaterialTheme.typography.body2, + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.body2, ) } } @@ -306,19 +301,21 @@ private fun InfoForYou(award: String, networkName: String, address: String? = nu private fun InfoForYourFriend(discount: String) { ConditionInfo(title = stringResource(id = R.string.referral_point_discount_title)) { Text( - text = buildString { + text = buildAnnotatedString { append(stringResource(id = R.string.referral_point_discount_description_prefix)) - append( - String.format( - stringResource(id = R.string.referral_point_discount_description_value), - " $discount", - ), - ) + withStyle(SpanStyle(color = TangemTheme.colors.text.primary1)) { + append( + String.format( + stringResource(id = R.string.referral_point_discount_description_value), + " $discount", + ), + ) + } append(" ") append(stringResource(id = R.string.referral_point_discount_description_suffix)) }, - color = MaterialTheme.colors.textColor(type = TextColorType.TERTIARY), - style = MaterialTheme.typography.body2, + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.body2, ) } } @@ -328,8 +325,8 @@ private fun ConditionInfo(title: String, subtitleContent: @Composable () -> Unit Column(verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing2)) { Text( text = title, - color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY1), - style = MaterialTheme.typography.subtitle1, + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.subtitle1, ) subtitleContent() } @@ -350,6 +347,7 @@ private fun ShimmerInfo() { .width(TangemTheme.dimens.size102) .height(TangemTheme.dimens.size16) .background(TangemColorPalette.White), + // .background(Color(0xFFF8F8F8)), ) Box( modifier = Modifier @@ -363,23 +361,23 @@ private fun ShimmerInfo() { // TODO() Replace component with component from ds @Composable -private fun ErrorSnackbarHost(errorSnackbar: ErrorSnackbar?) { +private fun BoxScope.ErrorSnackbarHost(errorSnackbar: ErrorSnackbar?) { if (errorSnackbar != null) { val snackbarHostState by remember { mutableStateOf(SnackbarHostState()) } val coroutineScope = rememberCoroutineScope() SnackbarHost( hostState = snackbarHostState, - modifier = Modifier.padding(top = TangemTheme.dimens.spacing56), + modifier = Modifier.align(Alignment.BottomCenter), snackbar = { Snackbar( snackbarData = it, modifier = Modifier.fillMaxWidth(), actionOnNewLine = true, shape = RoundedCornerShape(size = TangemTheme.dimens.radius8), - backgroundColor = Black, - contentColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2), - actionColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2), + backgroundColor = TangemColorPalette.Black, + contentColor = TangemTheme.colors.text.primary2, + actionColor = TangemTheme.colors.text.primary2, elevation = TangemTheme.dimens.elevation3, ) }, @@ -412,7 +410,7 @@ private fun ErrorSnackbarHost(errorSnackbar: ErrorSnackbar?) { // TODO() Replace component with component from ds @Composable -private fun CopySnackbarHost(isCopyButtonPressed: MutableState) { +private fun BoxScope.CopySnackbarHost(isCopyButtonPressed: MutableState) { if (isCopyButtonPressed.value) { val snackbarHostState by remember { mutableStateOf(SnackbarHostState()) } val coroutineScope = rememberCoroutineScope() @@ -424,13 +422,14 @@ private fun CopySnackbarHost(isCopyButtonPressed: MutableState) { SnackbarHost( hostState = snackbarHostState, modifier = Modifier - .padding(top = TangemTheme.dimens.spacing56, start = (width - snackbarWidth).div(2)) + .align(Alignment.BottomCenter) + .padding(start = (width - snackbarWidth).div(2), bottom = dimensionResource(R.dimen.spacing12)) .fillMaxWidth(), snackbar = { Box( modifier = Modifier .onSizeChanged { snackbarSize = it.width } - .background(Black, RoundedCornerShape(size = TangemTheme.dimens.radius8)) + .background(TangemColorPalette.Black, RoundedCornerShape(size = TangemTheme.dimens.radius8)) .shadow( TangemTheme.dimens.elevation3, RoundedCornerShape(size = TangemTheme.dimens.radius8), @@ -442,8 +441,8 @@ private fun CopySnackbarHost(isCopyButtonPressed: MutableState) { ) { Text( text = it.message, - color = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2), - style = MaterialTheme.typography.body2, + color = TangemTheme.colors.text.primary2, + style = TangemTheme.typography.body2, ) } }, diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/viewmodels/ReferralViewModel.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/viewmodels/ReferralViewModel.kt index 21bd4b1057..ded54643ff 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/viewmodels/ReferralViewModel.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/viewmodels/ReferralViewModel.kt @@ -107,9 +107,9 @@ internal class ReferralViewModel @Inject constructor( private fun ReferralData.getDiscountValue(): String { val discountSymbol = when (discountType) { DiscountType.PERCENTAGE -> "%" - DiscountType.VALUE -> error("Value doesn't support") + DiscountType.VALUE -> this.getToken().symbol } - return "$discount $discountSymbol" + return "$discount$discountSymbol" } private fun ReferralData.getToken() = requireNotNull(tokens.firstOrNull()) { "Token list is empty" }