xxfast
02/14/2024, 4:07 AM+-
or .plusOrMinus
operator that does
val fruits = listOf("π", "π", "π")
print(fruits Β± "π₯") // "π", "π", "π", "π₯"
print(fruits Β± "π") // "π", "π"
which works like
operator fun <T> Collection<T>.plusOrMinus(item: T): Collection<T> =
if (item in this) this + item
else this - item
ephemient
02/14/2024, 4:12 AMxor
if we ever got bitwise operatorsxxfast
02/14/2024, 4:12 AM@Composable
fun ListScreen(items: List<Item>) {
var collapsed: Set<Category> by rememberSaveable { mutableStateOf(emptySet()) }
val groups = items.groupBy { item.category }
LazyColumn {
Category.entries.forEach { category ->
item(span = FullLine) {
CollapsableHeader(
isCollapsed = category in collapsed,
onClick = { collapsed = (collapsed Β± category).toSet() }
) {
Text(category.text)
}
}
if(category !in groups) items(groups[category].entries) { item ->
ItemView(item)
}
}
}
}
ephemient
02/14/2024, 4:16 AMinfix fun <T> Iterable<T>.xor(item: T): List<T> = toMutableList().apply { remove(item) || add(item) }
xxfast
02/14/2024, 4:17 AMephemient
02/14/2024, 4:18 AMephemient
02/14/2024, 4:19 AMAlejandro Serrano.Mena
02/14/2024, 9:39 AM