Created
December 13, 2021 18:43
-
-
Save Oleur/6993cd1c093613eb1782bd04e8ae5352 to your computer and use it in GitHub Desktop.
Credit Card transformation offset mapping from Compose documentation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Making XXXX-XXXX-XXXX-XXXX string. | |
val creditCardOffsetMapping = object : OffsetMapping { | |
override fun originalToTransformed(offset: Int): Int { | |
if (offset <= 3) return offset | |
if (offset <= 7) return offset + 1 | |
if (offset <= 11) return offset + 2 | |
if (offset <= 16) return offset + 3 | |
return 19 | |
} | |
override fun transformedToOriginal(offset: Int): Int { | |
if (offset <= 4) return offset | |
if (offset <= 9) return offset - 1 | |
if (offset <= 14) return offset - 2 | |
if (offset <= 19) return offset - 3 | |
return 16 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment