Jaime
10/07/2022, 10:14 PMJaime
10/07/2022, 10:16 PMJaime
10/07/2022, 10:17 PMitemsIndexed(items = answer.sections) { index, section ->
val textFieldState: TextFieldState =
rendering.formState.getState(section.id)
when (section.type) {
TYPE_TEXT -> {
OutlinedTextField(
maxLines = 1,
value = textFieldState.value,
onValueChange = {
textFieldState.change(it)
},
label = {
CompositionLocalProvider(
LocalContentAlpha provides ContentAlpha.medium
) {
Text(
text = lokaliseResource(lokaliseKey = section.hint),
color = HapiTheme.colors.textPrimary,
style = bodyRegularL,
textAlign = TextAlign.Center
)
}
},
modifier = Modifier
.fillMaxWidth()
.padding(
PaddingValues(
start = 30.dp,
end = 30.dp,
top = 10.dp
),
),
textStyle = TextStyle(
color = colors.textPrimary,
fontFamily = bodyRegularL.fontFamily,
fontWeight = bodyRegularL.fontWeight,
fontSize = bodyRegularL.fontSize
),
isError = textFieldState.hasError,
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = if (index == answer.sections.size - 1)
ImeAction.Done else ImeAction.Next,
capitalization = KeyboardCapitalization.None
),
keyboardActions = KeyboardActions(
onDone = {
}
),
colors = TextFieldDefaults.outlinedTextFieldColors(
backgroundColor = colors.textFieldBackground,
focusedBorderColor = violet2Hapi,
unfocusedBorderColor = darkGreyVioletHapi,
disabledBorderColor = gray3Hapi,
errorBorderColor = if (textFieldState.hasError) {
colors.error
} else {
colors.textLink
},
cursorColor = darkGrey1Hapi,
errorCursorColor = darkGrey1Hapi,
focusedLabelColor = violet2Hapi
),
shape = RoundedCornerShape(12.dp),
enabled = true,
)
}
}
}
Zach Klippenstein (he/him) [MOD]
10/07/2022, 10:22 PMJaime
10/07/2022, 10:23 PMJaime
10/07/2022, 10:23 PM