diff --git a/demo/src/main/java/com/orange/ods/demo/ui/components/radiobuttons/ComponentRadioButtons.kt b/demo/src/main/java/com/orange/ods/demo/ui/components/radiobuttons/ComponentRadioButtons.kt index d568d5d6a..3bca04596 100644 --- a/demo/src/main/java/com/orange/ods/demo/ui/components/radiobuttons/ComponentRadioButtons.kt +++ b/demo/src/main/java/com/orange/ods/demo/ui/components/radiobuttons/ComponentRadioButtons.kt @@ -16,55 +16,56 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.selection.selectableGroup import androidx.compose.foundation.verticalScroll import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.rememberBottomSheetScaffoldState import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier import androidx.compose.ui.res.dimensionResource import com.orange.ods.demo.R +import com.orange.ods.demo.ui.components.utilities.ComponentCustomizationBottomSheetScaffold import com.orange.ods.demo.ui.utilities.composable.RadioButtonListItem -import com.orange.ods.demo.ui.utilities.composable.Title +import com.orange.ods.demo.ui.utilities.composable.SwitchListItem @ExperimentalMaterialApi @Composable fun ComponentRadioButtons() { - Column( - modifier = Modifier - .verticalScroll(rememberScrollState()) - .padding(bottom = dimensionResource(id = R.dimen.spacing_m)) - ) { - Title(textRes = R.string.component_radio_buttons_enabled, withHorizontalPadding = true) - RadioButtons(enabled = true) + val disabled = rememberSaveable { mutableStateOf(false) } - Title(textRes = R.string.component_radio_buttons_disabled, withHorizontalPadding = true) - RadioButtons(enabled = false) - } -} - -@ExperimentalMaterialApi -@Composable -private fun RadioButtons(enabled: Boolean) { - val selectedRadio = remember { mutableStateOf(R.string.component_element_item1) } - Column(modifier = Modifier.selectableGroup()) { - RadioButtonListItem( - labelRes = R.string.component_element_item1, - selectedRadio = selectedRadio, - currentRadio = R.string.component_element_item1, - enabled = enabled - ) + ComponentCustomizationBottomSheetScaffold( + bottomSheetScaffoldState = rememberBottomSheetScaffoldState(), + bottomSheetContent = { + SwitchListItem(labelRes = R.string.component_state_disabled, checked = disabled) + }) { + Column( + modifier = Modifier + .verticalScroll(rememberScrollState()) + .padding(bottom = dimensionResource(id = R.dimen.spacing_m)) + ) { + val selectedRadio = remember { mutableStateOf(R.string.component_element_item1) } + Column(modifier = Modifier.selectableGroup()) { + RadioButtonListItem( + labelRes = R.string.component_element_item1, + selectedRadio = selectedRadio, + currentRadio = R.string.component_element_item1, + enabled = !disabled.value + ) - RadioButtonListItem( - labelRes = R.string.component_element_item2, - selectedRadio = selectedRadio, - currentRadio = R.string.component_element_item2, - enabled = enabled - ) + RadioButtonListItem( + labelRes = R.string.component_element_item2, + selectedRadio = selectedRadio, + currentRadio = R.string.component_element_item2, + enabled = !disabled.value + ) - RadioButtonListItem( - labelRes = R.string.component_element_item3, - selectedRadio = selectedRadio, - currentRadio = R.string.component_element_item3, - enabled = enabled - ) + RadioButtonListItem( + labelRes = R.string.component_element_item3, + selectedRadio = selectedRadio, + currentRadio = R.string.component_element_item3, + enabled = !disabled.value + ) + } + } } } \ No newline at end of file diff --git a/demo/src/main/res/values/strings.xml b/demo/src/main/res/values/strings.xml index e5d4f02f9..a0f3dd461 100644 --- a/demo/src/main/res/values/strings.xml +++ b/demo/src/main/res/values/strings.xml @@ -134,8 +134,6 @@ Radio Buttons Radio buttons enable users to choose one item from a set of mutually exclusive, related choices. - Enabled radio buttons - Disabled radio buttons Switches @@ -205,7 +203,6 @@ Keyboard action Capitalization - Tabs A tab bar appears at the top of the screen and provides an easy way for users to switch between a number of different views.