@OptIn(ExperimentalComposeUiApi::class) @Composable fun PocketStory( @PreviewParameter(PocketStoryProvider::class) story: PocketRecommendedStory, backgroundColor: Color, onStoryClick: (PocketRecommendedStory) -> Unit, ) { val imageUrl = story.imageUrl.replace( "{wh}", with(LocalDensity.current) { "${116.dp.toPx().roundToInt()}x${84.dp.toPx().roundToInt()}" }, ) val isValidPublisher = story.publisher.isNotBlank() val isValidTimeToRead = story.timeToRead >= 0 ListItemTabLarge( imageUrl = imageUrl, backgroundColor = backgroundColor, onClick = { onStoryClick(story) }, title = { Text( text = story.title, modifier = Modifier.semantics { testTagsAsResourceId = true testTag = "pocket.story.title" }, color = FirefoxTheme.colors.textPrimary, overflow = TextOverflow.Ellipsis, maxLines = 2, style = FirefoxTheme.typography.body2, ) }, subtitle = { if (isValidPublisher && isValidTimeToRead) { TabSubtitleWithInterdot(story.publisher, "${story.timeToRead} min") } else if (isValidPublisher) { Text( text = story.publisher, modifier = Modifier.semantics { testTagsAsResourceId = true testTag = "pocket.story.publisher" }, color = FirefoxTheme.colors.textSecondary, overflow = TextOverflow.Ellipsis, maxLines = 1, style = FirefoxTheme.typography.caption, ) } else if (isValidTimeToRead) { Text( text = "${story.timeToRead} min", modifier = Modifier.semantics { testTagsAsResourceId = true testTag = "pocket.story.timeToRead" }, color = FirefoxTheme.colors.textSecondary, overflow = TextOverflow.Ellipsis, maxLines = 1, style = FirefoxTheme.typography.caption, ) } }, ) }
Displays a single [PocketRecommendedStory].