From e44811f2652bef9c8763d464e6a3aebce876a6c3 Mon Sep 17 00:00:00 2001 From: Saeed Noshadi Date: Mon, 14 Nov 2022 15:35:13 +0330 Subject: [PATCH] show all authors in the news card --- .../apps/nowinandroid/core/ui/NewsResourceCard.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt index 36e5ff60a..f260353d8 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt @@ -16,6 +16,7 @@ package com.google.samples.apps.nowinandroid.core.ui +import android.util.Log import androidx.compose.foundation.background import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement @@ -156,12 +157,17 @@ fun NewsResourceAuthors( authors: List ) { if (authors.isNotEmpty()) { - // Only display first author for now - val author = authors[0] + // display all authors + val authorName = StringBuilder() + authors.forEachIndexed { index, author -> + authorName + .append(author.name) + .append(if (index == authors.lastIndex) "" else ", ") + } - val authorNameFormatted = author.name.uppercase(Locale.getDefault()) + val authorNameFormatted = "$authorName".uppercase(Locale.getDefault()) - val authorImageUrl = author.imageUrl + val authorImageUrl = authors[0].imageUrl val authorImageModifier = Modifier .clip(CircleShape)