Skip to content

Commit

Permalink
make state not nullable for input components
Browse files Browse the repository at this point in the history
  • Loading branch information
xavimolloy committed Oct 6, 2023
1 parent 42cb738 commit d9f60d4
Show file tree
Hide file tree
Showing 59 changed files with 184 additions and 27 deletions.
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 @@ -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
Expand Up @@ -31,6 +31,7 @@ fun InputPercentageScreen() {
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 InputPhoneNumberScreen() {
// no-op
},
onFocusChanged = {},
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 InputPositiveIntegerOrZeroScreen() {
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 InputPositiveIntegerScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))
SubTitle("Basic Input Integer with error", textColor = TextColor.OnSurfaceVariant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fun InputRadioButtonScreen() {
onItemChange = {
selectedItemVertical = it
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))
InputRadioButton(
Expand Down Expand Up @@ -106,6 +107,7 @@ fun InputRadioButtonScreen() {
onItemChange = {
selectedItemHorizontal = it
},
state = InputShellState.UNFOCUSED,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fun InputSequentialScreen() {
newSelectedItem
}
},
state = InputShellState.UNFOCUSED,
)

InputSequential(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fun InputTextScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))
SubTitle("Input text with error ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fun InputYesNoFieldScreen() {
onItemChange = {
selectedItem = it
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))
InputYesNoField(
Expand All @@ -45,6 +46,7 @@ fun InputYesNoFieldScreen() {
onItemChange = {
selectedItem1 = it
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))
InputYesNoField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@ fun InputYesOnlyCheckBoxScreen() {
var checkboxData2 by rememberSaveable {
mutableStateOf(CheckBoxData(uid = "0", checked = false, enabled = true, textInput = "Label"))
}
var checkboxData3 by rememberSaveable {
val checkboxData3 by rememberSaveable {
mutableStateOf(CheckBoxData(uid = "0", checked = false, enabled = true, textInput = "Label"))
}
var checkboxData4 by rememberSaveable {
val checkboxData4 by rememberSaveable {
mutableStateOf(CheckBoxData(uid = "0", checked = true, enabled = true, textInput = "Label"))
}
InputYesOnlyCheckBox(
checkBoxData = checkboxData,
state = InputShellState.UNFOCUSED,
) {
checkboxData = checkboxData.copy(checked = !checkboxData.checked)
}
Spacer(Modifier.size(Spacing.Spacing18))
InputYesOnlyCheckBox(
checkBoxData = checkboxData1,
state = InputShellState.UNFOCUSED,
) {
checkboxData1 = checkboxData1.copy(checked = !checkboxData.checked)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ fun InputYesOnlySwitchScreen() {
InputYesOnlySwitch(
title = "Label",
isChecked = isSelected,
state = InputShellState.UNFOCUSED,
) {
isSelected = !isSelected
}
Spacer(Modifier.size(Spacing.Spacing18))
InputYesOnlySwitch(
title = "Label",
isChecked = isSelected1,
state = InputShellState.UNFOCUSED,
) {
isSelected1 = !isSelected1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.hisp.dhis.common.screens.previews.lorem
import org.hisp.dhis.common.screens.previews.lorem_medium
import org.hisp.dhis.common.screens.previews.lorem_short
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.InputText
import org.hisp.dhis.mobile.ui.designsystem.component.Section
import org.hisp.dhis.mobile.ui.designsystem.component.SectionState
Expand Down Expand Up @@ -162,15 +163,18 @@ private fun TestingFields() {
title = "Label",
inputText = inputValue1,
onValueChanged = { inputValue1 = it ?: "" },
state = InputShellState.UNFOCUSED,
)
InputText(
title = "Label",
inputText = inputValue2,
onValueChanged = { inputValue2 = it ?: "" },
state = InputShellState.UNFOCUSED,
)
InputText(
title = "Label",
inputText = inputValue3,
onValueChanged = { inputValue3 = it ?: "" },
state = InputShellState.UNFOCUSED,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun InputCheckBox(
checkBoxData: List<CheckBoxData>,
modifier: Modifier = Modifier,
orientation: Orientation = Orientation.VERTICAL,
state: InputShellState = InputShellState.UNFOCUSED,
state: InputShellState,
supportingText: List<SupportingTextData>? = null,
legendData: LegendData? = null,
isRequired: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations
@Composable
fun InputEmail(
title: String,
state: InputShellState = InputShellState.UNFOCUSED,
state: InputShellState,
supportingText: List<SupportingTextData>? = null,
legendData: LegendData? = null,
inputText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations
@Composable
fun InputInteger(
title: String,
state: InputShellState = InputShellState.UNFOCUSED,
state: InputShellState,
supportingText: List<SupportingTextData>? = null,
legendData: LegendData? = null,
inputText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations
@Composable
fun InputLetter(
title: String,
state: InputShellState = InputShellState.UNFOCUSED,
state: InputShellState,
supportingText: List<SupportingTextData>? = null,
legendData: LegendData? = null,
inputText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations
@Composable
fun InputLink(
title: String,
state: InputShellState = InputShellState.UNFOCUSED,
state: InputShellState,
supportingText: List<SupportingTextData>? = null,
legendData: LegendData? = null,
inputText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
@Composable
fun InputLongText(
title: String,
state: InputShellState = InputShellState.UNFOCUSED,
state: InputShellState,
supportingText: List<SupportingTextData>? = null,
legendData: LegendData? = null,
inputText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState.UNFOCUSED
import org.hisp.dhis.mobile.ui.designsystem.component.internal.IconCard
import org.hisp.dhis.mobile.ui.designsystem.component.internal.IconCardData
import org.hisp.dhis.mobile.ui.designsystem.component.internal.VerticalGrid
Expand Down Expand Up @@ -42,7 +41,7 @@ fun InputMatrix(
itemCount: Int = 2,
selectedData: IconCardData? = null,
modifier: Modifier = Modifier,
state: InputShellState = UNFOCUSED,
state: InputShellState,
supportingText: List<SupportingTextData>? = null,
legendData: LegendData? = null,
isRequired: Boolean = false,
Expand Down
Loading

0 comments on commit d9f60d4

Please sign in to comment.