Skip to content

Commit

Permalink
fixed Phone number mask for TextField
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelina Podbolotova committed Nov 28, 2021
1 parent 7af1d0b commit 276e62d
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 276e62d

Please sign in to comment.