SelectionControlScope


class SelectionControlScope


SelectionControlScope provides enabled and selected properties. This allows selection controls to omit enabled/selected parameters as they given by the scope.

Summary

Public constructors

SelectionControlScope(isEnabled: Boolean, isSelected: Boolean)

Public properties

Boolean

Controls the enabled state of the selection control.

Boolean

Indicates whether the control is currently selected

Extension functions

Unit

Radio provides an animated radio selection control for use in RadioButton or SplitRadioButton.

Public constructors

SelectionControlScope

Added in 1.0.0-alpha21
SelectionControlScope(isEnabled: Boolean, isSelected: Boolean)
Parameters
isEnabled: Boolean

Controls the enabled state of the selection control. When false, the control is displayed with disabled colors

isSelected: Boolean

Indicates whether the control is currently selected

Public properties

isEnabled

Added in 1.0.0-alpha21
val isEnabledBoolean

Controls the enabled state of the selection control. When false, the control is displayed with disabled colors

isSelected

Added in 1.0.0-alpha21
val isSelectedBoolean

Indicates whether the control is currently selected

Extension functions

@Composable
fun SelectionControlScope.Radio(
    modifier: Modifier = Modifier,
    colors: RadioColors = RadioDefaults.colors()
): Unit

Radio provides an animated radio selection control for use in RadioButton or SplitRadioButton.

RadioButton sample:

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material3.Icon
import androidx.wear.compose.material3.RadioButton
import androidx.wear.compose.material3.Text

Column(modifier = Modifier.selectableGroup()) {
    var selectedButton by remember { mutableStateOf(0) }
    // RadioButton uses the Radio selection control by default.
    RadioButton(
        label = {
            Text("Radio button", maxLines = 3, overflow = TextOverflow.Ellipsis)
        },
        secondaryLabel = {
            Text("With secondary label", maxLines = 2, overflow = TextOverflow.Ellipsis)
        },
        selected = selectedButton == 0,
        onSelect = { selectedButton = 0 },
        icon = {
            Icon(
                Icons.Filled.Favorite,
                contentDescription = "Favorite icon"
            )
        },
        enabled = true,
    )
    Spacer(modifier = Modifier.height(4.dp))
    RadioButton(
        label = {
            Text("Radio button", maxLines = 3, overflow = TextOverflow.Ellipsis)
        },
        secondaryLabel = {
            Text("With secondary label", maxLines = 3, overflow = TextOverflow.Ellipsis)
        },
        selected = selectedButton == 1,
        onSelect = { selectedButton = 1 },
        icon = {
            Icon(
                Icons.Filled.Favorite,
                contentDescription = "Favorite icon"
            )
        },
        enabled = true,
    )
}
Parameters
modifier: Modifier = Modifier

Modifier to be applied to the radio control. This can be used to provide a content description for accessibility.

colors: RadioColors = RadioDefaults.colors()

RadioColors from which the Radio control colors will be obtained.