From 11df0d0ac6f494938450b13b4df20288b065f518 Mon Sep 17 00:00:00 2001 From: jocmp <9521010+jocmp@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:36:54 -0500 Subject: [PATCH] Small tweaks and bugfixes (#162) * Attempt to fix layout crash with placeholders Default "placeholders" to true for the article pager in an attempt to avoid the IllegalStateException "Error: Placement happened before lookahead." Placeholders in the DB are different from placeholders in the UI, but the error also only happens during scroll. * Tweak font styles on article cards --- .../capyreader/app/ui/articles/ArticleRow.kt | 23 +++++++++++++++---- .../app/ui/articles/ArticleScreenViewModel.kt | 4 ++-- ...ager.kt => AccountBuildArticlePagerExt.kt} | 3 +-- 3 files changed, 22 insertions(+), 8 deletions(-) rename capy/src/main/java/com/jocmp/capy/{AccountPager.kt => AccountBuildArticlePagerExt.kt} (88%) diff --git a/app/src/main/java/com/capyreader/app/ui/articles/ArticleRow.kt b/app/src/main/java/com/capyreader/app/ui/articles/ArticleRow.kt index 9e5904e9..877cb188 100644 --- a/app/src/main/java/com/capyreader/app/ui/articles/ArticleRow.kt +++ b/app/src/main/java/com/capyreader/app/ui/articles/ArticleRow.kt @@ -13,6 +13,7 @@ import androidx.compose.material3.ListItemColors import androidx.compose.material3.ListItemDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme.colorScheme +import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable @@ -24,6 +25,10 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter @@ -83,6 +88,7 @@ fun ArticleRow( headlineContent = { Text( article.title, + fontWeight = titleFontWeight(read = article.read), ) }, supportingContent = { @@ -104,6 +110,8 @@ fun ArticleRow( time = article.publishedAt, currentTime = currentTime, ), + style = typography.labelSmall, + modifier = Modifier.padding(vertical = 4.dp), maxLines = 1, ) } @@ -153,6 +161,14 @@ fun PlaceholderArticleRow() { ) } +@Composable +fun titleFontWeight(read: Boolean): FontWeight { + return if (read) { + FontWeight.Normal + } else { + FontWeight.Bold + } +} @Composable @Stable @@ -173,12 +189,11 @@ private fun listItemColors( @Composable fun findFeedNameColor(read: Boolean): Color { val defaults = ListItemDefaults.colors() - val colorScheme = MaterialTheme.colorScheme return if (read) { defaults.disabledHeadlineColor } else { - colorScheme.onSurface + Color.Unspecified } } @@ -195,7 +210,7 @@ fun ArticleRowPreview_Selected_DarkMode() { contentHTML = "