Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified casa-showcase.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -51,14 +52,27 @@ internal fun CatalogScreen(
var searchTerm by remember(searchState) {
mutableStateOf("")
}
val categories = catalogSamples.groupBy { it.path }
val categories = remember(catalogSamples) {
catalogSamples.groupBy { it.path }
}
val tags = remember(catalogSamples) {
catalogSamples.flatMap { it.tags }.distinct()
}
val filters by remember {
derivedStateOf {
(categories.keys + tags).sorted()
}
}
val selectedFilters = remember { mutableStateListOf<String>() }
val displayedSamples = catalogSamples.filter {
val displayedSamples = catalogSamples.filter { sample ->
if (searchTerm.isBlank()) {
selectedFilters.isEmpty() || selectedFilters.contains(it.path)
selectedFilters.isEmpty() ||
selectedFilters.contains(sample.path) ||
sample.tags.any { selectedFilters.contains(it) }
} else {
it.name.contains(searchTerm, ignoreCase = true) ||
it.description.contains(searchTerm, ignoreCase = true)
sample.name.contains(searchTerm, ignoreCase = true) ||
sample.description.contains(searchTerm, ignoreCase = true) ||
sample.tags.any { it.equals(searchTerm, ignoreCase = true) }
}
}.sortedBy {
it.name
Expand Down Expand Up @@ -92,7 +106,7 @@ internal fun CatalogScreen(
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
item {
FilterTabRow(categories.keys.sorted(), selectedFilters) {
FilterTabRow(filters, selectedFilters) {
if (selectedFilters.contains(it)) {
selectedFilters.remove(it)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowForward
import androidx.compose.material.icons.rounded.KeyboardArrowRight
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
Expand Down Expand Up @@ -60,7 +60,7 @@ internal fun CardItem(
verticalAlignment = Alignment.CenterVertically
) {
Text(text = label, style = MaterialTheme.typography.labelLarge)
Icon(Icons.Rounded.ArrowForward, "Forward")
Icon(Icons.Rounded.KeyboardArrowRight, "Forward")
}
Text(
modifier = Modifier
Expand Down