Skip to content

Commit

Permalink
Made header title clickable as well, made updates count in header be …
Browse files Browse the repository at this point in the history
…filtered by search query

(cherry picked from commit 7c1ece2)
  • Loading branch information
lamba92 committed Dec 8, 2023
1 parent c0bc1f6 commit 69469b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ class PackageListBuilder(
}

private fun List<PackageSearchDeclaredPackage>.getUpdatesAvailableAdditionalContent() =
count { it.hasUpdates(onlyStable) }
.takeIf { it > 0 }
?.let { PackageListItem.Header.AdditionalContent.UpdatesAvailableCount(it) }

private fun PackageSearchModuleVariant.getUpdatesAvailableAdditionalContent() =
declaredDependencies.count { it.hasUpdates(onlyStable) }
filter { it.matchesSearchQuery() }
.count { it.hasUpdates(onlyStable) }
.takeIf { it > 0 }
?.let { PackageListItem.Header.AdditionalContent.UpdatesAvailableCount(it) }

Expand Down Expand Up @@ -189,7 +185,7 @@ class PackageListBuilder(
attributes = variant.attributes.map { it.value },
additionalContent = when (id) {
in headerLoadingStates -> PackageListItem.Header.AdditionalContent.Loading
else -> variant.getUpdatesAvailableAdditionalContent()
else -> variant.declaredDependencies.getUpdatesAvailableAdditionalContent()
}
)
if (state == PackageListItem.Header.State.OPEN) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jetbrains.packagesearch.plugin.ui.panels.packages.items

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Arrangement.SpaceBetween
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -54,7 +55,7 @@ fun PackageListHeader(
verticalAlignment = Alignment.CenterVertically,
) {
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Box(
Row(
modifier = Modifier.onClick(enabled = content.state != State.LOADING) {
onEvent(
PackageListItemEvent.SetHeaderState(
Expand All @@ -65,6 +66,8 @@ fun PackageListHeader(
)
)
}
.pointerHoverIcon(PointerIcon(Cursor(Cursor.HAND_CURSOR))),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
when (content.state) {
State.OPEN -> Icon(
Expand All @@ -83,12 +86,13 @@ fun PackageListHeader(

State.LOADING -> CircularProgressIndicator()
}

Text(
fontWeight = FontWeight(600),
text = content.title,
maxLines = 1
)
}
Text(
fontWeight = FontWeight(600),
text = content.title,
maxLines = 1
)
if (content.attributes.isNotEmpty()) {
Box(
modifier = Modifier
Expand Down

0 comments on commit 69469b0

Please sign in to comment.