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 {
FlowRow(mainAxisSpacing = 16.dp) {
var expandedTopic by remember { mutableStateOf<String?>(null) }
var expandedTopicId by remember { mutableStateOf<String?>(null) }
var firstFollowed by remember { mutableStateOf(false) }
NiaTopicTag(
expanded = expandedTopic == "Topic 1",
expanded = expandedTopicId == "Topic 1",
followed = firstFollowed,
onDropMenuToggle = { show ->
expandedTopic = if (show) "Topic 1" else null
expandedTopicId = if (show) "Topic 1" else null
},
onFollowClick = { firstFollowed = true },
onUnfollowClick = { firstFollowed = false },
@ -537,10 +537,10 @@ fun NiaCatalog() {
)
var secondFollowed by remember { mutableStateOf(true) }
NiaTopicTag(
expanded = expandedTopic == "Topic 2",
expanded = expandedTopicId == "Topic 2",
followed = secondFollowed,
onDropMenuToggle = { show ->
expandedTopic = if (show) "Topic 2" else null
expandedTopicId = if (show) "Topic 2" else null
},
onFollowClick = { secondFollowed = true },
onUnfollowClick = { secondFollowed = false },

@ -21,10 +21,6 @@ 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
import androidx.compose.runtime.mutableStateOf
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

@ -268,7 +268,9 @@ fun NewsResourceTopics(
topics: List<Topic>,
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(
modifier = modifier.horizontalScroll(rememberScrollState()), // causes narrow chips
@ -276,10 +278,10 @@ fun NewsResourceTopics(
) {
for (topic in topics) {
NiaTopicTag(
expanded = expandedTopic == topic.id,
expanded = expandedTopicId == topic.id,
followed = true, // ToDo: Check if topic is followed
onDropMenuToggle = { show ->
expandedTopic = if (show) topic.id else null
expandedTopicId = if (show) topic.id else null
},
onFollowClick = { }, // ToDo
onUnfollowClick = { }, // ToDo

Loading…
Cancel
Save