Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix date format for InputAge component #298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,96 @@ 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")
SubTitle("Input Age Component - Invalid Date Of Birth")
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.DateOfBirth(
TextFieldValue("01011985"),
),
siddh1004 marked this conversation as resolved.
Show resolved Hide resolved
state = InputShellState.DISABLED,
onValueChanged = {
},
inputState = InputShellState.DISABLED,
),
onValueChanged = {
},
)

SubTitle("Input Age Component - Date Of Birth")
InputAge(
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.DateOfBirth(
TextFieldValue("1991-11-27"),
),
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
Loading