Skip to content

Conversation

@aanorbel
Copy link
Member

Closes #345

Comment on lines 56 to 57
itemList.size == 1 -> listOf(itemList.first())
itemList.size > 1 && itemList.size == measurements.size -> itemList
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between these 2 cases? Aren't we just returning the itemList in both?

itemList.size == 1 -> listOf(itemList.first())
itemList.size > 1 && itemList.size == measurements.size -> itemList
else -> {
val key = itemList.first().measurement.test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also get the key from above: .flatMap { (key, itemList) ->


data class State(
val result: ResultItem?,
val groupedMeasurements: List<Any>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sealed interface/class is a safer and more developer-friendly way of having 2 different types in a list. With Any you never know what could be inside.

Comment on lines 148 to 153
var key: Any = item.toString()
when (item) {
is ResultViewModel.MeasurementGroup -> key = item.test.name
is MeasurementWithUrl -> key = item.measurement.idOrThrow.value
}
key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the key variable, just go with:

key = { item ->
    when (item) {
        is ResultViewModel.MeasurementGroup -> item.test.name
        is MeasurementWithUrl -> item.measurement.idOrThrow.value
    }
}

modifier = Modifier.fillMaxWidth().alpha(0.66f).padding(horizontal = 16.dp),
) {
TestName(item.test, item.measurements.first(), modifier = Modifier.weight(1f))
IconButton(onClick = { onDropdownToggled() }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer if the whole row was clickable to expand/collapse.

@sdsantos sdsantos merged commit f88eea6 into main Dec 18, 2024
2 checks passed
@sdsantos sdsantos deleted the issues/345 branch December 18, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Result: Group experimental measurements by type

4 participants