Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Dec 5, 2023
1 parent ab7284e commit 329a465
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.jetbrains.packagesearch.plugin.ui.LocalComponentManager
import com.jetbrains.packagesearch.plugin.ui.PackageSearchToolwindow
import com.jetbrains.packagesearch.plugin.ui.bridge.LocalPackageSearchDropdownLinkStyle
import com.jetbrains.packagesearch.plugin.ui.bridge.PackageSearchDropdownLinkStyle
import com.jetbrains.packagesearch.plugin.ui.bridge.PackageSearchGlobalColors
import com.jetbrains.packagesearch.plugin.ui.bridge.PackageSearchTabStyle
import com.jetbrains.packagesearch.plugin.ui.bridge.PackageSearchTreeStyle
Expand All @@ -24,7 +26,8 @@ class PackageSearchToolWindowFactory : ToolWindowFactory, DumbAware {
LocalComponentManager provides project,
LocalGlobalColors provides PackageSearchGlobalColors(),
LocalDefaultTabStyle provides PackageSearchTabStyle(),
LocalLazyTreeStyle provides PackageSearchTreeStyle()
LocalLazyTreeStyle provides PackageSearchTreeStyle(),
LocalPackageSearchDropdownLinkStyle provides PackageSearchDropdownLinkStyle(),
) {
PackageSearchToolwindow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fun LabelInfo(


@Composable
fun TextSelectionDropdown(
fun PackageSearchDropdownLink(
modifier: Modifier,
menuModifier: Modifier,
items: List<String>,
Expand All @@ -79,7 +79,7 @@ fun TextSelectionDropdown(
modifier = modifier,
menuModifier = menuModifier.heightIn(max = PackageSearchMetrics.Dropdown.maxHeight),
enabled = enabled && items.isNotEmpty(),
style = PackageSearchDropdownLinkStyle(),
style = LocalPackageSearchDropdownLinkStyle.current,
menuContent = {
items.forEach {
selectableItem(
Expand All @@ -94,6 +94,7 @@ fun TextSelectionDropdown(
)
}


@Composable
internal fun PackageActionPopup(
isOpen: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.jetbrains.packagesearch.plugin.ui.bridge
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.dp
Expand All @@ -27,7 +29,7 @@ import org.jetbrains.jewel.ui.theme.linkStyle
@Composable
internal fun PackageSearchDropdownLinkStyle(): LinkStyle {
val currentStyle = JewelTheme.linkStyle
val contentColor= LocalContentColor.current
val contentColor = LocalContentColor.current
return LinkStyle(
colors = LinkColors(
content = contentColor,
Expand Down Expand Up @@ -101,4 +103,10 @@ internal fun PackageSearchTreeStyle(): LazyTreeStyle {
),
currentStyle.icons,
)
}
}


internal val LocalPackageSearchDropdownLinkStyle: ProvidableCompositionLocal<LinkStyle> =
staticCompositionLocalOf {
error("No LoLinkStyle provided. Have you forgotten the theme?")
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.jetbrains.packagesearch.plugin.ui.LearnMoreLink
import com.jetbrains.packagesearch.plugin.ui.PackageSearchMetrics
import com.jetbrains.packagesearch.plugin.ui.bridge.LabelInfo
import com.jetbrains.packagesearch.plugin.ui.bridge.PackageActionPopup
import com.jetbrains.packagesearch.plugin.ui.bridge.TextSelectionDropdown
import com.jetbrains.packagesearch.plugin.ui.bridge.PackageSearchDropdownLink
import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListItem
import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListItemEvent
import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListItemEvent.EditPackageEvent.SetPackageScope
Expand Down Expand Up @@ -437,7 +437,7 @@ fun VersionSelectionDropdown(
}
}
}
TextSelectionDropdown(
PackageSearchDropdownLink(
modifier = modifier,
menuModifier = menuModifier,
items = availableVersions,
Expand All @@ -457,7 +457,7 @@ fun ScopeSelectionDropdown(
enabled: Boolean,
onScopeChanged: (String?) -> Unit,
) {
TextSelectionDropdown(
PackageSearchDropdownLink(
modifier = modifier,
menuModifier = menuModifier,
items = buildList {
Expand Down

0 comments on commit 329a465

Please sign in to comment.