File tree 2 files changed +9
-2
lines changed
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ fun SignInContent(
136
136
Button (
137
137
onClick = { onSignInSubmitted(emailState.text, passwordState.text) },
138
138
modifier = Modifier .fillMaxWidth().padding(vertical = 16 .dp),
139
- enabled = emailState.isValid
139
+ enabled = emailState.isValid && passwordState.isValid
140
140
) {
141
141
Text (
142
142
text = stringResource(id = R .string.sign_in)
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ fun Email(
145
145
emailState.getError()?.let { error -> TextFieldError (textError = error) }
146
146
}
147
147
148
+ @OptIn(ExperimentalFocus ::class )
148
149
@Composable
149
150
fun Password (
150
151
label : String ,
@@ -160,7 +161,13 @@ fun Password(
160
161
passwordState.text = it
161
162
passwordState.enableShowErrors()
162
163
},
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
+ },
164
171
textStyle = MaterialTheme .typography.body2,
165
172
label = {
166
173
ProvideEmphasis (emphasis = EmphasisAmbient .current.medium) {
You can’t perform that action at this time.
0 commit comments