Skip to content

Commit

Permalink
add supporting text as input phone number param, make state not nulla…
Browse files Browse the repository at this point in the history
…ble for input shell and basic text input
  • Loading branch information
xavimolloy committed Oct 6, 2023
1 parent 56580e0 commit 42cb738
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import java.util.Locale
@Composable
internal fun BasicTextInput(
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 @@ -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
Expand Down Expand Up @@ -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<SupportingTextData>? = 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -60,7 +63,7 @@ fun InputQRCode(
enabled = true,
icon = {
Icon(
imageVector = Icons.Outlined.QrCode2,
imageVector = actionButtonIconVector.value,
contentDescription = null,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 42cb738

Please sign in to comment.