Skip to content
Closed
Show file tree
Hide file tree
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 @@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -874,17 +873,15 @@ private fun <T : Any> PopupContent(
VerticallyScrollableContainer(scrollState = listState.lazyListState as ScrollableState) {
SelectableLazyColumn(
modifier =
Modifier.fillMaxWidth()
.testTag("Jewel.ComboBox.List")
.thenIf(items.isNotEmpty()) { padding(contentPadding) }
.thenIf(items.isEmpty()) {
heightIn(
min =
comboBoxSize.height +
contentPadding.calculateTopPadding() +
contentPadding.calculateBottomPadding()
)
},
Modifier.fillMaxWidth().testTag("Jewel.ComboBox.List").thenIf(items.isEmpty()) {
heightIn(
min =
comboBoxSize.height +
contentPadding.calculateTopPadding() +
contentPadding.calculateBottomPadding()
)
},
contentPadding = if (items.isNotEmpty()) contentPadding else PaddingValues(),
selectionMode = SelectionMode.Single,
state = listState,
onSelectedIndexesChange = { selectedItemsIndexes ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jewel.swing.not.editable.disabled=Not editable + disabled
jewel.swing.editable=Editable
jewel.swing.editable.disabled=Editable + Disabled
jewel.swing.text.areas=Text areas:
jewel.swing.label=Swing
jewel.compose.label=Compose

compose.sandbox=Compose Sandbox
compose.sandbox.show.automatically.on.project.open=Show automatically on project open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() {

private fun Panel.comboBoxesRow() {
row(DevkitComposeBundle.message("jewel.swing.combo.boxes")) {
// Swing ComboBoxes
label(DevkitComposeBundle.message("jewel.swing.label")).bold()
}
.layout(RowLayout.PARENT_GRID)

row("") {
val zoomLevels = arrayOf("100%", "125%", "150%", "175%", "200%", "300%")

JPanel()
Expand Down Expand Up @@ -323,7 +327,7 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() {
}
.run { cell(this).align(AlignY.TOP) }

val itemsComboBox = arrayOf("Cat", "Elephant", "Sun", "Book", "Laughter")
val itemsComboBox = arrayOf("Cat", "Elephant", "Sun", "Book", "Laughter", "Whisper", "Ocean", "Serendipity lorem ipsum", "Umbrella")
JPanel()
.apply {
layout = BoxLayout(this, BoxLayout.Y_AXIS)
Expand All @@ -350,7 +354,15 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() {
)
}
.run { cell(this).align(AlignY.TOP) }
}
.layout(RowLayout.PARENT_GRID)

row("") {
label(DevkitComposeBundle.message("jewel.compose.label")).bold()
}
.layout(RowLayout.PARENT_GRID)

row("") {
compose(modifier = Modifier.padding(horizontal = 8.dp)) {
val comboBoxItems = remember {
listOf(
Expand All @@ -366,17 +378,20 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() {
"Joy",
)
}
val zoomLevels = remember {
listOf("100%", "125%", "150%", "175%", "200%", "300%")
}

Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Column {
var selectedIndex by remember { mutableIntStateOf(0) }
val selectedText: String = comboBoxItems[selectedIndex]
val selectedText: String = zoomLevels[selectedIndex]

Text("Not editable")
Text(text = "Selected item: $selectedText")

ListComboBox(
items = comboBoxItems,
items = zoomLevels,
selectedIndex = selectedIndex,
onSelectedItemChange = { selectedIndex = it },
modifier = Modifier.width(200.dp),
Expand All @@ -385,13 +400,13 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() {

Column {
var selectedIndex by remember { mutableIntStateOf(0) }
val selectedText: String = comboBoxItems[selectedIndex]
val selectedText: String = zoomLevels[selectedIndex]

Text("Not editable + disabled")
Text(text = "Selected item: $selectedText")

ListComboBox(
items = comboBoxItems,
items = zoomLevels,
selectedIndex = selectedIndex,
onSelectedItemChange = { selectedIndex = it },
modifier = Modifier.width(200.dp),
Expand Down
Loading