-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Dropdown API to DropdownLink, fixes various cosmetics issues …
…like spacing and color (#4) Created PackageSearchDropdownLink with a specific Style, injected top level (cherry picked from commit 3adb17e)
- Loading branch information
Showing
6 changed files
with
136 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/bridge/CustomStyles.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
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 | ||
import com.jetbrains.packagesearch.plugin.ui.PackageSearchMetrics | ||
import org.jetbrains.jewel.foundation.GlobalColors | ||
import org.jetbrains.jewel.foundation.LocalGlobalColors | ||
import org.jetbrains.jewel.foundation.OutlineColors | ||
import org.jetbrains.jewel.foundation.theme.JewelTheme | ||
import org.jetbrains.jewel.foundation.theme.LocalContentColor | ||
import org.jetbrains.jewel.ui.component.styling.LazyTreeMetrics | ||
import org.jetbrains.jewel.ui.component.styling.LazyTreeStyle | ||
import org.jetbrains.jewel.ui.component.styling.LinkColors | ||
import org.jetbrains.jewel.ui.component.styling.LinkStyle | ||
import org.jetbrains.jewel.ui.component.styling.LocalDefaultTabStyle | ||
import org.jetbrains.jewel.ui.component.styling.LocalLazyTreeStyle | ||
import org.jetbrains.jewel.ui.component.styling.TabMetrics | ||
import org.jetbrains.jewel.ui.component.styling.TabStyle | ||
import org.jetbrains.jewel.ui.theme.linkStyle | ||
|
||
|
||
@Composable | ||
internal fun PackageSearchDropdownLinkStyle(): LinkStyle { | ||
val currentStyle = JewelTheme.linkStyle | ||
val contentColor = LocalContentColor.current | ||
return LinkStyle( | ||
colors = LinkColors( | ||
content = contentColor, | ||
contentDisabled = currentStyle.colors.contentDisabled, | ||
contentHovered = contentColor, | ||
contentPressed = contentColor, | ||
contentFocused = contentColor, | ||
contentVisited = contentColor, | ||
), | ||
metrics = currentStyle.metrics, | ||
icons = currentStyle.icons, | ||
textStyles = currentStyle.textStyles, | ||
) | ||
} | ||
|
||
|
||
@Composable | ||
internal fun PackageSearchTabStyle(): TabStyle { | ||
val current = LocalDefaultTabStyle.current | ||
return TabStyle( | ||
colors = current.colors, | ||
metrics = TabMetrics( | ||
underlineThickness = current.metrics.underlineThickness, | ||
tabPadding = current.metrics.tabPadding, | ||
tabHeight = PackageSearchMetrics.searchBarHeight, | ||
closeContentGap = current.metrics.closeContentGap, | ||
), | ||
icons = current.icons, | ||
contentAlpha = current.contentAlpha | ||
) | ||
} | ||
|
||
@Composable | ||
fun PackageSearchGlobalColors(): GlobalColors { | ||
val colors = LocalGlobalColors.current | ||
|
||
return remember(colors) { | ||
GlobalColors( | ||
borders = colors.borders, | ||
outlines = OutlineColors( | ||
focused = Color.Transparent, | ||
focusedWarning = colors.outlines.focusedWarning, | ||
focusedError = colors.outlines.focusedError, | ||
warning = colors.outlines.warning, | ||
error = colors.outlines.error, | ||
), | ||
infoContent = colors.infoContent, | ||
paneBackground = colors.paneBackground, | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
internal fun PackageSearchTreeStyle(): LazyTreeStyle { | ||
val currentStyle = LocalLazyTreeStyle.current | ||
val paddings = currentStyle.metrics.elementPadding | ||
return LazyTreeStyle( | ||
currentStyle.colors, | ||
metrics = LazyTreeMetrics( | ||
indentSize = currentStyle.metrics.indentSize, | ||
elementPadding = PaddingValues( | ||
top = paddings.calculateTopPadding(), | ||
bottom = paddings.calculateBottomPadding(), | ||
start = paddings.calculateStartPadding(LocalLayoutDirection.current), | ||
end = 0.dp | ||
), | ||
elementContentPadding = currentStyle.metrics.elementContentPadding, | ||
elementMinHeight = currentStyle.metrics.elementMinHeight, | ||
chevronContentGap = currentStyle.metrics.chevronContentGap, | ||
elementBackgroundCornerSize = currentStyle.metrics.elementBackgroundCornerSize, | ||
), | ||
currentStyle.icons, | ||
) | ||
} | ||
|
||
|
||
internal val LocalPackageSearchDropdownLinkStyle: ProvidableCompositionLocal<LinkStyle> = | ||
staticCompositionLocalOf { | ||
error("No PackageSearchDropdownLinkStyle provided. Have you forgotten the theme?") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.