-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Group experimental measurements by type #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| itemList.size == 1 -> listOf(itemList.first()) | ||
| itemList.size > 1 && itemList.size == measurements.size -> itemList |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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.
| var key: Any = item.toString() | ||
| when (item) { | ||
| is ResultViewModel.MeasurementGroup -> key = item.test.name | ||
| is MeasurementWithUrl -> key = item.measurement.idOrThrow.value | ||
| } | ||
| key |
There was a problem hiding this comment.
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() }) { |
There was a problem hiding this comment.
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.
Closes #345