diff --git a/core-designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt b/core-designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt
index c2790c538..d45bdb226 100644
--- a/core-designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt
+++ b/core-designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt
@@ -18,6 +18,7 @@ package com.google.samples.apps.nowinandroid.core.designsystem.component
import androidx.compose.foundation.layout.Box
import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -26,6 +27,8 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import com.google.samples.apps.nowinandroid.core.designsystem.R
@Composable
fun NiaTopicTag(
@@ -36,9 +39,9 @@ fun NiaTopicTag(
modifier: Modifier = Modifier,
enabled: Boolean = true,
text: @Composable () -> Unit,
- followText: @Composable () -> Unit,
- unFollowText: @Composable () -> Unit,
- browseText: @Composable () -> Unit
+ followText: @Composable () -> Unit = { Text(stringResource(R.string.follow)) },
+ unFollowText: @Composable () -> Unit = { Text(stringResource(R.string.unfollow)) },
+ browseText: @Composable () -> Unit = { Text(stringResource(R.string.browse_topic)) }
) {
var expanded by remember { mutableStateOf(false) }
Box(modifier = modifier) {
diff --git a/core-designsystem/src/main/res/values/strings.xml b/core-designsystem/src/main/res/values/strings.xml
new file mode 100644
index 000000000..5d1158888
--- /dev/null
+++ b/core-designsystem/src/main/res/values/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ Follow
+ Unfollow
+ Browse topic
+
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 dcf9ecba2..82cd9537b 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
@@ -17,6 +17,7 @@
package com.google.samples.apps.nowinandroid.core.ui
import androidx.compose.foundation.background
+import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@@ -27,8 +28,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.lazy.LazyRow
-import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
@@ -48,7 +48,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
-import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
@@ -57,10 +56,9 @@ import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
-import androidx.core.os.ConfigurationCompat
import coil.compose.AsyncImage
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaToggleButton
-import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopicChip
+import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopicTag
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.Author
@@ -69,6 +67,7 @@ import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import java.time.ZoneId
import java.time.format.DateTimeFormatter
+import java.util.Locale
import kotlinx.datetime.Instant
import kotlinx.datetime.toJavaInstant
@@ -159,7 +158,7 @@ fun NewsResourceAuthors(
// Only display first author for now
val author = authors[0]
- val authorNameFormatted = uppercaseFormat(author.name)
+ val authorNameFormatted = author.name.uppercase(Locale.getDefault())
val authorImageUrl = author.imageUrl
@@ -269,34 +268,22 @@ fun NewsResourceTopics(
topics: List,
modifier: Modifier = Modifier
) {
- LazyRow(
- modifier = modifier,
- horizontalArrangement = Arrangement.spacedBy(4.dp)
+ Row(
+ modifier = modifier.horizontalScroll(rememberScrollState()), // causes narrow chips
+ horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
- items(items = topics, key = { item -> item.id }) { topic ->
- NiaTopicChip(
- enabled = true, // ToDo: Chip should be disabled if user is not following
- onClick = { }, // ToDo: Handle topic chip interaction
- ) {
- Text(uppercaseFormat(topic.name))
- }
+ for (topic in topics) {
+ NiaTopicTag(
+ followed = true, // Todo
+ onFollowClick = { }, // Todo
+ onUnfollowClick = { }, // Todo
+ onBrowseClick = { }, // Todo
+ text = { Text(text = topic.name.uppercase(Locale.getDefault())) }
+ )
}
}
}
-@Composable
-private fun uppercaseFormat(string: String): String {
- val locale = ConfigurationCompat.getLocales(LocalConfiguration.current).get(0)
-
- val uppercaseFormatted = if (locale != null) {
- string.uppercase(locale)
- } else {
- string.uppercase()
- }
-
- return uppercaseFormatted
-}
-
@Preview("Bookmark Button")
@Composable
fun BookmarkButtonPreview() {