Skip to content

Commit

Permalink
Fix selection background appearance in PackageSearchpackageList
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi authored and lamba92 committed Jan 26, 2024
1 parent 33a5cb7 commit fcc0701
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ object PackageSearchMetrics {
val header = PaddingValues(bottom = 1.dp)

object Package {
@Composable
fun paddingFor(isFirstItem: Boolean, isLastItem: Boolean): PaddingValues {
val top = if (isFirstItem) 4.dp else 0.dp
val bottom = if (isLastItem) 4.dp else 0.dp
return PaddingValues(top = top, bottom = bottom)
val end = scrollbarWidth
return PaddingValues(top = top, bottom = bottom, end = end)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ fun PackageSearchPackageList(
when (item) {
is PackageListItem.Header -> stickyHeader(key = item.id, contentType = "header") {
PackageListHeader(
additionalContentModifier = Modifier.padding(end = PackageSearchMetrics.scrollbarWidth),
additionalContentModifier = Modifier,
content = item,
onEvent = onPackageEvent
)
}

is PackageListItem.Package -> item(key = item.id, contentType = item.contentType()) {
PackageListItem(
modifier = Modifier.padding(end = PackageSearchMetrics.scrollbarWidth),
modifier = Modifier,
content = item,
packagesList = packagesList,
index = index,
Expand Down Expand Up @@ -127,6 +127,13 @@ internal fun SelectableLazyItemScope.PackageListItem(
)
Box(
modifier = modifier
.background(
when {
isSelected && isActive -> LocalLazyTreeStyle.current.colors.elementBackgroundSelectedFocused
isSelected && !isActive -> LocalLazyTreeStyle.current.colors.elementBackgroundSelected
else -> Color.Transparent
},
)
.padding(itemPaddings)
.onClick(
interactionSource = remember { MutableInteractionSource() },
Expand All @@ -143,13 +150,7 @@ internal fun SelectableLazyItemScope.PackageListItem(
modifier = Modifier
.fillMaxWidth()
.height(PackageSearchMetrics.PackageList.Item.height)
.background(
when {
isSelected && isActive -> LocalLazyTreeStyle.current.colors.elementBackgroundSelectedFocused
isSelected && !isActive -> LocalLazyTreeStyle.current.colors.elementBackgroundSelected
else -> Color.Transparent
},
).padding(start = PackageSearchMetrics.PackageList.Item.padding),
.padding(start = PackageSearchMetrics.PackageList.Item.padding),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Expand Down

0 comments on commit fcc0701

Please sign in to comment.