Skip to content

Commit aca46a3

Browse files
authoredSep 22, 2020
Merge pull request android#186 from android/fm/pass_validation
[Jetsurvey] Password validation errors fixed
2 parents 7293cdc + b5d306a commit aca46a3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInScreen.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fun SignInContent(
136136
Button(
137137
onClick = { onSignInSubmitted(emailState.text, passwordState.text) },
138138
modifier = Modifier.fillMaxWidth().padding(vertical = 16.dp),
139-
enabled = emailState.isValid
139+
enabled = emailState.isValid && passwordState.isValid
140140
) {
141141
Text(
142142
text = stringResource(id = R.string.sign_in)

‎Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ fun Email(
145145
emailState.getError()?.let { error -> TextFieldError(textError = error) }
146146
}
147147

148+
@OptIn(ExperimentalFocus::class)
148149
@Composable
149150
fun Password(
150151
label: String,
@@ -160,7 +161,13 @@ fun Password(
160161
passwordState.text = it
161162
passwordState.enableShowErrors()
162163
},
163-
modifier = modifier.fillMaxWidth(),
164+
modifier = modifier.fillMaxWidth().focusObserver { focusState ->
165+
val focused = focusState == FocusState.Active
166+
passwordState.onFocusChange(focused)
167+
if (!focused) {
168+
passwordState.enableShowErrors()
169+
}
170+
},
164171
textStyle = MaterialTheme.typography.body2,
165172
label = {
166173
ProvideEmphasis(emphasis = EmphasisAmbient.current.medium) {

0 commit comments

Comments
 (0)
Please sign in to comment.