Skip to content

Commit

Permalink
numberHint as map
Browse files Browse the repository at this point in the history
  • Loading branch information
hbmartin committed Mar 7, 2023
1 parent e2f1cfc commit d5a9125
Show file tree
Hide file tree
Showing 2 changed files with 252 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,18 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.togitech.ccp.R
import com.togitech.ccp.data.CountryData
import com.togitech.ccp.data.utils.countryDataMap
import com.togitech.ccp.data.utils.getDefaultPhoneCode
import com.togitech.ccp.data.utils.getNumberHint
import com.togitech.ccp.data.utils.isPhoneNumberValid
import com.togitech.ccp.data.utils.numberHint
import com.togitech.ccp.data.utils.unitedStates
import com.togitech.ccp.transformation.PhoneNumberTransformation
import kotlinx.collections.immutable.ImmutableSet

private val DEFAULT_TEXT_FIELD_SHAPE = RoundedCornerShape(24.dp)

@OptIn(ExperimentalComposeUiApi::class)
@Suppress("LongMethod")
@Composable
/**
* @param text The text to be displayed in the text field.
* @param onValueChange Called when the text in the text field changes.
Expand All @@ -71,6 +69,9 @@ private val DEFAULT_TEXT_FIELD_SHAPE = RoundedCornerShape(24.dp)
* Set to null to include all supported countries.
* @param clearIcon The icon to be used for the clear button. Set to null to disable the clear button.
*/
@OptIn(ExperimentalComposeUiApi::class)
@Suppress("LongMethod")
@Composable
fun TogiCountryCodePicker(
text: String,
onValueChange: (Pair<String, String>, Boolean) -> Unit,
Expand Down Expand Up @@ -183,11 +184,9 @@ private fun PlaceholderNumberHint(
) {
Text(
text = stringResource(
id = getNumberHint(
countryDataMap.getOrDefault(
langAndCode.first,
fallbackCountry,
).countryCode.lowercase(),
id = numberHint.getOrDefault(
countryDataMap.getOrDefault(langAndCode.first, fallbackCountry).countryCode,
R.string.unknown,
),
),
)
Expand Down
Loading

0 comments on commit d5a9125

Please sign in to comment.