Skip to content

Commit

Permalink
Fix date time format for InputAge component
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Sep 11, 2024
1 parent ec6f196 commit 790419b
Show file tree
Hide file tree
Showing 8 changed files with 645 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ 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.ColumnScreenContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputAge
import org.hisp.dhis.mobile.ui.designsystem.component.InputAgeModel
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.LegendData
import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitValues
import org.hisp.dhis.mobile.ui.designsystem.component.state.InputAgeData
import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberInputAgeState
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor

@Composable
Expand All @@ -24,100 +25,108 @@ fun InputAgeScreen() {

ColumnComponentContainer("Input Age Component - Idle") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = inputType,
onValueChanged = { newInputType ->
inputType = newInputType
},
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Idle Disabled") {
InputAge(
InputAgeModel(
title = "Label",
inputType = AgeInputType.None,
state = InputShellState.DISABLED,
onValueChanged = { newInputType ->
inputType = newInputType
},
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputState = InputShellState.DISABLED,
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Date Of Birth") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.DateOfBirth(TextFieldValue("01011985")),
state = InputShellState.DISABLED,

onValueChanged = { newInputType ->
inputType = newInputType
},
inputState = InputShellState.DISABLED,
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Date Of Birth Required Error") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
isRequired = true,
),
inputType = AgeInputType.DateOfBirth(TextFieldValue("010")),
state = InputShellState.ERROR,
isRequired = true,

onValueChanged = {
// no-op
},
inputState = InputShellState.ERROR,
),
onValueChanged = {
// no-op
},
)
}

ColumnComponentContainer("Input Age Component - Age Disabled") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.DISABLED,

onValueChanged = { newInputType ->
inputType = newInputType
},
inputState = InputShellState.DISABLED,
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Age Required Error") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
isRequired = true,
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,

onValueChanged = {
// no-op
},
inputState = InputShellState.ERROR,
),
onValueChanged = {
// no-op
},
)
}

ColumnComponentContainer("Input Age Component - Legend") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
isRequired = true,
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,

onValueChanged = {
// no-op
},
inputState = InputShellState.ERROR,
legendData = LegendData(SurfaceColor.CustomGreen, "Legend", popUpLegendDescriptionData = regularLegendList),
),
onValueChanged = {
// no-op
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer
import org.hisp.dhis.mobile.ui.designsystem.component.DateTimeActionType
import org.hisp.dhis.mobile.ui.designsystem.component.DropdownItem
import org.hisp.dhis.mobile.ui.designsystem.component.InputAge
import org.hisp.dhis.mobile.ui.designsystem.component.InputAgeModel
import org.hisp.dhis.mobile.ui.designsystem.component.InputBarCode
import org.hisp.dhis.mobile.ui.designsystem.component.InputCheckBox
import org.hisp.dhis.mobile.ui.designsystem.component.InputDateTime
Expand All @@ -43,7 +42,9 @@ import org.hisp.dhis.mobile.ui.designsystem.component.parameter.model.ParameterS
import org.hisp.dhis.mobile.ui.designsystem.component.parameter.model.ParameterSelectorItemModel.Status.CLOSED
import org.hisp.dhis.mobile.ui.designsystem.component.parameter.model.ParameterSelectorItemModel.Status.FOCUSED
import org.hisp.dhis.mobile.ui.designsystem.component.parameter.model.ParameterSelectorItemModel.Status.UNFOCUSED
import org.hisp.dhis.mobile.ui.designsystem.component.state.InputAgeData
import org.hisp.dhis.mobile.ui.designsystem.component.state.InputDateTimeData
import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberInputAgeState
import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberInputDateTimeState
import org.hisp.dhis.mobile.ui.designsystem.resource.provideDHIS2Icon
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
Expand Down Expand Up @@ -134,14 +135,16 @@ fun ParameterSelectorScreen() {
helper = "Optional",
inputField = {
InputAge(
InputAgeModel(
title = "Age parameter",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Age parameter",
inputStyle = InputStyle.ParameterInputStyle(),
),
inputType = ageInputType,
inputStyle = InputStyle.ParameterInputStyle(),
onValueChanged = {
ageInputType = it
},
),
onValueChanged = {
ageInputType = it ?: AgeInputType.None
},
)
},
status = when (ageInputType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import androidx.compose.ui.text.input.TextFieldValue
import org.hisp.dhis.mobile.ui.designsystem.component.AgeInputType
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputAge
import org.hisp.dhis.mobile.ui.designsystem.component.InputAgeModel
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.TimeUnitValues
import org.hisp.dhis.mobile.ui.designsystem.component.state.InputAgeData
import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberInputAgeState
import org.junit.Rule
import org.junit.Test

Expand All @@ -22,74 +23,81 @@ class InputAgeSnapshotTest {
ColumnScreenContainer {
SubTitle("Input Age Component - Idle")
InputAge(
InputAgeModel(
title = "Label",
inputType = AgeInputType.None,

onValueChanged = {
},
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
),
onValueChanged = {
},
)

SubTitle("Input Age Component - Idle Disabled")
InputAge(
InputAgeModel(
title = "Label",
inputType = AgeInputType.None,
state = InputShellState.DISABLED,
onValueChanged = {
},
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputState = InputShellState.DISABLED,
),
onValueChanged = {
},
)

SubTitle("Input Age Component - Date Of Birth")
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.DateOfBirth(
TextFieldValue("01011985"),
),
state = InputShellState.DISABLED,
onValueChanged = {
},
inputState = InputShellState.DISABLED,
),
onValueChanged = {
},
)

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

SubTitle("Input Age Component - Age Disabled")
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.DISABLED,
onValueChanged = {
},
inputState = InputShellState.DISABLED,
),
onValueChanged = {
},
)

SubTitle("Input Age Component - Age Required Error")
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,
onValueChanged = {
// no-op
},
inputState = InputShellState.ERROR,
),
onValueChanged = {
},
)
}
}
Expand Down
Loading

0 comments on commit 790419b

Please sign in to comment.