Display resource type for each news resource

Change-Id: Ib33ffd0e9b87ec91d2ee4316a4e3dbf70bb5cfc9
pull/476/head
Caren 2 years ago
parent 7dec90ba30
commit f150516b3c

@ -57,6 +57,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopic
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import java.time.ZoneId
@ -109,7 +110,7 @@ fun NewsResourceCardExpanded(
BookmarkButton(isBookmarked, onToggleBookmark)
}
Spacer(modifier = Modifier.height(12.dp))
NewsResourceDate(newsResource.publishDate)
NewsResourceDateAndNewsType(newsResource.publishDate, newsResource.type)
Spacer(modifier = Modifier.height(12.dp))
NewsResourceShortDescription(newsResource.content)
Spacer(modifier = Modifier.height(12.dp))
@ -195,10 +196,22 @@ private fun dateFormatted(publishDate: Instant): String {
}
@Composable
fun NewsResourceDate(
publishDate: Instant
fun NewsResourceDateAndNewsType(
publishDate: Instant,
resourceType: NewsResourceType
) {
Text(dateFormatted(publishDate), style = MaterialTheme.typography.labelSmall)
val date = dateFormatted(publishDate)
if (resourceType != NewsResourceType.Unknown) {
Text(
"$date${resourceType.displayText}", style = MaterialTheme.typography.labelSmall
)
} else {
Text(
date, style = MaterialTheme.typography.labelSmall
)
}
}
@Composable

Loading…
Cancel
Save