summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2023-04-11 07:53:28 +0200
committerAlbin <albin@mullvad.net>2023-04-11 11:11:58 +0200
commit256311c5195d9c8698a30d16baf0b1be9f268e4c (patch)
tree30c665938807445f355f82a077fc96c814789363 /android/app/src
parentcdc127afd24e39ae87648d6e023b00b6da5ae788 (diff)
downloadmullvadvpn-256311c5195d9c8698a30d16baf0b1be9f268e4c.tar.xz
mullvadvpn-256311c5195d9c8698a30d16baf0b1be9f268e4c.zip
Support setting color of html text
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/HtmlText.kt14
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)