rename variable and fix spotless errors

pull/246/head
Robert 2 years ago
parent 4219ec11c4
commit 36c369d8dd

@ -518,14 +518,14 @@ fun NiaCatalog() {
item { Text("Tags", Modifier.padding(top = 16.dp)) } item { Text("Tags", Modifier.padding(top = 16.dp)) }
item { item {
FlowRow(mainAxisSpacing = 16.dp) { FlowRow(mainAxisSpacing = 16.dp) {
var expandedTopic by remember { mutableStateOf<String?>(null) } var expandedTopicId by remember { mutableStateOf<String?>(null) }
var firstFollowed by remember { mutableStateOf(false) } var firstFollowed by remember { mutableStateOf(false) }
NiaTopicTag( NiaTopicTag(
expanded = expandedTopic == "Topic 1", expanded = expandedTopicId == "Topic 1",
followed = firstFollowed, followed = firstFollowed,
onDropMenuToggle = { show -> onDropMenuToggle = { show ->
expandedTopic = if (show) "Topic 1" else null expandedTopicId = if (show) "Topic 1" else null
}, },
onFollowClick = { firstFollowed = true }, onFollowClick = { firstFollowed = true },
onUnfollowClick = { firstFollowed = false }, onUnfollowClick = { firstFollowed = false },
@ -537,10 +537,10 @@ fun NiaCatalog() {
) )
var secondFollowed by remember { mutableStateOf(true) } var secondFollowed by remember { mutableStateOf(true) }
NiaTopicTag( NiaTopicTag(
expanded = expandedTopic == "Topic 2", expanded = expandedTopicId == "Topic 2",
followed = secondFollowed, followed = secondFollowed,
onDropMenuToggle = { show -> onDropMenuToggle = { show ->
expandedTopic = if (show) "Topic 2" else null expandedTopicId = if (show) "Topic 2" else null
}, },
onFollowClick = { secondFollowed = true }, onFollowClick = { secondFollowed = true },
onUnfollowClick = { secondFollowed = false }, onUnfollowClick = { secondFollowed = false },

@ -21,10 +21,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.contentColorFor import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
@ -32,9 +28,9 @@ import com.google.samples.apps.nowinandroid.core.designsystem.R
@Composable @Composable
fun NiaTopicTag( fun NiaTopicTag(
expanded : Boolean = false, expanded: Boolean = false,
followed: Boolean, followed: Boolean,
onDropMenuToggle : (show: Boolean) -> Unit = {}, onDropMenuToggle: (show: Boolean) -> Unit = {},
onFollowClick: () -> Unit, onFollowClick: () -> Unit,
onUnfollowClick: () -> Unit, onUnfollowClick: () -> Unit,
onBrowseClick: () -> Unit, onBrowseClick: () -> Unit,

@ -268,7 +268,9 @@ fun NewsResourceTopics(
topics: List<Topic>, topics: List<Topic>,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
var expandedTopic by remember { mutableStateOf<String?>(null) } // Store the ID of the Topic which has its "following" menu expanded, if any.
// To avoid UI confusion, only one topic can have an expanded menu at a time.
var expandedTopicId by remember { mutableStateOf<String?>(null) }
Row( Row(
modifier = modifier.horizontalScroll(rememberScrollState()), // causes narrow chips modifier = modifier.horizontalScroll(rememberScrollState()), // causes narrow chips
@ -276,10 +278,10 @@ fun NewsResourceTopics(
) { ) {
for (topic in topics) { for (topic in topics) {
NiaTopicTag( NiaTopicTag(
expanded = expandedTopic == topic.id, expanded = expandedTopicId == topic.id,
followed = true, // ToDo: Check if topic is followed followed = true, // ToDo: Check if topic is followed
onDropMenuToggle = { show -> onDropMenuToggle = { show ->
expandedTopic = if (show) topic.id else null expandedTopicId = if (show) topic.id else null
}, },
onFollowClick = { }, // ToDo onFollowClick = { }, // ToDo
onUnfollowClick = { }, // ToDo onUnfollowClick = { }, // ToDo

Loading…
Cancel
Save