Created
December 13, 2021 18:33
-
-
Save Oleur/6ce1b6b85b70fa97bba8bc9d21013a5e to your computer and use it in GitHub Desktop.
PasswordVisualTransformation from Jetpack Compose
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
class PasswordVisualTransformation(val mask: Char = '\u2022') : VisualTransformation { | |
override fun filter(text: AnnotatedString): TransformedText { | |
return TransformedText( | |
text = AnnotatedString(mask.toString().repeat(text.text.length)), | |
offsetMapping = object : OffsetMapping { | |
override fun originalToTransformed(offset: Int): Int = offset | |
override fun transformedToOriginal(offset: Int): Int = offset | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment