Skip to content

Commit

Permalink
Merge pull request #45 from developer-kaczmarek/feature/phone_mask
Browse files Browse the repository at this point in the history
fixed Phone number mask for TextField
  • Loading branch information
aartikov authored Nov 29, 2021
2 parents 5564281 + 276e62d commit 2e4b45b
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 2e4b45b

Please sign in to comment.