Skip to content

Commit

Permalink
Version updates and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hbmartin committed Oct 9, 2023
1 parent 2eb44bb commit fa62adf
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

7 changes: 2 additions & 5 deletions ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -217,7 +216,6 @@ private fun SearchTextField(

BasicTextField(
modifier = modifier
.height(MIN_TAP_DIMENSION)
.fillMaxWidth()
.focusRequester(requester),
value = value,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand All @@ -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,
)
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down

0 comments on commit fa62adf

Please sign in to comment.