diff --git a/README.md b/README.md index 0c7351e..f23d149 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ TogiCountryCodePicker( | textStyle | An optional [TextStyle](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TextStyle) for customizing text style of phone number input field. Defaults to MaterialTheme.typography.body1 | | keyboardOptions | An optional [KeyboardOptions](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/KeyboardOptions) to customize keyboard options. | | keyboardActions | An optional [KeyboardActions](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/KeyboardActions) to customize keyboard actions. | - +| showError | Whether to show error on field when number is invalid, default true. | ## How to add in your project @@ -97,8 +97,8 @@ Step 2. Add the dependency - n.b. this currently does not support Material 3. ```kotlin dependencies { - implementation("androidx.compose.material:material:1.5.3") - implementation("com.github.jump-sdk:jetpack_compose_country_code_picker_emoji:2.2.4") + implementation("androidx.compose.material:material:1.5.4") + implementation("com.github.jump-sdk:jetpack_compose_country_code_picker_emoji:2.2.5") } ``` diff --git a/ccp/build.gradle.kts b/ccp/build.gradle.kts index 48a470a..98430af 100644 --- a/ccp/build.gradle.kts +++ b/ccp/build.gradle.kts @@ -78,7 +78,7 @@ afterEvaluate { groupId = "com.togisoft" artifactId = "jetpack_country_code_picker" // Update version in README when changing below - version = "2.2.4" + version = "2.2.5" } } } diff --git a/ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt b/ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt index 0a907f1..82703da 100644 --- a/ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt +++ b/ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt @@ -63,6 +63,7 @@ private const val ROW_PADDING_VERTICAL_SCALING = 1.1f private val SEARCH_ICON_PADDING = 5.dp private const val HEADER_TEXT_SIZE_MULTIPLE = 1.5 private val MIN_TAP_DIMENSION = 48.dp +private const val DIVIDER_ALPHA = 0.12f /** * @param onDismissRequest Executes when the user tries to dismiss the dialog. @@ -72,6 +73,7 @@ private val MIN_TAP_DIMENSION = 48.dp * @param countryList The list of countries to display in the dialog. * @param rowPadding The padding to be applied to each row. * @param backgroundColor The [Color] of the dialog background. + * @param dividerColor The [Color] of the country row dividers. */ @Composable fun CountryDialog( @@ -82,6 +84,7 @@ fun CountryDialog( countryList: ImmutableList = persistentListOf(), rowPadding: Dp = DEFAULT_ROW_PADDING, backgroundColor: Color = MaterialTheme.colors.surface, + dividerColor: Color = MaterialTheme.colors.onSurface.copy(alpha = DIVIDER_ALPHA), ) { val context = LocalContext.current var searchValue by rememberSaveable { mutableStateOf("") } @@ -124,7 +127,7 @@ fun CountryDialog( Spacer(modifier = Modifier.height(DEFAULT_ROW_PADDING)) LazyColumn { items(filteredCountries, key = { it.countryIso }) { countryItem -> - Divider() + Divider(color = dividerColor) CountryRowItem( rowPadding = rowPadding, onSelect = { onSelect(countryItem) }, diff --git a/ccp/src/main/java/com/togitech/ccp/component/TogiCodeDialog.kt b/ccp/src/main/java/com/togitech/ccp/component/TogiCodeDialog.kt index 26b1188..bb832a3 100644 --- a/ccp/src/main/java/com/togitech/ccp/component/TogiCodeDialog.kt +++ b/ccp/src/main/java/com/togitech/ccp/component/TogiCodeDialog.kt @@ -43,6 +43,7 @@ internal fun TogiCodeDialog( showCountryCode: Boolean, showFlag: Boolean, textStyle: TextStyle, + backgroundColor: Color, ) { val context = LocalContext.current @@ -93,6 +94,7 @@ internal fun TogiCodeDialog( } else { textStyle.copy(color = MaterialTheme.colors.onSurface) }, + backgroundColor = backgroundColor, ) } } @@ -145,5 +147,6 @@ private fun TogiCodeDialogPreview() { showCountryCode = true, showFlag = true, textStyle = TextStyle(), + backgroundColor = Color.White, ) } diff --git a/ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt b/ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt index 6a26e03..b5e5777 100644 --- a/ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt +++ b/ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt @@ -81,6 +81,7 @@ private const val TAG = "TogiCountryCodePicker" * Defaults to MaterialTheme.typography.body1 * @param [keyboardOptions] An optional [KeyboardOptions] to customize keyboard options. * @param [keyboardActions] An optional [KeyboardActions] to customize keyboard actions. + * @param [showError] Whether to show error on field when number is invalid, default true. */ @OptIn(ExperimentalComposeUiApi::class) @Suppress("LongMethod") @@ -102,10 +103,11 @@ fun TogiCountryCodePicker( initialCountryPhoneCode: PhoneCode? = null, label: @Composable (() -> Unit)? = null, textStyle: TextStyle = MaterialTheme.typography.body1.copy( - color = MaterialTheme.colors.onSurface, + color = colors.textColor(enabled = true).value, ), keyboardOptions: KeyboardOptions? = null, keyboardActions: KeyboardActions? = null, + showError: Boolean = true, ) { val context = LocalContext.current val focusRequester = remember { FocusRequester() } @@ -212,6 +214,7 @@ fun TogiCountryCodePicker( showCountryCode = showCountryCode, showFlag = showCountryFlag, textStyle = textStyle, + backgroundColor = colors.backgroundColor(enabled = true).value, ) }, trailingIcon = { @@ -227,7 +230,7 @@ fun TogiCountryCodePicker( } } }, - isError = !isNumberValid, + isError = showError && !isNumberValid, visualTransformation = phoneNumberTransformation, keyboardOptions = keyboardOptions ?: KeyboardOptions.Default.copy( keyboardType = KeyboardType.Phone, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2163f20..111de5a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] kotlin = "1.9.10" -dokka = "1.9.0" +dokka = "1.9.10" ## SDK Versions minSdk = "24" @@ -8,7 +8,7 @@ targetSdk = "34" compileSdk = "34" # Dependencies -android-gradle-plugin = "8.2.0-beta06" +android-gradle-plugin = "8.2.0-rc01" gradle-versions = "0.49.0" detekt = "1.23.1" @@ -19,7 +19,7 @@ androidx-lifecycle = "2.6.2" androidx-test-junit = "1.1.5" # update version in README when changing below -compose = "1.5.3" +compose = "1.5.4" # https://androidx.dev/storage/compose-compiler/repository/ # https://developer.android.com/jetpack/androidx/releases/compose-compiler composeCompiler = "1.5.3"