Skip to content

Commit

Permalink
Added leading zero to seconds formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
spacecowboy committed Nov 29, 2023
1 parent de62e7d commit 12bd7cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,11 @@ fun RowScope.FeedItemText(
}
if (readTimeSecs > 0) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
val seconds = "%02d".format(readTimeSecs % 60)
val readTimeText =
pluralStringResource(id = R.plurals.n_minutes, count = readTimeSecs / 60)
.format(
"${readTimeSecs / 60}:${readTimeSecs % 60}",
"${readTimeSecs / 60}:$seconds",
)
val wordCountText =
pluralStringResource(id = R.plurals.n_words, count = item.wordCount)
Expand Down Expand Up @@ -344,6 +345,7 @@ fun RowScope.FeedItemText(

@Composable
@ThemePreviews
@Suppress("ktlint:standard:max-line-length")
private fun Preview() {
FeederTheme {
FeedItemCard(
Expand Down Expand Up @@ -380,6 +382,7 @@ private fun Preview() {

@Composable
@ThemePreviews
@Suppress("ktlint:standard:max-line-length")
private fun PreviewWithImageUnread() {
FeederTheme {
Box(
Expand Down Expand Up @@ -420,6 +423,7 @@ private fun PreviewWithImageUnread() {

@Composable
@ThemePreviews
@Suppress("ktlint:standard:max-line-length")
private fun PreviewWithImageRead() {
FeederTheme {
Box(
Expand All @@ -440,7 +444,7 @@ private fun PreviewWithImageRead() {
feedImageUrl = null,
primarySortTime = Instant.EPOCH,
rawPubDate = null,
wordCount = 950,
wordCount = 910,
),
showThumbnail = true,
onMarkAboveAsRead = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,11 @@ fun ReaderView(
imageVector = Icons.Outlined.Timelapse,
contentDescription = null,
)
val seconds = "%02d".format(readTimeSecs % 60)
val readTimeText =
pluralStringResource(id = R.plurals.n_minutes, count = readTimeSecs / 60)
.format(
"${readTimeSecs / 60}:${readTimeSecs % 60}",
"${readTimeSecs / 60}:$seconds",
)
WithBidiDeterminedLayoutDirection(paragraph = readTimeText) {
val interactionSource =
Expand Down Expand Up @@ -331,7 +332,7 @@ private fun ReaderPreview() {
Surface {
ReaderView(
screenType = ScreenType.SINGLE,
wordCount = 9831,
wordCount = 9700,
onEnclosureClick = {},
onFeedTitleClick = {},
) {}
Expand Down

0 comments on commit 12bd7cc

Please sign in to comment.