CountryPickerConfig

data class CountryPickerConfig(val selectionMode: CountrySelectionMode = CountrySelectionMode.Single, val allowedCountryCodes: Set<String>? = null, val excludedCountryCodes: Set<String> = emptySet(), val disabledCountryCodes: Set<String> = emptySet(), val enabledRegions: Set<CountryRegion> = CountryRegion.entries.toSet(), val initialRegion: CountryRegion? = null, val showRecentlySelected: Boolean = true, val showSuggestedCountries: Boolean = true, val showSearch: Boolean = true, val closeOnSingleSelection: Boolean = true, val minimumSelectionCount: Int = 0, val maximumSelectionCount: Int? = null, val autoConfirmOnMaximum: Boolean = false, val searchFields: Set<CountrySearchField> = CountrySearchField.All, val minimumSearchQueryLength: Int = 1, val suggestedCountryCodes: List<String> = emptyList(), val recentCountryLimit: Int = 5, val countryComparator: Comparator<Country>? = null)(source)

Everything about what a picker offers and how selection behaves, in one value.

Appearance is not here: flags, list style, region filters, the A–Z rail and every other visual choice live in com.ezzy.ccp.countrypicker.theme.CountryPickerStyle. Keeping the two apart means a single config can be shared by every market selector in an app while each screen styles it as it needs:

val marketPicker = CountryPickerDefaults.config(allowedCountryCodes = supportedMarkets)

Instances are Immutable, so passing one to a composable does not defeat skipping.

Constructors

Link copied to clipboard
constructor(selectionMode: CountrySelectionMode = CountrySelectionMode.Single, allowedCountryCodes: Set<String>? = null, excludedCountryCodes: Set<String> = emptySet(), disabledCountryCodes: Set<String> = emptySet(), enabledRegions: Set<CountryRegion> = CountryRegion.entries.toSet(), initialRegion: CountryRegion? = null, showRecentlySelected: Boolean = true, showSuggestedCountries: Boolean = true, showSearch: Boolean = true, closeOnSingleSelection: Boolean = true, minimumSelectionCount: Int = 0, maximumSelectionCount: Int? = null, autoConfirmOnMaximum: Boolean = false, searchFields: Set<CountrySearchField> = CountrySearchField.All, minimumSearchQueryLength: Int = 1, suggestedCountryCodes: List<String> = emptyList(), recentCountryLimit: Int = 5, countryComparator: Comparator<Country>? = null)

Properties

Link copied to clipboard

When non-null, the only ISO alpha-2 codes offered. An empty set is meaningful: it allows nothing, and the sheet shows its "no countries available" state rather than silently falling back to everything.

Link copied to clipboard

Confirm automatically once maximumSelectionCount is reached. Reasonable for max = 1; surprising above that, so it defaults to off.

Link copied to clipboard

Dismiss the sheet after a single selection. Disable for a picker the user is expected to browse.

Link copied to clipboard

Custom ordering of the full list, or null for alphabetical by display name.

Link copied to clipboard

Codes shown but not selectable, marked "Not available". Prefer this over exclusion when the user needs to understand why their country cannot be chosen.

Link copied to clipboard

Regions offered as filters. Narrow it for a regional product.

Link copied to clipboard

Codes removed from the list. Applied after allowedCountryCodes, so exclusion always wins.

Link copied to clipboard

Region pre-selected when the sheet opens, or null for "All".

Link copied to clipboard

True when this config drives a multiple-selection picker.

Link copied to clipboard

Multiple-selection ceiling, or null for unlimited. Further taps are refused with feedback rather than silently ignored.

Link copied to clipboard

Characters before search filters. 1 — local search is instant, so there is no reason to make the user type more.

Link copied to clipboard

Multiple-selection floor. Confirm stays disabled below it.

Link copied to clipboard

How many recents to surface.

Link copied to clipboard

Which fields search matches against.

Link copied to clipboard

Single or multiple selection. Multiple selection adds the confirmation bar.

Link copied to clipboard

Surface recent selections. Requires a com.ezzy.ccp.countrypicker.persistence.RecentCountryStore; with the default no-op store there are none to show.

Link copied to clipboard

Offer search.

Link copied to clipboard

Surface suggestedCountryCodes.

Link copied to clipboard

Codes to suggest. Deliberately empty by default: which countries deserve promotion is a product decision, and a library that ships ["US","GB"] as a universal default is asserting something false about most apps.

Functions

Link copied to clipboard
fun isAtMaximum(count: Int): Boolean

True when count has hit the ceiling and further additions must be refused.

Link copied to clipboard

True when count satisfies the min/max bounds, i.e. Confirm should be enabled.