Section: suppress sectionItemHover on disabled SectionItemView

sectionItemHover was applied unconditionally inside section cards, so a
disabled row would still show the hover overlay on mouseover —
misleading: the visible interactive feedback contradicts the disabled
state (no click reaction).

Add `enabled: Boolean = true` parameter; the helper now returns `this`
unchanged when `enabled = false`. The 3 SectionItemView family
functions that own a modifier chain pass `enabled = !disabled`.
SectionItemViewWithoutMinPadding inherits through SectionItemView delegation.

Non-clickable info rows (click == null but disabled = false) still get
the hover overlay — that's intentional cursor feedback matching iOS
Settings behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
another-simple-pixel
2026-05-16 09:53:29 -07:00
parent f223267687
commit 17a6e344f3
@@ -40,9 +40,11 @@ private val LocalInSectionCard = staticCompositionLocalOf { false }
// against the off-white LIGHT canvas (where the default 0.04-alpha ripple hover
// blends in). Click ripple is still provided by Modifier.clickable's own
// indication — this only handles the persistent hover overlay.
// `enabled = false` suppresses the hover state entirely (used for disabled
// items, which should not visually respond to hover).
@Composable
private fun Modifier.sectionItemHover(): Modifier {
if (!LocalInSectionCard.current) return this
private fun Modifier.sectionItemHover(enabled: Boolean = true): Modifier {
if (!enabled || !LocalInSectionCard.current) return this
val interactionSource = remember { MutableInteractionSource() }
val isHovered by interactionSource.collectIsHoveredAsState()
val hoverColor = if (isHovered) MaterialTheme.colors.onBackground.copy(alpha = 0.08f) else Color.Transparent
@@ -200,7 +202,7 @@ fun SectionItemView(
val modifier = Modifier
.fillMaxWidth()
.sizeIn(minHeight = minHeight)
.sectionItemHover()
.sectionItemHover(enabled = !disabled)
.sectionItemDivider()
Row(
if (click == null || disabled) modifier.padding(padding) else modifier.clickable(onClick = click).padding(padding),
@@ -241,7 +243,7 @@ fun SectionItemViewLongClickable(
val modifier = Modifier
.fillMaxWidth()
.sizeIn(minHeight = minHeight)
.sectionItemHover()
.sectionItemHover(enabled = !disabled)
.sectionItemDivider()
Row(
if (disabled) {
@@ -267,7 +269,7 @@ fun SectionItemViewSpaceBetween(
val modifier = Modifier
.fillMaxWidth()
.sizeIn(minHeight = minHeight)
.sectionItemHover()
.sectionItemHover(enabled = !disabled)
.sectionItemDivider()
Row(
if (click == null || disabled) modifier.padding(padding).padding(vertical = DEFAULT_MIN_SECTION_ITEM_PADDING_VERTICAL) else modifier