From 42cb738b0159428f711b37a16483578b9d99a18f Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Fri, 6 Oct 2023 08:15:56 +0200 Subject: [PATCH] add supporting text as input phone number param, make state not nullable for input shell and basic text input --- .../ui/designsystem/component/BasicTextInput.kt | 2 +- .../ui/designsystem/component/InputPhoneNumber.kt | 14 +------------- .../ui/designsystem/component/InputQRCode.kt | 5 ++++- .../mobile/ui/designsystem/component/InputShell.kt | 2 +- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt index 8d25bc8ce..55be3eb6f 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt @@ -39,7 +39,7 @@ import java.util.Locale @Composable internal fun BasicTextInput( title: String, - state: InputShellState = InputShellState.UNFOCUSED, + state: InputShellState, supportingText: List? = null, legendData: LegendData? = null, inputText: String? = null, diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt index ea75698f2..8d2aa97a9 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt @@ -10,7 +10,6 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations -import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource /** * DHIS2 Input Phone Number @@ -43,20 +42,9 @@ fun InputPhoneNumber( onValueChanged: ((String?) -> Unit)? = null, onFocusChanged: ((Boolean) -> Unit) = {}, imeAction: ImeAction = ImeAction.Next, - errorMessage: String = provideStringResource("enter_phone_number"), + supportingText: List? = emptyList(), allowedCharacters: RegExValidations = RegExValidations.PHONE_NUMBER, ) { - val supportingText = if (state == InputShellState.ERROR) { - listOf( - SupportingTextData( - text = errorMessage, - state = SupportingTextState.ERROR, - ), - ) - } else { - emptyList() - } - BasicTextInput( title = title, state = state, diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputQRCode.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputQRCode.kt index 3edd753e8..7d3b626b7 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputQRCode.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputQRCode.kt @@ -3,8 +3,10 @@ package org.hisp.dhis.mobile.ui.designsystem.component import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.QrCode2 +import androidx.compose.material.icons.outlined.QrCodeScanner import androidx.compose.material3.Icon import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.input.ImeAction @@ -41,6 +43,7 @@ fun InputQRCode( imeAction: ImeAction = ImeAction.Next, modifier: Modifier = Modifier, ) { + val actionButtonIconVector = mutableStateOf(if (!inputText.isNullOrEmpty()) Icons.Outlined.QrCode2 else Icons.Outlined.QrCodeScanner) BasicTextInput( title = title, state = state, @@ -60,7 +63,7 @@ fun InputQRCode( enabled = true, icon = { Icon( - imageVector = Icons.Outlined.QrCode2, + imageVector = actionButtonIconVector.value, contentDescription = null, ) }, diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputShell.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputShell.kt index 292bebf92..149e30907 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputShell.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputShell.kt @@ -47,7 +47,7 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor @Composable fun InputShell( title: String, - state: InputShellState = InputShellState.UNFOCUSED, + state: InputShellState, primaryButton: @Composable (() -> Unit)? = null, secondaryButton: @Composable (() -> Unit)? = null, inputField: @Composable (() -> Unit)? = null,