From 630bba1c40dbdd359f9db94983f5026a0d5d64a2 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 3 May 2023 13:05:48 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../ui/components/AddCustomTokenWarning.kt | 3 +- .../com/tangem/core/ui/res/TangemDimens.kt | 3 + .../com/tangem/core/ui/res/TangemShapes.kt | 2 + .../src/main/res/drawable/ic_eye_off_24.xml | 9 + features/wallet/api/.gitignore | 1 + features/wallet/api/build.gradle.kts | 5 + .../wallet/api/src/main/AndroidManifest.xml | 2 + features/wallet/impl/.gitignore | 1 + features/wallet/impl/build.gradle.kts | 34 ++++ .../wallet/impl/src/main/AndroidManifest.xml | 4 + .../main/presentation/ui/BalanceUIState.kt | 5 + .../main/presentation/ui/WalletHeader.kt | 185 ++++++++++++++++++ .../presentation/ui/WalletHeaderConfig.kt | 12 ++ .../extension/BaseExtensionConfigurations.kt | 4 +- settings.gradle.kts | 3 + 15 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 core/ui/src/main/res/drawable/ic_eye_off_24.xml create mode 100644 features/wallet/api/.gitignore create mode 100644 features/wallet/api/build.gradle.kts create mode 100644 features/wallet/api/src/main/AndroidManifest.xml create mode 100644 features/wallet/impl/.gitignore create mode 100644 features/wallet/impl/build.gradle.kts create mode 100644 features/wallet/impl/src/main/AndroidManifest.xml create mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/BalanceUIState.kt create mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeader.kt create mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeaderConfig.kt diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarning.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarning.kt index 5eb76c6e66..3e1b99796e 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarning.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarning.kt @@ -3,7 +3,6 @@ package com.tangem.tap.features.customtoken.impl.presentation.ui.components import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Card import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -30,7 +29,7 @@ import com.tangem.wallet.R internal fun AddCustomTokenWarning(description: TextReference, modifier: Modifier = Modifier) { Card( modifier = modifier, - shape = RoundedCornerShape(TangemTheme.dimens.radius4), + shape = TangemTheme.shapes.roundedCornersSmall2, backgroundColor = TangemColorPalette.Tangerine, contentColor = TangemColorPalette.White, elevation = TangemTheme.dimens.elevation4, diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt index d5d14244ae..5f37be0e27 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt @@ -65,7 +65,9 @@ data class TangemDimens internal constructor( val size93: Dp = 93.dp, val size96: Dp = 96.dp, val size102: Dp = 102.dp, + val size108: Dp = 108.dp, val size116: Dp = 116.dp, + val size120: Dp = 120.dp, val size142: Dp = 142.dp, val size164: Dp = 164.dp, val size200: Dp = 200.dp, @@ -95,5 +97,6 @@ data class TangemDimens internal constructor( val spacing54: Dp = 54.dp, val spacing56: Dp = 56.dp, val spacing92: Dp = 92.dp, + val spacing154: Dp = 154.dp, // endregion Spacing ) \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemShapes.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemShapes.kt index 57bd37658f..b452e38004 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/TangemShapes.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemShapes.kt @@ -9,6 +9,7 @@ data class TangemShapes internal constructor( val roundedCornersSmall: Shape, val roundedCornersSmall2: Shape, val roundedCornersMedium: Shape, + val roundedCornersXMedium: Shape, val roundedCornersLarge: Shape, val bottomSheet: Shape, ) { @@ -16,6 +17,7 @@ data class TangemShapes internal constructor( roundedCornersSmall = RoundedCornerShape(size = dimens.radius2), roundedCornersSmall2 = RoundedCornerShape(size = dimens.radius4), roundedCornersMedium = RoundedCornerShape(size = dimens.radius12), + roundedCornersXMedium = RoundedCornerShape(size = dimens.radius16), roundedCornersLarge = RoundedCornerShape(size = dimens.radius28), bottomSheet = RoundedCornerShape( topStart = dimens.radius16, diff --git a/core/ui/src/main/res/drawable/ic_eye_off_24.xml b/core/ui/src/main/res/drawable/ic_eye_off_24.xml new file mode 100644 index 0000000000..7454717d84 --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_eye_off_24.xml @@ -0,0 +1,9 @@ + + + diff --git a/features/wallet/api/.gitignore b/features/wallet/api/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/features/wallet/api/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/features/wallet/api/build.gradle.kts b/features/wallet/api/build.gradle.kts new file mode 100644 index 0000000000..1fbece85d5 --- /dev/null +++ b/features/wallet/api/build.gradle.kts @@ -0,0 +1,5 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + id("configuration") +} \ No newline at end of file diff --git a/features/wallet/api/src/main/AndroidManifest.xml b/features/wallet/api/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..85a7d6c7c5 --- /dev/null +++ b/features/wallet/api/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/features/wallet/impl/.gitignore b/features/wallet/impl/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/features/wallet/impl/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/features/wallet/impl/build.gradle.kts b/features/wallet/impl/build.gradle.kts new file mode 100644 index 0000000000..ea6af49097 --- /dev/null +++ b/features/wallet/impl/build.gradle.kts @@ -0,0 +1,34 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + alias(deps.plugins.hilt.android) + id("configuration") +} + +dependencies { + /** AndroidX */ + implementation(deps.androidx.activity.compose) + + /** Compose */ + implementation(deps.compose.material) + implementation(deps.compose.foundation) + implementation(deps.compose.navigation) + implementation(deps.compose.navigation.hilt) + implementation(deps.compose.ui) + implementation(deps.compose.ui.tooling) + implementation(deps.compose.shimmer) + implementation(deps.compose.accompanist.systemUiController) + + /** DI */ + implementation(deps.hilt.android) + kapt(deps.hilt.kapt) + + /** Core modules */ + implementation(project(":core:featuretoggles")) + implementation(project(":core:ui")) + + /** Feature Apis */ + implementation(project(":features:wallet:api")) + +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/AndroidManifest.xml b/features/wallet/impl/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..a1a96bfa00 --- /dev/null +++ b/features/wallet/impl/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/BalanceUIState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/BalanceUIState.kt new file mode 100644 index 0000000000..b6010c0f04 --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/BalanceUIState.kt @@ -0,0 +1,5 @@ +package com.tangem.feature.main.presentation.ui + +enum class BalanceUIState { + VISIBLE, LOADING, HIDDEN, NONE +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeader.kt b/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeader.kt new file mode 100644 index 0000000000..8c2ba58d7e --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeader.kt @@ -0,0 +1,185 @@ +package com.tangem.feature.main.presentation.ui + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Icon +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.sp +import com.tangem.core.ui.R +import com.tangem.core.ui.components.* +import com.tangem.core.ui.res.TangemTheme +import com.valentinilk.shimmer.shimmer + +@OptIn(ExperimentalMaterialApi::class) +@Composable +fun WalletHeaderCard(config: WalletHeaderConfig, modifier: Modifier = Modifier) { + Surface( + modifier = modifier.defaultMinSize(minHeight = TangemTheme.dimens.size108), + shape = TangemTheme.shapes.roundedCornersXMedium, + color = TangemTheme.colors.background.primary, + onClick = config.onClick ?: {}, + enabled = config.onClick != null, + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .height(intrinsicSize = IntrinsicSize.Max), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Column( + modifier = Modifier.padding(all = TangemTheme.dimens.spacing12), + verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8), + ) { + HeaderWalletName( + walletName = config.walletName, + balanceState = config.balanceState, + ) + HeaderBalanceTitle( + balance = config.balance, + balanceState = config.balanceState, + ) + Text( + text = config.additionalInfo, + color = TangemTheme.colors.text.disabled, + style = TangemTheme.typography.caption, + ) + } + Image( + modifier = Modifier + .width(TangemTheme.dimens.size120) + .padding(end = TangemTheme.dimens.spacing18) + .fillMaxHeight(), + painter = config.cardImage, + contentDescription = null, + contentScale = ContentScale.FillWidth, + ) + } + } +} + +@Composable +private fun HeaderWalletName(walletName: String, balanceState: BalanceUIState) { + if (balanceState == BalanceUIState.HIDDEN) { + Row(horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing4)) { + Text( + text = walletName, + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.body2, + maxLines = 1, + ) + Icon( + modifier = Modifier.size(size = TangemTheme.dimens.size20), + painter = painterResource(id = R.drawable.ic_eye_off_24), + contentDescription = null, + tint = TangemTheme.colors.icon.informative, + ) + } + } else { + Text( + text = walletName, + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.body2, + maxLines = 1, + ) + } +} + +@Composable +private fun HeaderBalanceTitle(balance: String, balanceState: BalanceUIState) { + when (balanceState) { + BalanceUIState.VISIBLE -> { + ResizableText( + text = balance, + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.h2, + fontSizeRange = FontSizeRange(min = 16.sp, max = TangemTheme.typography.h2.fontSize), + modifier = Modifier.defaultMinSize(minHeight = TangemTheme.dimens.size32), + ) + } + BalanceUIState.LOADING -> { + Box( + modifier = Modifier + .padding(vertical = TangemTheme.dimens.spacing4) + .size(width = TangemTheme.dimens.size102, height = TangemTheme.dimens.size24) + .shimmer() + .background( + color = TangemTheme.colors.button.secondary, + shape = RoundedCornerShape(TangemTheme.dimens.radius6), + ), + ) + } + BalanceUIState.HIDDEN -> { + Text( + text = "•••", + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.h2, + ) + } + BalanceUIState.NONE -> { + Text( + text = "—", + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.h2, + ) + } + } +} + +// region Preview + +@Composable +private fun WarningsPreview() { + val walletHeaderConfig = WalletHeaderConfig( + walletName = "Wallet 1", + balance = "8923,05 $", + additionalInfo = "3 cards • Seed enabled", + balanceState = BalanceUIState.VISIBLE, + cardImage = painterResource(id = R.drawable.ill_businessman_3d), + onClick = {}, + ) + Column(modifier = Modifier.fillMaxWidth()) { + WalletHeaderCard( + config = walletHeaderConfig, + ) + SpacerH32() + WalletHeaderCard( + config = walletHeaderConfig.copy(balanceState = BalanceUIState.HIDDEN), + ) + SpacerH32() + WalletHeaderCard( + config = walletHeaderConfig.copy(balanceState = BalanceUIState.LOADING), + ) + SpacerH32() + WalletHeaderCard( + config = walletHeaderConfig.copy(balanceState = BalanceUIState.NONE), + ) + SpacerH32() + } +} + +@Preview(showBackground = true) +@Composable +private fun Preview_Warning_InLightTheme() { + TangemTheme(isDark = false) { + WarningsPreview() + } +} + +@Preview(showBackground = true) +@Composable +private fun Preview_Warning_InDarkTheme() { + TangemTheme(isDark = true) { + WarningsPreview() + } +} + +// endregion Preview \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeaderConfig.kt b/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeaderConfig.kt new file mode 100644 index 0000000000..b8c22ca329 --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/main/presentation/ui/WalletHeaderConfig.kt @@ -0,0 +1,12 @@ +package com.tangem.feature.main.presentation.ui + +import androidx.compose.ui.graphics.painter.Painter + +data class WalletHeaderConfig( + val walletName: String, + val balance: String, + val additionalInfo: String, + val balanceState: BalanceUIState, + val cardImage: Painter, + val onClick: (() -> Unit)?, +) \ No newline at end of file diff --git a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/BaseExtensionConfigurations.kt b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/BaseExtensionConfigurations.kt index c1af6d55fe..c05a661a44 100644 --- a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/BaseExtensionConfigurations.kt +++ b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/BaseExtensionConfigurations.kt @@ -20,10 +20,10 @@ internal fun BaseExtension.configureCompilerOptions() { internal fun BaseExtension.configureCompose(project: Project) { val useCompose = with(project.path) { contains(":ui") || - contains(":onboarding") || + contains(":onboarding") || // TODO: divide on api/impl after migrating all onboarding to module contains(":presentation") || contains(":app") || // TODO: [REDACTED_JIRA] - contains(":tester:impl") // TODO: Rename module + contains(":impl") } buildFeatures.compose = useCompose if (useCompose) { diff --git a/settings.gradle.kts b/settings.gradle.kts index 70f5aeb9e2..2c4e5ecbcc 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -57,6 +57,9 @@ include(":features:swap:presentation") include(":features:tester:api") include(":features:tester:impl") + +include(":features:wallet:api") +include(":features:wallet:impl") // endregion Feature modules // region Domain modules