Skip to content

jump-sdk/jetpack_compose_country_code_picker_emoji

Repository files navigation

Jetpack Compose Country Code Picker Emoji

Android CI Maintainability Rating Jitpack

  • 😍 Emoji flag icons - beautiful and minimizes library size
  • 🤔 Country numbers hints (option to disable)
  • 🔢 Phone number visualTransformation (Automatic number formatting)
  • 🇺🇳 Automatic country recognition (detection by sim card if sim card is inserted)
  • ⚙️ Advanced customization options (see usage below)
  • 🏁 Fast! Flattened layouts and immutable collections prevent unwanted recomposition.
  • ✅ Code quality checks with Ktlint and Detekt, snapshot testing with Paparazzi
  • 🗣 Multilingual: Turkish, English, Italian, Arabic, Russian, Dutch, Spanish, Somali, French, Chinese, Hindi

Screenshots

Usage

See MainActivity in the sample app for a full example.

        TogiCountryCodePicker(
            onValueChange = { (code, phone), isValid ->
                Log.d("CCP", "onValueChange: $code $phone -> $isValid")
                phoneNumber.value = phone
                fullPhoneNumber.value = code + phone
                isNumberValid = isValid
            },
        )
Parameter Description
onValueChange Called when the text in the text field changes. The first parameter is string pair of (country code, phone number) and the second parameter is a boolean indicating whether the phone number is valid.
modifier Modifier to be applied to the inner OutlinedTextField.
enabled Boolean indicating whether the field is enabled.
shape Shape of the text field.
showCountryCode Whether to show the country code in the text field.
showCountryFlag Whether to show the country flag in the text field.
colors Colors to be used for the text field.
fallbackCountryCode The country to be used as a fallback if the user's country cannot be determined.
showPlaceholder Whether to show the placeholder number in the text field.
includeOnly A set of 2 digit country codes to be included in the list of countries. Set to null to include all supported countries.
clearIcon The icon to be used for the clear button. Set to null to disable the clear button.
initialPhoneNumber An optional phone number to be initial value of the input field.
initialCountryCode An optional ISO-3166-1 alpha-2 country code equivalent of the MCC (Mobile Country Code) of the initially selected country.
initialCountryPhoneCode An optional Phone calling code of initially selected country.
label An optional composable to be used as a label for input field.

How to add in your project

Step 1: In the build.gradle add Jitpack repository.

In Groovy:

    repositories {
        maven { url 'https://jitpack.io' }
    }

In Kts:

    repositories {
        maven("https://jitpack.io")
    }

Step 2. Add the dependency

	dependencies {
	    implementation("com.github.jump-sdk:jetpack_compose_country_code_picker_emoji:2.0.8")
	}  

Contributing

  • PRs and bug reports / feature requests are welcome!
  • This project is linted with ktlint and statically checked with detekt
  • Additional checking done with Twitter's and appKODE's Jetpack Compose rules for Detekt
  • Treat other people with helpfulness, gratitude, and consideration! See the JetBrains CoC
  • Use precommit hook ./gradlew :ccp:detektMain :ccp:lint :ccp:verifyPaparazziDebug to check code quality before commit

All support goes to the original author

Buy Me A Coffee