Skip to content

Commit

Permalink
Semantics clear for tri state checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
alorma committed Jan 21, 2025
1 parent 053dfea commit ebfe566
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ fun SettingsScreen(
)
SettingsSwitchSampleSection(iconState.value)
SettingsCheckboxSampleSection(iconState.value)
/*
SettingsTriStateCheckboxSampleSection(iconState.value)
SettingsRadioButtonSampleSection(iconState.value)
SettingsMenuLinkSectionSample(iconState.value)
SettingsSliderSectionSample(iconState.value)
SettingsSelectorsSample(iconState.value)
SettingsGroupSectionSample(iconState.value)
*/
SettingsTriStateCheckboxSampleSection(iconState.value)
SettingsRadioButtonSampleSection(iconState.value)
SettingsMenuLinkSectionSample(iconState.value)
SettingsSliderSectionSample(iconState.value)
SettingsSelectorsSample(iconState.value)
SettingsGroupSectionSample(iconState.value)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.SemanticsPropertyReceiver
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.unit.Dp
import com.alorma.compose.settings.ui.base.internal.LocalSettingsGroupEnabled
Expand All @@ -35,19 +38,20 @@ fun SettingsTriStateCheckbox(
),
tonalElevation: Dp = SettingsTileDefaults.Elevation,
shadowElevation: Dp = SettingsTileDefaults.Elevation,
semanticProperties: (SemanticsPropertyReceiver.() -> Unit) = {},
onCheckedChange: (Boolean) -> Unit = {},
) {
val update: () -> Unit = { onCheckedChange(state?.not() ?: true) }
Row(
modifier =
Modifier
modifier = Modifier
.fillMaxWidth()
.triStateToggleable(
state = mapNullableBooleanToToggleableState(state),
onClick = update,
enabled = enabled,
role = Role.Checkbox,
).then(modifier),
).semantics(properties = semanticProperties)
.then(modifier),
verticalAlignment = Alignment.CenterVertically,
) {
SettingsTileScaffold(
Expand All @@ -60,6 +64,7 @@ fun SettingsTriStateCheckbox(
shadowElevation = shadowElevation,
) {
TriStateCheckbox(
modifier = Modifier.clearAndSetSemantics { },
enabled = enabled,
state = mapNullableBooleanToToggleableState(state),
onClick = update,
Expand Down

0 comments on commit ebfe566

Please sign in to comment.