mirror of
https://github.com/bitwarden/android.git
synced 2026-04-27 03:18:30 -05:00
Add helper method for applying visual transformations to any string (#342)
This commit is contained in:
committed by
Álison Fernandes
parent
3a42d3e58a
commit
ba62eaf6d0
@@ -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].
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user