From 85ce60ba223bcfefd3ccf11d1c3c860a373eac78 Mon Sep 17 00:00:00 2001 From: Vitalii Vanziak Date: Mon, 10 Aug 2026 16:15:39 +0300 Subject: [PATCH] Default phone number region code by default locale --- .../ui/napm/NativeAlternativePaymentInteractor.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ui/src/main/kotlin/com/processout/sdk/ui/napm/NativeAlternativePaymentInteractor.kt b/ui/src/main/kotlin/com/processout/sdk/ui/napm/NativeAlternativePaymentInteractor.kt index c2ae4338..c73f744d 100644 --- a/ui/src/main/kotlin/com/processout/sdk/ui/napm/NativeAlternativePaymentInteractor.kt +++ b/ui/src/main/kotlin/com/processout/sdk/ui/napm/NativeAlternativePaymentInteractor.kt @@ -12,6 +12,7 @@ import android.util.Patterns import androidx.annotation.StringRes import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.input.TextFieldValue +import androidx.core.os.LocaleListCompat import androidx.core.os.postDelayed import androidx.core.text.isDigitsOnly import androidx.lifecycle.DefaultLifecycleObserver @@ -75,6 +76,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.update +import java.util.Locale import java.util.UUID internal class NativeAlternativePaymentInteractor( @@ -421,7 +423,15 @@ internal class NativeAlternativePaymentInteractor( TextFieldValue(text = parameter.preselectedValue?.value ?: String()) ) is Parameter.Bool -> FieldValue.Text(TextFieldValue(text = "false")) - is Parameter.PhoneNumber -> FieldValue.PhoneNumber() + is Parameter.PhoneNumber -> { + val defaultLocale = LocaleListCompat.getAdjustedDefault()[0] ?: Locale.getDefault() + FieldValue.PhoneNumber( + regionCode = TextFieldValue( + text = if (parameter.dialingCodes.any { it.regionCode == defaultLocale.country }) + defaultLocale.country else String() + ) + ) + } else -> FieldValue.Text() } Field(