Skip to content

Commit e44811f

Browse files
show all authors in the news card
1 parent e72e31b commit e44811f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.samples.apps.nowinandroid.core.ui
1818

19+
import android.util.Log
1920
import androidx.compose.foundation.background
2021
import androidx.compose.foundation.horizontalScroll
2122
import androidx.compose.foundation.layout.Arrangement
@@ -156,12 +157,17 @@ fun NewsResourceAuthors(
156157
authors: List<Author>
157158
) {
158159
if (authors.isNotEmpty()) {
159-
// Only display first author for now
160-
val author = authors[0]
160+
// display all authors
161+
val authorName = StringBuilder()
162+
authors.forEachIndexed { index, author ->
163+
authorName
164+
.append(author.name)
165+
.append(if (index == authors.lastIndex) "" else ", ")
166+
}
161167

162-
val authorNameFormatted = author.name.uppercase(Locale.getDefault())
168+
val authorNameFormatted = "$authorName".uppercase(Locale.getDefault())
163169

164-
val authorImageUrl = author.imageUrl
170+
val authorImageUrl = authors[0].imageUrl
165171

166172
val authorImageModifier = Modifier
167173
.clip(CircleShape)

0 commit comments

Comments
 (0)