diff --git a/.gitignore b/.gitignore index 38ae652..c37fa82 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ /.idea/navEditor.xml /.idea/assetWizardSettings.xml /.idea/jarRepositories.xml +/.idea/deploymentTargetDropDown.xml +/.idea/apollo.xml +/.idea/graphql-settings.xml .DS_Store /build /captures diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 0c0c338..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file 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 5ec1b70..fe4f39d 100644 --- a/ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt +++ b/ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt @@ -62,7 +62,6 @@ private val DEFAULT_ROW_PADDING = 16.dp 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 /** * @param onDismissRequest Executes when the user tries to dismiss the dialog. @@ -217,7 +216,6 @@ private fun SearchTextField( BasicTextField( modifier = modifier - .height(MIN_TAP_DIMENSION) .fillMaxWidth() .focusRequester(requester), value = value, @@ -228,11 +226,10 @@ private fun SearchTextField( decorationBox = { innerTextField -> Row( Modifier - .fillMaxWidth() - .height(MIN_TAP_DIMENSION), + .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, ) { - if (leadingIcon != null) leadingIcon() + leadingIcon?.invoke() Box( modifier = Modifier .padding(start = DEFAULT_ROUNDING) 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 1856bc4..4c2b685 100644 --- a/ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt +++ b/ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt @@ -83,7 +83,8 @@ private const val TAG = "TogiCountryCodePicker" * @param initialCountryPhoneCode Optional country phone code to set the initially selected country. * This takes precedence over [initialCountryIsoCode]. * @param label An optional composable to be used as a label for input field - * @param textStyle An optional [TextStyle] for customizing text style of phone number input field + * @param textStyle An optional [TextStyle] for customizing text style of phone number input field. + * Defaults to MaterialTheme.typography.body1 */ @OptIn(ExperimentalComposeUiApi::class) @Suppress("LongMethod") @@ -126,7 +127,7 @@ fun TogiCountryCodePicker( if (initialPhoneNumber?.startsWith("+") == true) { Log.e(TAG, "initialPhoneNumber must not include the country code") } - if (initialCountryPhoneCode?.startsWith("+") != true) { + if (initialCountryPhoneCode?.startsWith("+")?.not() == true) { Log.e(TAG, "initialCountryPhoneCode must start with +") } mutableStateOf( @@ -153,10 +154,11 @@ fun TogiCountryCodePicker( OutlinedTextField( value = phoneNumber, onValueChange = { enteredPhoneNumber -> - val prefilteredPhoneNumber = - phoneNumberTransformation.preFilter(enteredPhoneNumber.text) - phoneNumber = - TextFieldValue(prefilteredPhoneNumber, TextRange(prefilteredPhoneNumber.length)) + val preFilteredPhoneNumber = phoneNumberTransformation.preFilter(enteredPhoneNumber) + phoneNumber = TextFieldValue( + text = preFilteredPhoneNumber, + selection = TextRange(preFilteredPhoneNumber.length), + ) isNumberValid = validatePhoneNumber( fullPhoneNumber = country.countryPhoneCode + phoneNumber.text, ) @@ -168,11 +170,11 @@ fun TogiCountryCodePicker( .autofill( autofillTypes = listOf(AutofillType.PhoneNumberNational), onFill = { filledPhoneNumber -> - val prefilteredPhoneNumber = + val preFilteredPhoneNumber = phoneNumberTransformation.preFilter(filledPhoneNumber) phoneNumber = TextFieldValue( - prefilteredPhoneNumber, - TextRange(prefilteredPhoneNumber.length), + text = preFilteredPhoneNumber, + selection = TextRange(preFilteredPhoneNumber.length), ) isNumberValid = validatePhoneNumber( fullPhoneNumber = country.countryPhoneCode + phoneNumber.text, diff --git a/ccp/src/main/java/com/togitech/ccp/transformation/PhoneNumberTransformation.kt b/ccp/src/main/java/com/togitech/ccp/transformation/PhoneNumberTransformation.kt index b8e1612..cfb655d 100644 --- a/ccp/src/main/java/com/togitech/ccp/transformation/PhoneNumberTransformation.kt +++ b/ccp/src/main/java/com/togitech/ccp/transformation/PhoneNumberTransformation.kt @@ -5,6 +5,7 @@ import android.telephony.PhoneNumberUtils import android.text.Selection import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.input.OffsetMapping +import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.TransformedText import androidx.compose.ui.text.input.VisualTransformation import io.michaelrocks.libphonenumber.android.PhoneNumberUtil @@ -18,6 +19,8 @@ class PhoneNumberTransformation(countryCode: String, context: Context) : VisualT fun preFilter(text: String): String = text.filter { PhoneNumberUtils.isReallyDialable(it) } + fun preFilter(textValue: TextFieldValue) = preFilter(textValue.text) + override fun filter(text: AnnotatedString): TransformedText { val transformation = reformat(text, Selection.getSelectionEnd(text)) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7a6e645..7647655 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ compileSdk = "34" # Dependencies android-gradle-plugin = "8.2.0-beta06" -gradle-versions = "0.48.0" +gradle-versions = "0.49.0" detekt = "1.23.1" accompanist = "0.32.0" @@ -25,7 +25,7 @@ compose = "1.5.3" composeCompiler = "1.5.3" kotlinx-coroutines = "1.7.3" -kotlinx-collections-immutable = "0.3.5" +kotlinx-collections-immutable = "0.3.6" libphonenumber = "8.13.17"