Skip to content

Commit

Permalink
Hide title in list and reader when blank (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
jocmp authored Feb 4, 2025
1 parent 2cca1ce commit d6a4913
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/com/capyreader/app/ui/articles/ArticleRow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ fun ArticleRow(
) {
ArticleListItem(
headlineContent = {
Text(
article.title,
fontWeight = FontWeight.Bold,
)
if (article.title.isNotBlank()) {
Text(
article.title,
fontWeight = FontWeight.Bold,
)
}
},
overlineContent = {
Row(
Expand Down
16 changes: 14 additions & 2 deletions capy/src/main/java/com/jocmp/capy/articles/ArticleRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ArticleRenderer(

val substitutions = colors + mapOf(
"external_link" to article.externalLink(),
"title" to article.title,
"title" to title(article.title),
"byline" to byline,
"feed_name" to article.feedName,
"font_size" to "${textSize.get()}px",
Expand Down Expand Up @@ -71,11 +71,23 @@ class ArticleRenderer(
}
}

private fun title(articleTitle: String): String {
return if (articleTitle.isBlank()) {
""
} else {
"""
<div class="article__title">
<h1>${articleTitle}</h1>
</div>
""".trimIndent()
}
}

private fun fontPreload(fontFamily: FontOption): String {
return when (fontFamily) {
FontOption.SYSTEM_DEFAULT -> ""
else -> """
<link rel="preload" href="https://appassets.androidplatform.net/res/font/${fontFamily.slug}.ttf" as="font" type="font/ttf" crossorigin>
<link rel="preload" href="https://appassets.androidplatform.net/res/font/${fontFamily.slug}.ttf" as="font" type="font/ttf" crossorigin>
""".trimIndent()
}
}
Expand Down
4 changes: 1 addition & 3 deletions capy/src/main/res/raw/template.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d6a4913

Please sign in to comment.