From 2d1faed947908a9bb01b7af8678a5867d045ab8f Mon Sep 17 00:00:00 2001 From: = Date: Wed, 13 Sep 2023 12:13:13 +0200 Subject: [PATCH 01/11] add: [ANDROAPP-5467] age field helper component finished --- .../dhis/common/screens/RadioButtonScreen.kt | 15 ++++++++++++ .../ui/designsystem/component/RadioButton.kt | 23 +++++++++++++++++++ 2 files changed, 38 insertions(+) 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 a38d74b2f..405409097 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 @@ -10,6 +10,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier 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 @@ -43,6 +44,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]) } @@ -51,6 +58,10 @@ fun RadioButtonScreen() { mutableStateOf(radioButtonDataItemsHorizontal[0]) } + var selectedFieldHorizontal by remember { + mutableStateOf(ageFieldHelperHorizontal[0]) + } + ColumnComponentContainer("Radio Buttons") { SubTitle("Text Radio Button") @@ -88,5 +99,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 3a7812176..35f032012 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 @@ -19,6 +20,7 @@ import androidx.compose.ui.platform.testTag 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 @@ -154,6 +156,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, From 3183590e136a19ee0e6c0d0a82daabc7062d50fa Mon Sep 17 00:00:00 2001 From: = Date: Thu, 14 Sep 2023 09:45:55 +0200 Subject: [PATCH 02/11] update: [ANDROAPP-5467] strings added, enum added --- .../dhis/mobile/ui/designsystem/component/RadioButton.kt | 6 +++++- designsystem/src/commonMain/resources/values/strings_en.xml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 35f032012..0a2e30a9a 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 @@ -13,10 +13,14 @@ import androidx.compose.material3.RadioButtonDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag +import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource 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 @@ -33,7 +37,7 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.hoverPointerIcon * identifying the component, selected for controlling which option is selected, enabled controls if the component is * clickable and textInput displaying the option text. * @param onClick Will be called when the user clicks the button. -* + * */ @Composable fun RadioButton( diff --git a/designsystem/src/commonMain/resources/values/strings_en.xml b/designsystem/src/commonMain/resources/values/strings_en.xml index 4f5375101..2dc17b4e1 100644 --- a/designsystem/src/commonMain/resources/values/strings_en.xml +++ b/designsystem/src/commonMain/resources/values/strings_en.xml @@ -6,6 +6,8 @@ AGE OR Years + Months + Days %d error %d errors %d warning From 060fd8c8190f20846a82580f5f3e9f03e222278f Mon Sep 17 00:00:00 2001 From: = Date: Thu, 14 Sep 2023 10:48:24 +0200 Subject: [PATCH 03/11] update: [ANDROAPP-5467] code cleaned --- .../org/hisp/dhis/common/screens/RadioButtonScreen.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 405409097..24539ecf7 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 @@ -11,6 +11,7 @@ import androidx.compose.ui.Modifier 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.AgeFieldHelperValues 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 @@ -45,9 +46,9 @@ fun RadioButtonScreen() { ) 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"), + RadioButtonData("0", selected = true, enabled = true, textInput = AgeFieldHelperValues.YEARS.value), + RadioButtonData("1", selected = false, enabled = true, textInput = AgeFieldHelperValues.MONTHS.value), + RadioButtonData("2", selected = false, enabled = true, textInput = AgeFieldHelperValues.DAYS.value), ) var selectedItemVertical by remember { @@ -100,7 +101,7 @@ fun RadioButtonScreen() { selectedItemVertical = it } SubTitle("Horizontal Age Field Helper") - AgeFieldHelper(Orientation.HORIZONTAL, ageFieldHelperHorizontal, selectedFieldHorizontal) { + AgeFieldHelper(Orientation.HORIZONTAL, AgeFieldHelperValues.YEARS.value) { selectedFieldHorizontal = it } } From e57ff414a5c0c82efe6221237796fe1c39013924 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 14 Sep 2023 13:12:29 +0200 Subject: [PATCH 04/11] update: [ANDROAPP-5467] age field helper screen moved to a new file --- .../kotlin/org/hisp/dhis/common/App.kt | 5 +++- .../dhis/common/screens/AgeFieldScreen.kt | 26 +++++++++++++++++++ .../hisp/dhis/common/screens/Components.kt | 1 + .../dhis/common/screens/RadioButtonScreen.kt | 16 ------------ 4 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt index f93aa8757..a270785f2 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt @@ -23,6 +23,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import org.hisp.dhis.common.screens.BadgesScreen import org.hisp.dhis.common.screens.BottomSheetHeaderScreen +import org.hisp.dhis.common.screens.AgeFieldScreen +import org.hisp.dhis.common.screens.BottomSheetScreen import org.hisp.dhis.common.screens.ButtonBlockScreen import org.hisp.dhis.common.screens.ButtonScreen import org.hisp.dhis.common.screens.CheckboxScreen @@ -67,7 +69,7 @@ fun App() { @Composable fun Main() { - val currentScreen = remember { mutableStateOf(Components.SWITCH) } + val currentScreen = remember { mutableStateOf(Components.FORM_SHELLS) } var expanded by remember { mutableStateOf(false) } Column( @@ -139,6 +141,7 @@ fun Main() { Components.INPUT_INTEGER -> InputIntegerScreen() Components.INPUT_NUMBER -> InputNumberScreen() Components.INPUT_LETTER -> InputLetterScreen() + Components.AGE_FIELD -> AgeFieldScreen() Components.CHIPS -> ChipsScreen() Components.BADGES -> BadgesScreen() Components.SWITCH -> SwitchScreen() diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt new file mode 100644 index 000000000..005aa95ab --- /dev/null +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt @@ -0,0 +1,26 @@ +package org.hisp.dhis.common.screens + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import org.hisp.dhis.mobile.ui.designsystem.component.AgeFieldHelper +import org.hisp.dhis.mobile.ui.designsystem.component.AgeFieldHelperValues +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.RadioButtonData +import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle + +@Composable +fun AgeFieldScreen() { + ColumnComponentContainer("Age Field components") { + SubTitle("Horizontal Age Field Helper") + var selectedFieldHorizontal by remember { + mutableStateOf(RadioButtonData("0", selected = true, enabled = true, textInput = AgeFieldHelperValues.YEARS.value)) + } + AgeFieldHelper(Orientation.HORIZONTAL, AgeFieldHelperValues.YEARS.value) { + selectedFieldHorizontal = it + } + } +} diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/Components.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/Components.kt index f9b593e56..ed8ba42a5 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/Components.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/Components.kt @@ -34,4 +34,5 @@ enum class Components(val label: String) { INPUT_SEQUENTIAL("Input Sequential"), QR_CODE_BLOCK("QR Code Block"), INPUT_CHECK_BOX("Input Check Box"), + AGE_FIELD("Age Field"), } 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 24539ecf7..a38d74b2f 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 @@ -10,8 +10,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier 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.AgeFieldHelperValues 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 @@ -45,12 +43,6 @@ fun RadioButtonScreen() { RadioButtonData("3", selected = false, enabled = false, textInput = option4), ) - val ageFieldHelperHorizontal = listOf( - RadioButtonData("0", selected = true, enabled = true, textInput = AgeFieldHelperValues.YEARS.value), - RadioButtonData("1", selected = false, enabled = true, textInput = AgeFieldHelperValues.MONTHS.value), - RadioButtonData("2", selected = false, enabled = true, textInput = AgeFieldHelperValues.DAYS.value), - ) - var selectedItemVertical by remember { mutableStateOf(radioButtonDataItemsVertical[0]) } @@ -59,10 +51,6 @@ fun RadioButtonScreen() { mutableStateOf(radioButtonDataItemsHorizontal[0]) } - var selectedFieldHorizontal by remember { - mutableStateOf(ageFieldHelperHorizontal[0]) - } - ColumnComponentContainer("Radio Buttons") { SubTitle("Text Radio Button") @@ -100,9 +88,5 @@ fun RadioButtonScreen() { RadioButtonBlock(Orientation.VERTICAL, radioButtonDataItemsVertical, selectedItemVertical) { selectedItemVertical = it } - SubTitle("Horizontal Age Field Helper") - AgeFieldHelper(Orientation.HORIZONTAL, AgeFieldHelperValues.YEARS.value) { - selectedFieldHorizontal = it - } } } From 41cc36266fc80d2dbf9276afbf0c6e4c93ac5358 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 14 Sep 2023 13:30:58 +0200 Subject: [PATCH 05/11] update: [ANDROAPP-5467] age field component moved to separate file --- .../designsystem/component/AgeFieldHelper.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt new file mode 100644 index 000000000..3ce1e9d6a --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt @@ -0,0 +1,50 @@ +package org.hisp.dhis.mobile.ui.designsystem.component + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource +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 + +/** + * DHIS2 age field helper. + * + * @param orientation Controls how the radio buttons will be displayed, HORIZONTAL for rows or + * VERTICAL for columns. + * @param optionSelected controls which item is selected. + * @param onClick is a callback to notify which item has changed into the block. + */ +@Composable +fun AgeFieldHelper( + orientation: Orientation, + optionSelected: String, + onClick: (RadioButtonData) -> Unit, +) { + RowComponentContainer( + modifier = Modifier + .padding( + start = Spacing.Spacing8, + end = Spacing.Spacing8, + ) + .background(color = SurfaceColor.Surface, Shape.SmallBottom), + ) { + val options = AgeFieldHelperValues.values().map { + RadioButtonData(it.value, optionSelected == it.value, true, provideStringResource(it.value)) + } + val selectedItem = options.find { + it.selected + } + RadioButtonBlock(orientation, options, selectedItem ?: options[0]) { + onClick.invoke(it) + } + } +} + +enum class AgeFieldHelperValues(val value: String) { + YEARS("Years"), + MONTHS("Months"), + DAYS("Days"), +} \ No newline at end of file From e6a7b4b286343951903e4b5302d517dd4826d230 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 14 Sep 2023 15:33:27 +0200 Subject: [PATCH 06/11] update:[ANDROAPP-5467] screen renamed to input age screen --- common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt | 3 ++- .../kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt | 2 +- .../dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt index a270785f2..aa14f26f7 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt @@ -23,7 +23,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import org.hisp.dhis.common.screens.BadgesScreen import org.hisp.dhis.common.screens.BottomSheetHeaderScreen -import org.hisp.dhis.common.screens.AgeFieldScreen import org.hisp.dhis.common.screens.BottomSheetScreen import org.hisp.dhis.common.screens.ButtonBlockScreen import org.hisp.dhis.common.screens.ButtonScreen @@ -34,6 +33,8 @@ import org.hisp.dhis.common.screens.FormShellsScreen import org.hisp.dhis.common.screens.FormsComponentsScreen import org.hisp.dhis.common.screens.IconButtonScreen import org.hisp.dhis.common.screens.InputCheckBoxScreen +import org.hisp.dhis.common.screens.IconCardsScreen +import org.hisp.dhis.common.screens.InputAgeScreen import org.hisp.dhis.common.screens.InputIntegerScreen import org.hisp.dhis.common.screens.InputLetterScreen import org.hisp.dhis.common.screens.InputLongTextScreen diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt index 005aa95ab..22e337401 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt @@ -13,7 +13,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.RadioButtonData import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle @Composable -fun AgeFieldScreen() { +fun InputAgeScreen() { ColumnComponentContainer("Age Field components") { SubTitle("Horizontal Age Field Helper") var selectedFieldHorizontal by remember { diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt index 3ce1e9d6a..a0daf2ae4 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt @@ -47,4 +47,4 @@ enum class AgeFieldHelperValues(val value: String) { YEARS("Years"), MONTHS("Months"), DAYS("Days"), -} \ No newline at end of file +} From 1ff77392efdab81be56053540f19c2c657c1d321 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 25 Sep 2023 12:08:41 +0200 Subject: [PATCH 07/11] add: [ANDROAPP-5467] component renamed to TimeUnitSelector --- .../commonMain/kotlin/org/hisp/dhis/common/App.kt | 2 +- .../screens/{AgeFieldScreen.kt => InputAgeScreen.kt} | 8 ++++---- .../ui/designsystem/component/AgeFieldHelper.kt | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) rename common/src/commonMain/kotlin/org/hisp/dhis/common/screens/{AgeFieldScreen.kt => InputAgeScreen.kt} (74%) diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt index aa14f26f7..c4e9adef6 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt @@ -142,7 +142,7 @@ fun Main() { Components.INPUT_INTEGER -> InputIntegerScreen() Components.INPUT_NUMBER -> InputNumberScreen() Components.INPUT_LETTER -> InputLetterScreen() - Components.AGE_FIELD -> AgeFieldScreen() + Components.AGE_FIELD -> InputAgeScreen() Components.CHIPS -> ChipsScreen() Components.BADGES -> BadgesScreen() Components.SWITCH -> SwitchScreen() diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/InputAgeScreen.kt similarity index 74% rename from common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt rename to common/src/commonMain/kotlin/org/hisp/dhis/common/screens/InputAgeScreen.kt index 22e337401..0b9b6aa6d 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/AgeFieldScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/InputAgeScreen.kt @@ -5,21 +5,21 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue -import org.hisp.dhis.mobile.ui.designsystem.component.AgeFieldHelper -import org.hisp.dhis.mobile.ui.designsystem.component.AgeFieldHelperValues 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.RadioButtonData import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle +import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitSelector +import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitValues @Composable fun InputAgeScreen() { ColumnComponentContainer("Age Field components") { SubTitle("Horizontal Age Field Helper") var selectedFieldHorizontal by remember { - mutableStateOf(RadioButtonData("0", selected = true, enabled = true, textInput = AgeFieldHelperValues.YEARS.value)) + mutableStateOf(RadioButtonData("0", selected = true, enabled = true, textInput = TimeUnitValues.YEARS.value)) } - AgeFieldHelper(Orientation.HORIZONTAL, AgeFieldHelperValues.YEARS.value) { + TimeUnitSelector(Orientation.HORIZONTAL, TimeUnitValues.YEARS.value) { selectedFieldHorizontal = it } } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt index a0daf2ae4..f62bab9f3 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt @@ -18,7 +18,7 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor * @param onClick is a callback to notify which item has changed into the block. */ @Composable -fun AgeFieldHelper( +fun TimeUnitSelector( orientation: Orientation, optionSelected: String, onClick: (RadioButtonData) -> Unit, @@ -31,7 +31,7 @@ fun AgeFieldHelper( ) .background(color = SurfaceColor.Surface, Shape.SmallBottom), ) { - val options = AgeFieldHelperValues.values().map { + val options = TimeUnitValues.values().map { RadioButtonData(it.value, optionSelected == it.value, true, provideStringResource(it.value)) } val selectedItem = options.find { @@ -43,8 +43,8 @@ fun AgeFieldHelper( } } -enum class AgeFieldHelperValues(val value: String) { - YEARS("Years"), - MONTHS("Months"), - DAYS("Days"), +enum class TimeUnitValues(val value: String) { + YEARS("years"), + MONTHS("months"), + DAYS("days"), } From df5493d2d9cf62e25d8f37682b738aff7d8cdbbc Mon Sep 17 00:00:00 2001 From: = Date: Mon, 25 Sep 2023 12:57:04 +0200 Subject: [PATCH 08/11] update: [ANDROAPP-5467] padding added --- .../designsystem/component/AgeFieldHelper.kt | 4 ++-- .../ui/designsystem/component/RadioButton.kt | 21 ------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt index f62bab9f3..c769d90a6 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt @@ -25,11 +25,11 @@ fun TimeUnitSelector( ) { RowComponentContainer( modifier = Modifier + .background(color = SurfaceColor.Surface, Shape.SmallBottom) .padding( start = Spacing.Spacing8, end = Spacing.Spacing8, - ) - .background(color = SurfaceColor.Surface, Shape.SmallBottom), + ), ) { val options = TimeUnitValues.values().map { RadioButtonData(it.value, optionSelected == it.value, true, provideStringResource(it.value)) 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 0a2e30a9a..3f98c931d 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 @@ -160,27 +160,6 @@ 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, From 8940389f1ae0e1454312ce046bfafce3b6ffbbd3 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 25 Sep 2023 13:02:30 +0200 Subject: [PATCH 09/11] update:[ANDROAPP-5467] unused imports removed --- .../hisp/dhis/mobile/ui/designsystem/component/RadioButton.kt | 3 --- 1 file changed, 3 deletions(-) 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 3f98c931d..1af380676 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 @@ -13,10 +13,7 @@ import androidx.compose.material3.RadioButtonDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag From 6a4cbafce7f7a47ef654f20d9964f423ac7e78f5 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 26 Sep 2023 10:21:11 +0200 Subject: [PATCH 10/11] add: [ANDROAPP-5467] state added --- .../mobile/ui/designsystem/component/AgeFieldHelper.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt index c769d90a6..5daf918a1 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AgeFieldHelper.kt @@ -3,6 +3,10 @@ package org.hisp.dhis.mobile.ui.designsystem.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource import org.hisp.dhis.mobile.ui.designsystem.theme.Shape @@ -37,7 +41,11 @@ fun TimeUnitSelector( val selectedItem = options.find { it.selected } - RadioButtonBlock(orientation, options, selectedItem ?: options[0]) { + var currentItem by remember { + mutableStateOf(selectedItem ?: options[0]) + } + RadioButtonBlock(orientation, options, currentItem) { + currentItem = it onClick.invoke(it) } } From 23c50f710f9ecc3982feffe3ed6dd95634f09398 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 28 Sep 2023 12:52:12 +0200 Subject: [PATCH 11/11] update: [ANDROAPP-5467] Conflicts resolved --- common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt | 4 +--- .../hisp/dhis/mobile/ui/designsystem/component/RadioButton.kt | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt index c4e9adef6..4d14af648 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt @@ -23,7 +23,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import org.hisp.dhis.common.screens.BadgesScreen import org.hisp.dhis.common.screens.BottomSheetHeaderScreen -import org.hisp.dhis.common.screens.BottomSheetScreen import org.hisp.dhis.common.screens.ButtonBlockScreen import org.hisp.dhis.common.screens.ButtonScreen import org.hisp.dhis.common.screens.CheckboxScreen @@ -32,9 +31,8 @@ import org.hisp.dhis.common.screens.Components import org.hisp.dhis.common.screens.FormShellsScreen import org.hisp.dhis.common.screens.FormsComponentsScreen import org.hisp.dhis.common.screens.IconButtonScreen -import org.hisp.dhis.common.screens.InputCheckBoxScreen -import org.hisp.dhis.common.screens.IconCardsScreen import org.hisp.dhis.common.screens.InputAgeScreen +import org.hisp.dhis.common.screens.InputCheckBoxScreen import org.hisp.dhis.common.screens.InputIntegerScreen import org.hisp.dhis.common.screens.InputLetterScreen import org.hisp.dhis.common.screens.InputLongTextScreen 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 1af380676..efdf720df 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,6 +1,5 @@ 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 @@ -17,11 +16,9 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag -import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource 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