Skip to content

Commit

Permalink
lint happy!
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Dec 11, 2023
1 parent 2ac7ca3 commit d67da54
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ private fun readMenuStyle(): MenuStyle {
),
separatorThickness = retrieveIntAsDpOrUnspecified("PopupMenuSeparator.stripeWidth")
.takeOrElse { 0.dp },
iconSize = 16.dp
iconSize = 16.dp,
),
submenuMetrics = SubmenuMetrics(offset = DpOffset(0.dp, (-8).dp)),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public fun MenuItemMetrics.Companion.defaults(
separatorPadding,
keybindingsPadding,
separatorThickness,
iconSize
iconSize,
)

public fun SubmenuMetrics.Companion.defaults(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ fun DecoratedWindowScope.TitleBarView() {
selected = MainViewModel.currentView == it,
onClick = {
MainViewModel.currentView = it
}) {
},
) {
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ fun Dropdowns() {
if (it == "---") {
separator()
} else {
selectableItem(selected == it,
onClick = { selected = it }
selectableItem(
selected = selected == it,
onClick = { selected = it },
) {
Text(it)
}
Expand All @@ -63,7 +64,7 @@ fun Dropdowns() {
} else {
selectableItem(
selected = selected == it,
onClick = { selected = it }
onClick = { selected = it },
) {
Text(it)
}
Expand All @@ -77,7 +78,7 @@ fun Dropdowns() {
} else {
selectableItem(
selected = selected == it,
onClick = { selected = it }
onClick = { selected = it },
) {
Text(it)
}
Expand All @@ -102,7 +103,7 @@ fun Dropdowns() {
} else {
selectableItem(
selected = selected == it,
onClick = { selected = it }
onClick = { selected = it },
) {
Text(it)
}
Expand All @@ -121,11 +122,15 @@ fun Dropdowns() {
selectableItem(
iconResource = dropdownIconsSample.random(),
iconClass = DropdownStyle::class.java,
keybinding = if (Random.nextBoolean()) null else dropdownKeybindingsSample.shuffled()
.take(2)
.toSet(),
keybinding = if (Random.nextBoolean()) {
null
} else {
dropdownKeybindingsSample.shuffled()
.take(2)
.toSet()
},
selected = false,
onClick = { }
onClick = { },
) {
Text(it)
}
Expand All @@ -139,11 +144,15 @@ fun Dropdowns() {
selectableItem(
iconResource = dropdownIconsSample.random(),
iconClass = DropdownStyle::class.java,
keybinding = if (Random.nextBoolean()) null else dropdownKeybindingsSample.shuffled()
.take(2)
.toSet(),
keybinding = if (Random.nextBoolean()) {
null
} else {
dropdownKeybindingsSample.shuffled()
.take(2)
.toSet()
},
selected = false,
onClick = { }
onClick = { },
) {
Text(it)
}
Expand All @@ -159,7 +168,7 @@ fun Dropdowns() {
iconResource = dropdownIconsSample.random(),
iconClass = DropdownStyle::class.java,
selected = false,
onClick = { }
onClick = { },
) {
Text(it)
}
Expand All @@ -179,4 +188,4 @@ fun Dropdowns() {
}

private val dropdownIconsSample = listOf("icons/search.svg", "icons/close.svg", null)
private val dropdownKeybindingsSample = setOf('A', 'B', '', '', '')
private val dropdownKeybindingsSample = setOf('A', 'B', '', '', '')
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ fun Links() {
selected = selected == it,
onClick = {
selected = it
}) {
},
) {
Text(it)
}
}
Expand Down
13 changes: 6 additions & 7 deletions ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Menu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ private fun (MenuScope.() -> Unit).asList() = buildList {
iconClass = iconClass,
keybinding = keybinding,
onClick = onClick,
content = content
)
content = content,
),
)
}

Expand Down Expand Up @@ -417,7 +417,7 @@ internal fun MenuItem(
modifier = Modifier.fillMaxWidth()
.drawItemBackground(itemMetrics, backgroundColor)
.padding(itemMetrics.contentPadding),
horizontalArrangement = Arrangement.spacedBy(4.dp)
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
if (iconGap) {
if (iconResource != null) {
Expand All @@ -430,11 +430,11 @@ internal fun MenuItem(
content()
}
if (keybindingGap) {
val keybindingText = remember { keybinding?.joinToString("") { it.toString() } ?: "" }
val keybindingText = remember { keybinding?.joinToString("") { it.toString() }.orEmpty() }
Text(
modifier = Modifier.padding(style.metrics.itemMetrics.keybindingsPadding),
text = keybindingText,
color = itemColors.keybindingTintFor(itemState).value
color = itemColors.keybindingTintFor(itemState).value,
)
}
}
Expand All @@ -454,8 +454,7 @@ public fun MenuSubmenuItem(
submenu: MenuScope.() -> Unit,
content: @Composable () -> Unit,
) {
var itemState by
remember(interactionSource) {
var itemState by remember(interactionSource) {
mutableStateOf(MenuItemState.of(selected = false, enabled = enabled))
}

Expand Down

0 comments on commit d67da54

Please sign in to comment.