diff options
| author | Albin <albin@mullvad.net> | 2023-04-11 07:53:28 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-04-11 11:11:58 +0200 |
| commit | 256311c5195d9c8698a30d16baf0b1be9f268e4c (patch) | |
| tree | 30c665938807445f355f82a077fc96c814789363 /android | |
| parent | cdc127afd24e39ae87648d6e023b00b6da5ae788 (diff) | |
| download | mullvadvpn-256311c5195d9c8698a30d16baf0b1be9f268e4c.tar.xz mullvadvpn-256311c5195d9c8698a30d16baf0b1be9f268e4c.zip | |
Support setting color of html text
Diffstat (limited to 'android')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/HtmlText.kt | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/HtmlText.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/HtmlText.kt index b22390cfa8..2042c04278 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/HtmlText.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/HtmlText.kt @@ -4,15 +4,25 @@ import android.util.TypedValue import android.widget.TextView import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.viewinterop.AndroidView import androidx.core.text.HtmlCompat @Composable -fun HtmlText(htmlFormattedString: String, textSize: Float, modifier: Modifier = Modifier) { +fun HtmlText( + htmlFormattedString: String, + textSize: Float, + modifier: Modifier = Modifier, + textColor: Int = Color.White.toArgb(), +) { AndroidView( modifier = modifier, factory = { context -> - TextView(context).apply { setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize) } + TextView(context).apply { + setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize) + setTextColor(textColor) + } }, update = { it.text = HtmlCompat.fromHtml(htmlFormattedString, HtmlCompat.FROM_HTML_MODE_COMPACT) |
