CountryPicker
0.1.4indexedLightweight, customizable country selection component with search functionality and country flags. Supports multiple platforms, offering efficient performance and diverse UI customization options.
Lightweight, customizable country selection component with search functionality and country flags. Supports multiple platforms, offering efficient performance and diverse UI customization options.
🌍A lightweight, customizable country selection component for Compose Multiplatform applications
Add the dependency below to your module's build.gradle file:
dependencies {
implementation("io.github.androidpoet.countrypicker:$version")
}
For Kotlin Multiplatform, add the dependency below to your module's build.gradle.kts file:
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.androidpoet.countrypicker:$version")
}
}
}
Here's a basic example of how to use the ComposePicker in your Compose Multiplatform project:
@Composable
{
currantCountry remember { mutableStateOf() }
isBottomSheetVisible remember { mutableStateOf() }
CountryPicker(
onCountryChanged = {
currantCountry = it.name + + it.flag + + it.alpha2
},
onDismiss = {
isBottomSheetVisible =
},
itemContent = { country, onClick ->
CountryItem(
name = country.name,
countryCode = country.phoneCountryCode,
flag = country.flag.toString(),
onItemClick = onClick,
itemBackgroundColor = Color.White,
textColor = Color.Black,
currencyCode = country.currencyCode.orEmpty(),
currencySign = country.currencySign.orEmpty(),
)
},
isBottomSheetVisible = isBottomSheetVisible,
)
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Column {
Text(currantCountry, fontSize = sp)
Button(onClick = {
isBottomSheetVisible = !isBottomSheetVisible
}) {
Text(, fontSize = sp)
}
}
}
}
ComposePicker offers various customization options:
CountryPicker(
onCountryChanged = {
currantCountry = it.name + " " + it.flag + " " + it.alpha2
},
onDismiss = {
isBottomSheetVisible = false
},
itemContent = { country, onClick ->
// pass your own layout here
CountryItem(
name = country.name,
countryCode = country.phoneCountryCode,
flag = country.flag.toString(),
onItemClick = onClick,
itemBackgroundColor = Color.White,
textColor = Color.Black,
currencyCode = country.currencyCode.orEmpty(),
currencySign = country.currencySign.orEmpty(),
)
},
isBottomSheetVisible = isBottomSheetVisible,
)
Contributions are welcome! If you've found a bug, have an idea for an improvement, or want to contribute new features, please open an issue or submit a pull request.
Support it by joining stargazers for this repository. :star:
Also, follow me on GitHub for my next creations! 🤩
Designed and developed ()
Licensed under the Apache License, Version 2.0 ();
you may use except compliance the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
Surfaced from shared tags and platforms — no rankings paid for.