diff --git a/compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/form/RussianPhoneNumberFormatter.kt b/compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/form/RussianPhoneNumberFormatter.kt index 68e4eac1..4cd01d99 100644 --- a/compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/form/RussianPhoneNumberFormatter.kt +++ b/compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/form/RussianPhoneNumberFormatter.kt @@ -25,21 +25,20 @@ object RussianPhoneNumberVisualTransformation : VisualTransformation { val numberOffsetTranslator = object : OffsetMapping { override fun originalToTransformed(offset: Int): Int { - if (offset == 0) return offset + if (offset <= 0) return offset if (offset <= 2) return offset + 4 if (offset <= 5) return offset + 6 if (offset <= 7) return offset + 7 - if (offset <= 10) return offset + 8 - return 14 + if (offset <= 9) return offset + 8 + return 18 } override fun transformedToOriginal(offset: Int): Int { - if (offset == 0) return offset - if (offset <= 2) return offset - 4 - if (offset <= 5) return offset - 6 - if (offset <= 7) return offset - 7 - if (offset <= 10) return offset - 8 - return offset + if (offset <= 4) return offset + if (offset <= 7) return offset - 4 + if (offset <= 11) return offset - 6 + if (offset <= 15) return offset - 7 + return 10 } }