Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup IDE demo #204

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.HoverInteraction
import androidx.compose.foundation.interaction.MutableInteractionSource
Expand Down Expand Up @@ -47,7 +48,6 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Color.Companion.Transparent
import androidx.compose.ui.graphics.Color.Companion.Unspecified
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
Expand All @@ -61,7 +61,6 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.intellij.icons.AllIcons
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.ui.NewUI
Expand All @@ -86,12 +85,14 @@ import org.jetbrains.jewel.foundation.modifier.onHover
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.ui.component.HorizontalSplitLayout
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.IconButton
import org.jetbrains.jewel.ui.component.PopupMenu
import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.component.TextField
import org.jetbrains.jewel.ui.component.VerticalScrollbar
import org.jetbrains.jewel.ui.component.items
import org.jetbrains.jewel.ui.painter.rememberResourcePainterProvider
import org.jetbrains.jewel.ui.theme.iconButtonStyle
import org.jetbrains.jewel.ui.util.thenIf
import org.jetbrains.skiko.DependsOnJBR
import java.awt.Font
Expand Down Expand Up @@ -127,7 +128,7 @@ fun ReleasesSampleCompose(project: Project) {
}

@Composable
fun LeftColumn(
private fun LeftColumn(
project: Project,
modifier: Modifier = Modifier,
onSelectedItemChange: (ContentItem?) -> Unit,
Expand Down Expand Up @@ -352,26 +353,29 @@ private fun OverflowMenu(
}
}

val backgroundColor = remember(hovered, pressed) {
when {
pressed -> JBUI.CurrentTheme.ActionButton.pressedBackground().toComposeColor()
hovered -> JBUI.CurrentTheme.ActionButton.hoverBackground().toComposeColor()
else -> Unspecified
}
}

var menuVisible by remember { mutableStateOf(false) }

// TODO use IconButton when it exists
Icon(
resource = "actions/more.svg",
iconClass = AllIcons::class.java,
contentDescription = "Select data source",
modifier = Modifier
.fillMaxHeight()
.clickable(interactionSource, null) { menuVisible = !menuVisible }
.background(backgroundColor, RoundedCornerShape((DarculaUIUtil.BUTTON_ARC.unscaled / 2).dp)),
)
// Emulates Swing actions that pop up menus — they stay pressed while the menu is open
IconButton(
modifier = Modifier.fillMaxHeight()
.thenIf(menuVisible) {
rock3r marked this conversation as resolved.
Show resolved Hide resolved
background(
color = JewelTheme.iconButtonStyle.colors.backgroundPressed,
shape = RoundedCornerShape(JewelTheme.iconButtonStyle.metrics.cornerSize),
).border(
width = JewelTheme.iconButtonStyle.metrics.borderWidth,
color = JewelTheme.iconButtonStyle.colors.backgroundPressed,
shape = RoundedCornerShape(JewelTheme.iconButtonStyle.metrics.cornerSize),
)
},
onClick = { menuVisible = !menuVisible },
) {
Icon(
resource = "actions/more.svg",
iconClass = AllIcons::class.java,
contentDescription = "Select data source",
)
}

val contentSources = remember {
listOf(AndroidStudioReleases, AndroidReleases)
Expand Down Expand Up @@ -419,7 +423,7 @@ private fun OverflowMenu(

@DependsOnJBR
@Composable
fun RightColumn(
private fun RightColumn(
selectedItem: ContentItem?,
modifier: Modifier,
) {
Expand Down
Loading