fix(#143): the group header itself toggles, without a checkbox of its own
This commit is contained in:
1 parent
9511444c6b
commit
e8d651fe96
1 file changed
+12
-21
@@ -2,6 +2,8 @@ package de.jeanlucmakiola.calendula.ui.filter
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -13,7 +15,6 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TriStateCheckbox
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@@ -21,8 +22,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.toggleableState
|
||||
import androidx.compose.ui.state.ToggleableState
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -118,28 +117,20 @@ private fun GroupHeader(
|
||||
val label = stringResource(
|
||||
if (state.nextGroupVisible()) R.string.filter_group_show_all else R.string.filter_group_hide_all,
|
||||
)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
// The header itself is the toggle; the rows' checkboxes show the result.
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = GroupedListInset / 2)
|
||||
.clip(MaterialTheme.shapes.large)
|
||||
.clickable(onClickLabel = label, role = Role.Checkbox) { onToggle() }
|
||||
.semantics { toggleableState = state }
|
||||
.padding(start = GroupedListInset / 2, end = GroupedListInset / 2 + 16.dp),
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(end = 8.dp),
|
||||
)
|
||||
Box(Modifier.size(48.dp), contentAlignment = Alignment.Center) {
|
||||
TriStateCheckbox(state = state, onClick = null)
|
||||
}
|
||||
}
|
||||
.clickable(onClickLabel = label, role = Role.Button) { onToggle() }
|
||||
.heightIn(min = 48.dp)
|
||||
.wrapContentHeight(Alignment.CenterVertically)
|
||||
.padding(horizontal = GroupedListInset / 2),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
Reference in new issue
Block a user