Skip to content

Commit

Permalink
feat: Don't parse background-color
Browse files Browse the repository at this point in the history
Sometime background-color make content unreadable
  • Loading branch information
kongwoojin committed May 3, 2024
1 parent 12ef51d commit db27cfa
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/src/main/java/com/kongjak/koreatechboard/util/CssParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,21 @@ fun parseSpanStyle(css: String?, isDarkMode: Boolean): SpanStyle {
key.trim() to value.trim()
}.toMap()

val hasBackgroundColor = cssMap.containsKey("background-color")

var color = Color.Unspecified
var backgroundColor = Color.Unspecified
var fontWeight: FontWeight? = null
var textDecoration = TextDecoration.None

for ((key, value) in cssMap) {
when (key) {
"color" -> {
color = parseColor(value, isDarkMode)
}

"background-color" -> {
backgroundColor = parseColor(value, isDarkMode)
/*
* If the background color is set, don't parse color.
*/
if (!hasBackgroundColor) {
color = parseColor(value, isDarkMode)
}
}

"font-weight" -> {
Expand All @@ -105,7 +107,6 @@ fun parseSpanStyle(css: String?, isDarkMode: Boolean): SpanStyle {

return SpanStyle(
color = color,
background = backgroundColor,
fontWeight = fontWeight,
textDecoration = textDecoration
)
Expand Down

0 comments on commit db27cfa

Please sign in to comment.