Fix preference disabled state alpha
This commit is contained in:
parent
89db713e24
commit
1a3fde5bf5
@ -2,13 +2,13 @@ package de.mm20.launcher2.ui.component.preferences
|
|||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.ContentAlpha
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.LocalContentAlpha
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@ -21,48 +21,44 @@ fun Preference(
|
|||||||
controls: @Composable (() -> Unit)? = null,
|
controls: @Composable (() -> Unit)? = null,
|
||||||
enabled: Boolean = true
|
enabled: Boolean = true
|
||||||
) {
|
) {
|
||||||
CompositionLocalProvider(
|
Row(
|
||||||
LocalContentAlpha provides if (enabled) ContentAlpha.high else ContentAlpha.disabled
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clickable(enabled = enabled, onClick = onClick)
|
||||||
|
.padding(horizontal = 16.dp, vertical = 16.dp)
|
||||||
|
.alpha(if (enabled) 1f else 0.38f),
|
||||||
) {
|
) {
|
||||||
|
Box(
|
||||||
Row(
|
modifier = Modifier.width(56.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
contentAlignment = Alignment.CenterStart
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.clickable(enabled = enabled, onClick = onClick)
|
|
||||||
.padding(horizontal = 16.dp, vertical = 16.dp),
|
|
||||||
) {
|
) {
|
||||||
|
if (icon != null) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
|
imageVector = icon,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.weight(1f)
|
||||||
|
) {
|
||||||
|
Text(text = title, style = MaterialTheme.typography.titleMedium)
|
||||||
|
if (summary != null) {
|
||||||
|
Text(
|
||||||
|
text = summary,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
modifier = Modifier.padding(top = 1.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (controls != null) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.width(56.dp),
|
modifier = Modifier.padding(start = 24.dp)
|
||||||
contentAlignment = Alignment.CenterStart
|
|
||||||
) {
|
) {
|
||||||
if (icon != null) {
|
controls()
|
||||||
Icon(
|
|
||||||
modifier = Modifier.padding(start = 4.dp),
|
|
||||||
imageVector = icon,
|
|
||||||
contentDescription = null,
|
|
||||||
tint = MaterialTheme.colorScheme.primary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.weight(1f)
|
|
||||||
) {
|
|
||||||
Text(text = title, style = MaterialTheme.typography.titleMedium)
|
|
||||||
if (summary != null) {
|
|
||||||
Text(
|
|
||||||
text = summary,
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
modifier = Modifier.padding(top = 1.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (controls != null) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier.padding(start = 24.dp)
|
|
||||||
) {
|
|
||||||
controls()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user