From f9ffe3a2d6bbde3c5648f828e6da91311e5fab54 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 24 Jul 2025 15:38:15 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../features/kyc/DefaultKycComponent.kt | 26 ++---- .../kyc/theme/TangemSNSIconHandler.kt | 35 +++++++ .../features/kyc/theme/TangemSNSTheme.kt | 91 +++++++++++++++++++ .../main/res/drawable/ic_kyc_drivers_24.xml | 30 ++++++ .../drawable/ic_kyc_email_verification_22.xml | 9 ++ .../main/res/drawable/ic_kyc_identity_22.xml | 13 +++ .../drawable/ic_kyc_other_countries_24.xml | 9 ++ .../main/res/drawable/ic_kyc_passport_22.xml | 29 ++++++ .../drawable/ic_kyc_phone_verification_24.xml | 9 ++ .../res/drawable/ic_kyc_profile_data_22.xml | 9 ++ .../drawable/ic_kyc_proof_of_residence_22.xml | 9 ++ .../res/drawable/ic_kyc_questionnaire_22.xml | 9 ++ .../main/res/drawable/ic_kyc_selfie_22.xml | 16 ++++ gradle/dependencies.toml | 2 +- 14 files changed, 277 insertions(+), 19 deletions(-) create mode 100644 features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSIconHandler.kt create mode 100644 features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSTheme.kt create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_drivers_24.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_email_verification_22.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_identity_22.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_other_countries_24.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_passport_22.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_phone_verification_24.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_profile_data_22.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_proof_of_residence_22.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_questionnaire_22.xml create mode 100644 features/kyc/impl/src/main/res/drawable/ic_kyc_selfie_22.xml diff --git a/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/DefaultKycComponent.kt b/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/DefaultKycComponent.kt index 8430ca49f1..afabc4e184 100644 --- a/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/DefaultKycComponent.kt +++ b/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/DefaultKycComponent.kt @@ -4,14 +4,13 @@ import com.sumsub.sns.core.SNSMobileSDK import com.sumsub.sns.core.data.listener.SNSCompleteHandler import com.sumsub.sns.core.data.listener.TokenExpirationHandler import com.sumsub.sns.core.data.model.SNSCompletionResult +import com.sumsub.sns.core.data.model.SNSInitConfig import com.sumsub.sns.core.data.model.SNSSDKState -import com.sumsub.sns.core.theme.SNSTheme -import com.sumsub.sns.core.theme.SNSThemeMetric -import com.sumsub.sns.core.theme.colors -import com.sumsub.sns.core.theme.metrics import com.tangem.core.decompose.context.AppComponentContext import com.tangem.domain.pay.repository.KycRepository import com.tangem.domain.models.wallet.UserWalletId +import com.tangem.features.kyc.theme.TangemSNSTheme +import com.tangem.features.kyc.theme.TangemSNSIconHandler import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject @@ -28,7 +27,7 @@ class DefaultKycComponent @AssistedInject constructor( override fun launch() { componentScope.launch { - // val startInfo = kycRepository.getKycStartInfo().getOrNull() ?: return@launch + val startInfo = kycRepository.getKycStartInfo().getOrNull() ?: return@launch val tokenExpirationHandler = object : TokenExpirationHandler { override fun onTokenExpired(): String? { @@ -38,19 +37,10 @@ class DefaultKycComponent @AssistedInject constructor( } val snsSdk = SNSMobileSDK.Builder(activity) - .withAccessToken( - "TODO", - onTokenExpiration = tokenExpirationHandler, - ) - .withTheme( - SNSTheme { - colors { - } - metrics { - this.screenHeaderAlignment = SNSThemeMetric.TextAlignment.CENTER - } - }, - ) + .withAccessToken(accessToken = startInfo.token, onTokenExpiration = tokenExpirationHandler) + .withConf(SNSInitConfig(strings = mapOf())) + .withTheme(TangemSNSTheme.theme(activity)) + .withIconHandler(TangemSNSIconHandler()) .withLocale(Locale("en")) .withCompleteHandler( object : SNSCompleteHandler { diff --git a/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSIconHandler.kt b/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSIconHandler.kt new file mode 100644 index 0000000000..df8d389dbb --- /dev/null +++ b/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSIconHandler.kt @@ -0,0 +1,35 @@ +package com.tangem.features.kyc.theme + +import android.content.Context +import android.graphics.drawable.Drawable +import androidx.core.content.res.ResourcesCompat +import com.sumsub.sns.core.data.listener.SNSDefaultIconHandler +import com.sumsub.sns.core.data.listener.SNSIconHandler +import com.tangem.features.kyc.impl.R + +/** + * Custom icons' settings for SumSub SDK + */ +internal class TangemSNSIconHandler : SNSDefaultIconHandler() { + @Suppress("CyclomaticComplexMethod") + override fun onResolveIcon(context: Context, key: String): Drawable? { + val iconRes = when { + key == "IdentityType/PASSPORT" -> R.drawable.ic_kyc_passport_22 + key == "IdentityType/DRIVERS" -> R.drawable.ic_kyc_drivers_24 + key == SNSIconHandler.SNSCommonIcons.COUNTRY_OTHER.imageName -> R.drawable.ic_kyc_other_countries_24 + key.startsWith("IdentityType/") -> R.drawable.ic_kyc_drivers_24 + key == "DocType/IDENTITY" -> R.drawable.ic_kyc_identity_22 + key == "DocType/PROOF_OF_RESIDENCE" -> R.drawable.ic_kyc_proof_of_residence_22 + key == "DocType/SELFIE" -> R.drawable.ic_kyc_selfie_22 + key == "DocType/APPLICANT_DATA" -> R.drawable.ic_kyc_profile_data_22 + key == "DocType/QUESTIONNAIRE" -> R.drawable.ic_kyc_questionnaire_22 + key == "DocType/PHONE_VERIFICATION" -> R.drawable.ic_kyc_phone_verification_24 + key == "DocType/EMAIL_VERIFICATION" -> R.drawable.ic_kyc_email_verification_22 + key == SNSIconHandler.SNSCommonIcons.PICTURE_AGREEMENT.imageName -> -1 + else -> null + } + return iconRes?.let { + if (iconRes != -1) ResourcesCompat.getDrawable(context.resources, it, context.theme) else null + } ?: run { super.onResolveIcon(context, key) } + } +} \ No newline at end of file diff --git a/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSTheme.kt b/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSTheme.kt new file mode 100644 index 0000000000..5cdbd2af74 --- /dev/null +++ b/features/kyc/impl/src/main/kotlin/com/tangem/features/kyc/theme/TangemSNSTheme.kt @@ -0,0 +1,91 @@ +package com.tangem.features.kyc.theme + +import android.content.Context +import android.graphics.Typeface +import androidx.compose.ui.graphics.toArgb +import androidx.core.content.res.ResourcesCompat +import com.sumsub.sns.core.theme.* +import com.tangem.core.ui.res.TangemColorPalette +import com.tangem.features.kyc.impl.R + +/** + * Custom theme settings for SumSub SDK + */ +internal object TangemSNSTheme { + + @Suppress("MagicNumber") + fun theme(context: Context): SNSTheme { + val robotoRegular = ResourcesCompat.getFont(context, R.font.roboto_regular) ?: Typeface.DEFAULT + val robotoMedium = ResourcesCompat.getFont(context, R.font.roboto_medium) ?: Typeface.DEFAULT_BOLD + return SNSTheme { + colors { + backgroundCommon = SNSThemeColor(TangemColorPalette.White.toArgb()) + contentStrong = SNSThemeColor(TangemColorPalette.Black.toArgb()) + contentNeutral = SNSThemeColor(TangemColorPalette.Dark2.toArgb()) + contentWeak = SNSThemeColor(TangemColorPalette.Light5.toArgb()) + primaryButtonBackground = SNSThemeColor(TangemColorPalette.Black.toArgb()) + primaryButtonContent = SNSThemeColor(TangemColorPalette.White.toArgb()) + primaryButtonBackgroundDisabled = SNSThemeColor(TangemColorPalette.Light3.toArgb()) + primaryButtonContentDisabled = SNSThemeColor(TangemColorPalette.Light5.toArgb()) + fieldBackground = SNSThemeColor(TangemColorPalette.Light1.toArgb()) + fieldBorder = SNSThemeColor(TangemColorPalette.Light3.toArgb()) + fieldBorderFocused = SNSThemeColor(TangemColorPalette.Azure.toArgb()) + fieldBorderDisabled = SNSThemeColor(TangemColorPalette.Light2.toArgb()) + fieldPlaceholder = SNSThemeColor(TangemColorPalette.Dark1.toArgb()) + fieldTint = SNSThemeColor(TangemColorPalette.Azure.toArgb()) + fieldContent = SNSThemeColor(TangemColorPalette.Black.toArgb()) + listSelectedItemBackground = SNSThemeColor(TangemColorPalette.Azure.copy(alpha = 0.1f).toArgb()) + cardPlainBackground = SNSThemeColor(TangemColorPalette.White.toArgb()) + contentLink = SNSThemeColor(TangemColorPalette.Azure.toArgb()) + statusBarColor = SNSThemeColor(TangemColorPalette.White.toArgb()) + contentWarning = SNSThemeColor(TangemColorPalette.Azure.toArgb()) + contentCritical = SNSThemeColor(TangemColorPalette.Amaranth.toArgb()) + contentSuccess = SNSThemeColor(TangemColorPalette.Azure.toArgb()) + } + fonts { + body = SNSThemeFont(robotoRegular, 14) + caption = SNSThemeFont(robotoRegular, 12) + headline1 = SNSThemeFont(robotoMedium, 34) + headline2 = SNSThemeFont(robotoMedium, 24) + subtitle1 = SNSThemeFont(robotoMedium, 16) + subtitle2 = SNSThemeFont(robotoMedium, 14) + } + metrics { + screenHorizontalMargin = 16.dpToPx(context) + buttonHeight = 64.dpToPx(context) + buttonCornerRadius = 14.dpToPx(context) + buttonBorderWidth = 0f + fieldHeight = 52.dpToPx(context) + fieldCornerRadius = 8.dpToPx(context) + fieldBorderWidth = 1.dpToPx(context) + cardCornerRadius = 12.dpToPx(context) + cardBorderWidth = 1.dpToPx(context) + listSeparatorHeight = 1.dpToPx(context) + listSeparatorMarginLeft = 16.dpToPx(context) + listSeparatorMarginRight = 16.dpToPx(context) + bottomSheetCornerRadius = 24.dpToPx(context) + viewportBorderWidth = 2.dpToPx(context) + documentFrameBorderWidth = 1.dpToPx(context) + documentFrameCornerRadius = 12.dpToPx(context) + documentFrameCornerSize = 8.dpToPx(context) + segmentedControlCornerRadius = 8.dpToPx(context) + + screenHeaderAlignment = SNSThemeMetric.TextAlignment.CENTER + sectionHeaderAlignment = SNSThemeMetric.TextAlignment.CENTER + verificationStepCardStyle = SNSThemeMetric.CardStyle.PLAIN + supportItemCardStyle = SNSThemeMetric.CardStyle.PLAIN + documentTypeCardStyle = SNSThemeMetric.CardStyle.BORDERED + selectedCountryCardStyle = SNSThemeMetric.CardStyle.BORDERED + agreementCardStyle = SNSThemeMetric.CardStyle.PLAIN + videoIdentLanguageCardStyle = SNSThemeMetric.CardStyle.PLAIN + videoIdentStepCardStyle = SNSThemeMetric.CardStyle.PLAIN + sumsubIdCardStyle = SNSThemeMetric.CardStyle.PLAIN + activityIndicatorStyle = SNSThemeMetric.Size.MEDIUM + } + } + } + + private fun Int.dpToPx(context: Context): Float { + return this * context.resources.displayMetrics.density + } +} \ No newline at end of file diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_drivers_24.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_drivers_24.xml new file mode 100644 index 0000000000..eb0c1eba4d --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_drivers_24.xml @@ -0,0 +1,30 @@ + + + + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_email_verification_22.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_email_verification_22.xml new file mode 100644 index 0000000000..ddd98399d0 --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_email_verification_22.xml @@ -0,0 +1,9 @@ + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_identity_22.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_identity_22.xml new file mode 100644 index 0000000000..746c3da002 --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_identity_22.xml @@ -0,0 +1,13 @@ + + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_other_countries_24.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_other_countries_24.xml new file mode 100644 index 0000000000..c14d2d4a6f --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_other_countries_24.xml @@ -0,0 +1,9 @@ + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_passport_22.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_passport_22.xml new file mode 100644 index 0000000000..4f42d322c8 --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_passport_22.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_phone_verification_24.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_phone_verification_24.xml new file mode 100644 index 0000000000..41f41ddd71 --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_phone_verification_24.xml @@ -0,0 +1,9 @@ + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_profile_data_22.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_profile_data_22.xml new file mode 100644 index 0000000000..20ed95d3af --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_profile_data_22.xml @@ -0,0 +1,9 @@ + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_proof_of_residence_22.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_proof_of_residence_22.xml new file mode 100644 index 0000000000..9f6c6bed3c --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_proof_of_residence_22.xml @@ -0,0 +1,9 @@ + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_questionnaire_22.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_questionnaire_22.xml new file mode 100644 index 0000000000..d6b75330f0 --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_questionnaire_22.xml @@ -0,0 +1,9 @@ + + + diff --git a/features/kyc/impl/src/main/res/drawable/ic_kyc_selfie_22.xml b/features/kyc/impl/src/main/res/drawable/ic_kyc_selfie_22.xml new file mode 100644 index 0000000000..78b2d88cc6 --- /dev/null +++ b/features/kyc/impl/src/main/res/drawable/ic_kyc_selfie_22.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index 16f13a4a15..03d9b1f740 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -90,7 +90,7 @@ room = "2.6.1" markdown = "0.7.2" markdownComposeView = "0.5.4" usedesk = "4.4.0" -sumsub = "1.36.0" +sumsub = "1.35.1" # endregion Other libraries # region Tools