Skip to content

Commit

Permalink
Fixing rank order. (#244)
Browse files Browse the repository at this point in the history
- Fixes #238
  • Loading branch information
dessalines authored Feb 1, 2025
1 parent a81d2c4 commit ae57e87
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberBasicTooltipState
import androidx.compose.foundation.shape.CircleShape
Expand Down Expand Up @@ -372,19 +372,21 @@ fun FavListDetailPane(
// FavListDetails(favList)
// }

itemsIndexed(
key = { _, item -> item.id },
items(
key = { item -> item.id },
items =
favListItems.orEmpty().filter {
it.name.contains(
searchFilter,
ignoreCase = true,
)
},
) { index, favListItem ->
) { favListItem ->
val rankNum = favListItems.orEmpty().indexOf(favListItem) + 1

FavListItemRow(
favListItem = favListItem,
index = index + 1,
rankNum = rankNum,
onClick = {
onItemDetailsClick(favListItem.id)
},
Expand Down Expand Up @@ -446,12 +448,12 @@ fun FavListDetailsPreview() {
@Composable
fun FavListItemRow(
favListItem: FavListItem,
index: Int,
rankNum: Int,
onClick: () -> Unit,
) {
// Only show the rank if its above the min confidence bound
val rank =
if (calculateConfidence(favListItem.glickoDeviation) >= MIN_CONFIDENCE_BOUND) index.toString() else "?"
if (calculateConfidence(favListItem.glickoDeviation) >= MIN_CONFIDENCE_BOUND) rankNum.toString() else "?"
ListItem(
headlineContent = {
Text(favListItem.name)
Expand All @@ -474,7 +476,7 @@ fun FavListItemRow(
fun FavListItemRowPreview() {
FavListItemRow(
favListItem = sampleFavListItem,
index = 23,
rankNum = 23,
onClick = {},
)
}

0 comments on commit ae57e87

Please # to comment.