mirror of
https://github.com/bitwarden/android.git
synced 2025-02-17 04:19:54 +03:00
Add helper method for applying visual transformations to any string (#342)
This commit is contained in:
parent
3a42d3e58a
commit
ba62eaf6d0
1 changed files with 14 additions and 0 deletions
|
@ -1,9 +1,11 @@
|
|||
package com.x8bit.bitwarden.ui.platform.base.util
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.core.graphics.toColorInt
|
||||
import java.net.URI
|
||||
import java.util.Locale
|
||||
|
@ -65,6 +67,18 @@ fun String.lowercaseWithCurrentLocal(): String {
|
|||
return lowercase(LocalContext.current.resources.configuration.locales[0])
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper method to apply the [visualTransformation] to the given string and and returns the
|
||||
* transformed [AnnotatedString].
|
||||
*/
|
||||
@Composable
|
||||
fun String.withVisualTransformation(
|
||||
visualTransformation: VisualTransformation,
|
||||
): AnnotatedString =
|
||||
remember(key1 = this) {
|
||||
visualTransformation.filter(toAnnotatedString()).text
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [String] as an [AnnotatedString].
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue