diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/RadioButtonScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/RadioButtonScreen.kt index c7f72770f..88980b075 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/RadioButtonScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/RadioButtonScreen.kt @@ -7,6 +7,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import org.hisp.dhis.common.screens.previews.RadioButtonPreview import org.hisp.dhis.common.screens.previews.TextRadioButtonPreview +import org.hisp.dhis.mobile.ui.designsystem.component.AgeFieldHelper import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer import org.hisp.dhis.mobile.ui.designsystem.component.Orientation import org.hisp.dhis.mobile.ui.designsystem.component.RadioButtonBlock @@ -39,6 +40,12 @@ fun RadioButtonScreen() { RadioButtonData("3", selected = false, enabled = false, textInput = option4), ) + val ageFieldHelperHorizontal = listOf( + RadioButtonData("0", selected = true, enabled = true, textInput = "Years"), + RadioButtonData("1", selected = false, enabled = true, textInput = "Months"), + RadioButtonData("2", selected = false, enabled = true, textInput = "Days"), + ) + var selectedItemVertical by remember { mutableStateOf(radioButtonDataItemsVertical[0]) } @@ -47,6 +54,10 @@ fun RadioButtonScreen() { mutableStateOf(radioButtonDataItemsHorizontal[0]) } + var selectedFieldHorizontal by remember { + mutableStateOf(ageFieldHelperHorizontal[0]) + } + ColumnComponentContainer("Radio Buttons") { SubTitle("Text Radio Button") @@ -81,5 +92,9 @@ fun RadioButtonScreen() { RadioButtonBlock(Orientation.VERTICAL, radioButtonDataItemsVertical, selectedItemVertical) { selectedItemVertical = it } + SubTitle("Horizontal Age Field Helper") + AgeFieldHelper(Orientation.HORIZONTAL, ageFieldHelperHorizontal, selectedFieldHorizontal) { + selectedFieldHorizontal = it + } } } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/RadioButton.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/RadioButton.kt index c16129977..93201fb6a 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/RadioButton.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/RadioButton.kt @@ -1,5 +1,6 @@ package org.hisp.dhis.mobile.ui.designsystem.component +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement @@ -21,6 +22,7 @@ import androidx.compose.ui.Modifier import org.hisp.dhis.mobile.ui.designsystem.theme.InternalSizeValues import org.hisp.dhis.mobile.ui.designsystem.theme.Outline import org.hisp.dhis.mobile.ui.designsystem.theme.Ripple +import org.hisp.dhis.mobile.ui.designsystem.theme.Shape import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor @@ -157,6 +159,27 @@ fun RadioButtonBlock( } } +@Composable +fun AgeFieldHelper( + orientation: Orientation, + options: List, + optionSelected: RadioButtonData, + onClick: (RadioButtonData) -> Unit, +) { + RowComponentContainer( + modifier = Modifier + .padding( + start = Spacing.Spacing8, + end = Spacing.Spacing8, + ) + .background(color = SurfaceColor.Surface, Shape.SmallBottom), + ) { + RadioButtonBlock(orientation, options, optionSelected) { + onClick + } + } +} + data class RadioButtonData( val uid: String, val selected: Boolean,