mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
app: fix touch effect and hitbox mismatches
Resolve touch target and ripple effect area discrepancies across the apk module: - ModuleScreen: Use Card(onClick) to ensure ripple indications are clipped to the card's 20.dp rounded corners. - SettingsComponents: Make trailing Switch passive and apply Modifier.toggleable on ListItem to eliminate nested ripples and conflicting hitboxes. - DenyListScreen: Use Modifier.toggleable on ProcessRow with a passive Checkbox to prevent 48dp touch targets overflowing the 32dp row. - HomeScreen: Increase developer link button spacing to 8.dp to prevent overlapping 48x48dp touch targets. - Scrollbar: Only consume pointer events when the scrollbar is visible and touch hits the thumb, allowing underlying controls to receive touches unimpeded. Assisted-by: Gemini 3.8 Flash
This commit is contained in:
@@ -385,11 +385,15 @@ fun Modifier.verticalScrollbar(
|
||||
LayoutDirection.Ltr -> down.position.x >= (width - paddingEnd - hitWidthPx)
|
||||
}
|
||||
|
||||
if (isHit && down.position.y in paddingTop..(height - paddingBottom)) {
|
||||
val trackHeight = height - paddingTop - paddingBottom
|
||||
val thumbH = (trackHeight * adapter.thumbRatio).coerceAtLeast(minThumbHeightPx)
|
||||
val thumbOffset = paddingTop + (trackHeight - thumbH) * adapter.offsetRatio
|
||||
val hitPaddingY = 16.dp.toPx()
|
||||
val isOverThumb = down.position.y in (thumbOffset - hitPaddingY)..(thumbOffset + thumbH + hitPaddingY)
|
||||
|
||||
if (alphaAnim.value > 0f && isHit && isOverThumb) {
|
||||
down.consume()
|
||||
isDragging = true
|
||||
val trackHeight = height - paddingTop - paddingBottom
|
||||
val thumbH = (trackHeight * adapter.thumbRatio).coerceAtLeast(minThumbHeightPx)
|
||||
val initialFraction = calculateFraction(down.position.y, height, thumbH)
|
||||
dragFraction = initialFraction
|
||||
|
||||
@@ -522,11 +526,20 @@ fun Modifier.horizontalScrollbar(
|
||||
|
||||
val isHit = down.position.y >= (height - paddingBottom - hitHeightPx)
|
||||
|
||||
if (isHit && down.position.x in paddingStart..(width - paddingEnd)) {
|
||||
val trackWidth = width - paddingStart - paddingEnd
|
||||
val thumbW = (trackWidth * adapter.thumbRatio).coerceAtLeast(minThumbWidthPx)
|
||||
val offset = (trackWidth - thumbW) * adapter.offsetRatio
|
||||
val thumbLeft = when (layoutDirection) {
|
||||
LayoutDirection.Ltr -> paddingStart + offset
|
||||
LayoutDirection.Rtl -> width - paddingEnd - offset - thumbW
|
||||
}
|
||||
val thumbRight = thumbLeft + thumbW
|
||||
val hitPaddingX = 16.dp.toPx()
|
||||
val isOverThumb = down.position.x in (thumbLeft - hitPaddingX)..(thumbRight + hitPaddingX)
|
||||
|
||||
if (alphaAnim.value > 0f && isHit && isOverThumb) {
|
||||
down.consume()
|
||||
isDragging = true
|
||||
val trackWidth = width - paddingStart - paddingEnd
|
||||
val thumbW = (trackWidth * adapter.thumbRatio).coerceAtLeast(minThumbWidthPx)
|
||||
val initialFraction = calculateFraction(down.position.x, width, thumbW)
|
||||
dragFraction = initialFraction
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.selection.selectable
|
||||
import androidx.compose.foundation.selection.selectableGroup
|
||||
import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
||||
@@ -63,9 +64,14 @@ fun SettingsSwitch(
|
||||
ListItem(
|
||||
headlineContent = { Text(title, style = MaterialTheme.typography.bodyLarge) },
|
||||
supportingContent = summary?.takeIf { it.isNotEmpty() }?.let { { Text(it, style = MaterialTheme.typography.bodyMedium) } },
|
||||
trailingContent = { Switch(checked = checked, onCheckedChange = onCheckedChange, enabled = enabled) },
|
||||
trailingContent = { Switch(checked = checked, onCheckedChange = null, enabled = enabled) },
|
||||
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
|
||||
modifier = modifier.clickable(enabled = enabled, onClick = { onCheckedChange(!checked) })
|
||||
modifier = modifier.toggleable(
|
||||
value = checked,
|
||||
enabled = enabled,
|
||||
role = Role.Switch,
|
||||
onValueChange = onCheckedChange
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
@@ -61,6 +62,7 @@ import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.state.ToggleableState
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
@@ -379,7 +381,11 @@ private fun ProcessRow(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClick = onToggle)
|
||||
.toggleable(
|
||||
value = proc.isEnabled,
|
||||
role = Role.Checkbox,
|
||||
onValueChange = { onToggle() }
|
||||
)
|
||||
.padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
@@ -393,7 +399,7 @@ private fun ProcessRow(
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Checkbox(
|
||||
checked = proc.isEnabled,
|
||||
onCheckedChange = { onToggle() }
|
||||
onCheckedChange = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,7 +843,7 @@ private fun DevelopersCard(
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
dev.links.forEach { link ->
|
||||
IconButton(onClick = { onLinkClicked(link.url) }) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -252,9 +251,9 @@ private fun ModuleCard(
|
||||
val hasDescription = item.module.description.isNotBlank()
|
||||
|
||||
Card(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(enabled = hasDescription) { expanded = !expanded },
|
||||
onClick = { expanded = !expanded },
|
||||
enabled = hasDescription,
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = colorScheme.surfaceContainerLow)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user