Skip to content

Commit

Permalink
Merge branch 'main' into ANDROAPP-5575-mobile-ui-Create-InputFileReso…
Browse files Browse the repository at this point in the history
…urce-component
  • Loading branch information
DavidAparicioAlbaAsenjo authored Oct 10, 2023
2 parents 39225c5 + dd42d28 commit 3b477be
Show file tree
Hide file tree
Showing 75 changed files with 1,149 additions and 56 deletions.
2 changes: 2 additions & 0 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import org.hisp.dhis.common.screens.InputLongTextScreen
import org.hisp.dhis.common.screens.InputMatrixScreen
import org.hisp.dhis.common.screens.InputNegativeIntegerScreen
import org.hisp.dhis.common.screens.InputNumberScreen
import org.hisp.dhis.common.screens.InputOrgUnitScreen
import org.hisp.dhis.common.screens.InputPercentageScreen
import org.hisp.dhis.common.screens.InputPhoneNumberScreen
import org.hisp.dhis.common.screens.InputPositiveIntegerOrZeroScreen
Expand Down Expand Up @@ -171,6 +172,7 @@ fun Main() {
Components.INPUT_EMAIL -> InputEmailScreen()
Components.CAROUSEL_BUTTONS -> ButtonCarouselScreen()
Components.INPUT_FILE_RESOURCE -> InputFileResourceScreen()
Components.INPUT_ORG_UNIT -> InputOrgUnitScreen()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ enum class Components(val label: String) {
INPUT_EMAIL("Input Email"),
CAROUSEL_BUTTONS("Carousel buttons"),
INPUT_FILE_RESOURCE("Input File Resource"),
INPUT_ORG_UNIT("Input Org. Unit"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fun FormShellsScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -52,7 +53,7 @@ fun FormShellsScreen() {
inputValue2 = it
}
},

state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down Expand Up @@ -124,6 +125,7 @@ fun FormShellsScreen() {
inputValue7 = it
}
},
state = InputShellState.ERROR,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down Expand Up @@ -159,6 +161,7 @@ fun FormShellsScreen() {
inputValue9 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -178,6 +181,8 @@ fun FormShellsScreen() {
inputValue10 = it
}
},
state = InputShellState.UNFOCUSED,

)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down Expand Up @@ -263,6 +268,7 @@ fun FormShellsScreen() {
inputValue14 = it
}
},
state = InputShellState.UNFOCUSED,
)

var inputValue15 by rememberSaveable { mutableStateOf("Input") }
Expand All @@ -275,6 +281,7 @@ fun FormShellsScreen() {
inputValue15 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -296,6 +303,7 @@ fun FormShellsScreen() {
inputValue16 = it
}
},
state = InputShellState.UNFOCUSED,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ 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.AgeInputType
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputAge
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
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
Expand All @@ -14,13 +17,94 @@ import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitValues

@Composable
fun InputAgeScreen() {
ColumnComponentContainer("Age Field components") {
ColumnComponentContainer {
SubTitle("Horizontal Age Field Helper")
var selectedFieldHorizontal by remember {
mutableStateOf(RadioButtonData("0", selected = true, enabled = true, textInput = TimeUnitValues.YEARS.value))
}
TimeUnitSelector(Orientation.HORIZONTAL, TimeUnitValues.YEARS.value) {
selectedFieldHorizontal = it
}

SubTitle("Input Age Component - Idle")
var inputType by remember { mutableStateOf<AgeInputType>(AgeInputType.None) }

InputAge(
title = "Label",
inputType = inputType,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Idle Disabled")
InputAge(
title = "Label",
inputType = AgeInputType.None,
state = InputShellState.DISABLED,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Date Of Birth")
InputAge(
title = "Label",
inputType = AgeInputType.DateOfBirth("01011985"),
state = InputShellState.DISABLED,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Date Of Birth Required Error")
InputAge(
title = "Label",
inputType = AgeInputType.DateOfBirth("010"),
state = InputShellState.ERROR,
isRequired = true,
onCalendarActionClicked = {
// no-op
},
onValueChanged = {
// no-op
},
)

SubTitle("Input Age Component - Age Disabled")
InputAge(
title = "Label",
inputType = AgeInputType.Age(value = "56", unit = TimeUnitValues.YEARS),
state = InputShellState.DISABLED,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Age Required Error")
InputAge(
title = "Label",
inputType = AgeInputType.Age(value = "56", unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,
onCalendarActionClicked = {
// no-op
},
onValueChanged = {
// no-op
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fun InputCheckBoxScreen() {
checkBoxDataItemsVertical[index] = checkBoxData.copy(checked = !checkBoxData.checked)
},
onClearSelection = { checkBoxDataItemsVertical.replaceAll { it.copy(checked = false) } },
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))
InputCheckBox(
Expand Down Expand Up @@ -99,6 +100,7 @@ fun InputCheckBoxScreen() {
checkBoxDataItemsHorizontal[index] = checkBoxData.copy(checked = !checkBoxData.checked)
},
onClearSelection = { checkBoxDataItemsHorizontal.replaceAll { it.copy(checked = false) } },
state = InputShellState.UNFOCUSED,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun InputEmailScreen() {
}
},
onEmailActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -51,6 +52,7 @@ fun InputEmailScreen() {
}
},
onEmailActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun InputIntegerScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun InputLetterScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun InputLinkScreen() {
}
},
onLinkActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -51,6 +52,7 @@ fun InputLinkScreen() {
}
},
onLinkActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -67,6 +69,7 @@ fun InputLinkScreen() {
}
},
onLinkActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fun InputLongTextScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fun InputMatrixScreen() {
newSelectedItem
}
},
state = InputShellState.UNFOCUSED,
)

InputMatrix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun InputNegativeIntegerScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fun InputNumberScreen() {
}
},
notation = RegExValidations.BRITISH_DECIMAL_NOTATION,
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -49,6 +50,7 @@ fun InputNumberScreen() {
}
},
notation = RegExValidations.EUROPEAN_DECIMAL_NOTATION,
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.hisp.dhis.common.screens

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputOrgUnit
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextData
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextState
import org.hisp.dhis.mobile.ui.designsystem.component.Title
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

@Composable
fun InputOrgUnitScreen() {
ColumnComponentContainer {
Title("Input Org. unit component", textColor = TextColor.OnSurfaceVariant)
SubTitle("Basic Org. unit ", textColor = TextColor.OnSurfaceVariant)
var inputText1 by rememberSaveable { mutableStateOf("") }

InputOrgUnit(
title = "Label",
inputText = inputText1,
onValueChanged = {
if (it != null) {
inputText1 = it
}
},
onOrgUnitActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Basic Org. unit with content ", textColor = TextColor.OnSurfaceVariant)
var inputText2 by rememberSaveable { mutableStateOf("PHC Fakename") }

InputOrgUnit(
title = "Label",
inputText = inputText2,
onValueChanged = {
if (it != null) {
inputText2 = it
}
},
onOrgUnitActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Error Org. unit required field ", textColor = TextColor.OnSurfaceVariant)
var inputText3 by rememberSaveable { mutableStateOf("") }

InputOrgUnit(
title = "Label",
state = InputShellState.ERROR,
supportingText = listOf(SupportingTextData("Required", SupportingTextState.ERROR)),
inputText = inputText3,
isRequiredField = true,
onValueChanged = {
if (it != null) {
inputText3 = it
}
},
onOrgUnitActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Disabled Org. unit with content ", textColor = TextColor.OnSurfaceVariant)
var inputText5 by rememberSaveable { mutableStateOf("PHC Fakename") }
InputOrgUnit(
title = "Label",
state = InputShellState.DISABLED,
inputText = inputText5,
onValueChanged = {
if (it != null) {
inputText5 = it
}
},
onOrgUnitActionCLicked = {},
)
}
}
Loading

0 comments on commit 3b477be

Please sign in to comment.