Skip to content

Commit

Permalink
Fix extra newline added by fromHtml
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Oct 6, 2023
1 parent f8aca6d commit 6380eaa
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ fun InfoDialog(message: String, additionalInfo: String? = null, onDismiss: () ->
Spacer(modifier = Modifier.height(Dimens.verticalSpace))
val htmlFormattedString =
HtmlCompat.fromHtml(additionalInfo, HtmlCompat.FROM_HTML_MODE_COMPACT)
val annotated = htmlFormattedString.toAnnotatedString()
// fromHtml may add a trailing newline when using HTML tags, so we remove it
val trimmed = annotated.substring(0, annotated.trimEnd().length)
Text(
text = htmlFormattedString.toAnnotatedString(),
text = trimmed,
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.fillMaxWidth()
Expand Down

0 comments on commit 6380eaa

Please sign in to comment.