Bug 1860274 - Modify SwitchWithLabel behaviour

fenix/120.0
AndiAJ 7 months ago committed by mergify[bot]
parent 5989874de8
commit c7d225138d

@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.selection.toggleable
import androidx.compose.material.SwitchDefaults
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@ -21,6 +22,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.unit.dp
import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.theme.FirefoxTheme
@ -47,7 +50,13 @@ fun SwitchWithLabel(
enabled: Boolean = true,
) {
Row(
modifier = modifier,
modifier = modifier
.toggleable(
value = checked,
enabled = enabled,
role = Role.Switch,
onValueChange = onCheckedChange,
),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalAlignment = Alignment.CenterVertically,
) {
@ -63,6 +72,7 @@ fun SwitchWithLabel(
)
Switch(
modifier = Modifier.clearAndSetSemantics {},
checked = checked,
onCheckedChange = onCheckedChange,
enabled = enabled,

Loading…
Cancel
Save