Skip to content

Commit

Permalink
Details panel content layout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Dec 4, 2023
1 parent 3de49fe commit 42a8bd5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
Expand All @@ -19,16 +18,17 @@ import androidx.compose.ui.unit.TextUnit
import com.intellij.icons.AllIcons
import com.jetbrains.packagesearch.plugin.ui.PackageSearchMetrics
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.foundation.theme.LocalContentColor
import org.jetbrains.jewel.foundation.theme.LocalTextStyle
import org.jetbrains.jewel.ui.component.Dropdown
import org.jetbrains.jewel.ui.component.DropdownLink
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.IconButton
import org.jetbrains.jewel.ui.component.MenuScope
import org.jetbrains.jewel.ui.component.PopupMenu
import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.component.styling.DropdownColors
import org.jetbrains.jewel.ui.component.styling.DropdownStyle
import org.jetbrains.jewel.ui.theme.dropdownStyle
import org.jetbrains.jewel.ui.component.styling.LinkColors
import org.jetbrains.jewel.ui.component.styling.LinkStyle
import org.jetbrains.jewel.ui.theme.linkStyle

@Composable
fun LabelInfo(
Expand Down Expand Up @@ -79,11 +79,11 @@ fun TextSelectionDropdown(
enabled: Boolean,
onSelection: (String) -> Unit,
) {
Dropdown(
DropdownLink(
modifier = modifier,
menuModifier = menuModifier.heightIn(max = PackageSearchMetrics.Dropdown.maxHeight),
enabled = enabled && items.isNotEmpty(),
style = packageSearchDropdownStyle(),
style = packageSearchDropdownLinkStyle(),
menuContent = {
items.forEach {
selectableItem(
Expand All @@ -94,15 +94,7 @@ fun TextSelectionDropdown(
}
}
},
content = {
Text(
modifier = Modifier.align(Alignment.CenterEnd),
text = content,
maxLines = 1,
overflow = TextOverflow.Clip,
textAlign = TextAlign.End
)
}
text = content
)
}

Expand Down Expand Up @@ -143,34 +135,20 @@ internal fun PackageActionPopup(
}

@Composable
private fun packageSearchDropdownStyle(): DropdownStyle {
val currentStyle = JewelTheme.dropdownStyle
return DropdownStyle(
colors = DropdownColors(
background = Color.Transparent,
backgroundDisabled = Color.Transparent,
backgroundFocused = Color.Transparent,
backgroundPressed = Color.Transparent,
backgroundHovered = Color.Transparent,
content = currentStyle.colors.content,
private fun packageSearchDropdownLinkStyle(): LinkStyle {
val currentStyle = JewelTheme.linkStyle
val contentColor= LocalContentColor.current
return LinkStyle(
colors = LinkColors(
content = contentColor,
contentDisabled = currentStyle.colors.contentDisabled,
contentFocused = currentStyle.colors.contentFocused,
contentPressed = currentStyle.colors.contentPressed,
contentHovered = currentStyle.colors.contentHovered,
border = Color.Transparent,
borderDisabled = Color.Transparent,
borderFocused = Color.Transparent,
borderPressed = Color.Transparent,
borderHovered = Color.Transparent,
iconTintDisabled = Color.Transparent,
iconTint = currentStyle.colors.iconTint,
iconTintFocused = currentStyle.colors.iconTintFocused,
iconTintPressed = currentStyle.colors.iconTintPressed,
iconTintHovered = currentStyle.colors.iconTintHovered,
contentHovered = contentColor,
contentPressed = contentColor,
contentFocused = contentColor,
contentVisited = contentColor,
),
metrics = currentStyle.metrics,
icons = currentStyle.icons,
textStyle = currentStyle.textStyle,
menuStyle = currentStyle.menuStyle,
textStyles = currentStyle.textStyles,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ private fun ScopeAndVersionDropdowns(
Row() {
Box(modifier = Modifier.widthIn(max = 180.dp)) {
ScopeSelectionDropdown(
modifier = Modifier.align(Alignment.CenterEnd),
declaredScope = item.selectedScope,
allowMissingScope = item.allowMissingScope,
availableScopes = item.availableScopes,
Expand All @@ -182,9 +181,8 @@ private fun ScopeAndVersionDropdowns(
)
}

Box(modifier = Modifier.width(180.dp)) {
Box(modifier = Modifier.width(180.dp), contentAlignment = Alignment.CenterEnd) {
VersionSelectionDropdown(
modifier = Modifier.align(Alignment.CenterEnd),
declaredVersion = item.declaredVersion,
availableVersions = item.availableVersions,
latestVersion = item.latestVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.jetbrains.packagesearch.plugin.PackageSearchBundle
import com.jetbrains.packagesearch.plugin.PackageSearchBundle.message
import com.jetbrains.packagesearch.plugin.core.data.IconProvider
import com.jetbrains.packagesearch.plugin.ui.bridge.LabelInfo
Expand Down Expand Up @@ -50,10 +49,7 @@ internal fun PackageOverviewTab(
verticalArrangement = Arrangement.spacedBy(4.dp),
modifier = Modifier.fillMaxSize().padding(start = 4.dp)
) {
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.Top
) {
Row(verticalAlignment = Alignment.Top) {
InfoPanelPackageTitle(modifier = Modifier.weight(1f), content.title, content.subtitle)
InfoPanelPackageActions(content, onPackageEvent)
}
Expand All @@ -63,7 +59,7 @@ internal fun PackageOverviewTab(
) {
if (content is InfoPanelContent.PackageInfo.Declared) {
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
horizontalArrangement = Arrangement.spacedBy(2.dp),
verticalAlignment = Alignment.Top
) {
LabelInfo(
Expand All @@ -80,7 +76,7 @@ internal fun PackageOverviewTab(
}
}
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
horizontalArrangement = Arrangement.spacedBy(2.dp),
verticalAlignment = Alignment.Top
) {
LabelInfo(
Expand Down Expand Up @@ -222,7 +218,7 @@ private fun InfoPanelPackageActions(

@Composable
private fun PackageType(name: String, icon: IconProvider.Icon) {
Row(horizontalArrangement = Arrangement.spacedBy(4.dp), verticalAlignment = Alignment.CenterVertically) {
Row(horizontalArrangement = Arrangement.spacedBy(2.dp), verticalAlignment = Alignment.CenterVertically) {
LabelInfo(
modifier = Modifier.defaultMinSize(90.dp),
text = message("packagesearch.ui.toolwindow.packages.columns.type")
Expand All @@ -244,7 +240,7 @@ private fun InfoPanelPackageDetailLine(name: String, value: String) {
verticalAlignment = Alignment.Top,
) {
LabelInfo(
modifier = Modifier.defaultMinSize(90.dp),
modifier = Modifier.defaultMinSize(90.dp,16.dp),
text = name
)
Text(value)
Expand Down Expand Up @@ -283,7 +279,7 @@ private fun InfoPanelPackageTitle(
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
org.jetbrains.jewel.ui.component.Text(name ?: id, fontWeight = FontWeight.Bold)
Text(name ?: id, fontWeight = FontWeight.Bold)
if (name != null) LabelInfo(id)
}
}
Expand All @@ -300,7 +296,7 @@ private fun InfoPanelPackageLinks(
) {
LabelInfo(
modifier = Modifier.defaultMinSize(90.dp),
text = PackageSearchBundle.message("packagesearch.ui.toolwindow.packages.details.info.licenses")
text = message("packagesearch.ui.toolwindow.packages.details.info.licenses")
)
licenses.forEachIndexed { index, license ->
when (license.url) {
Expand Down

0 comments on commit 42a8bd5

Please sign in to comment.