@@ -22,9 +22,9 @@ import androidx.compose.foundation.layout.Row
22
22
import androidx.compose.foundation.layout.Spacer
23
23
import androidx.compose.foundation.layout.fillMaxSize
24
24
import androidx.compose.foundation.layout.fillMaxWidth
25
+ import androidx.compose.foundation.layout.height
25
26
import androidx.compose.foundation.layout.padding
26
- import androidx.compose.foundation.layout.preferredHeight
27
- import androidx.compose.foundation.layout.preferredWidth
27
+ import androidx.compose.foundation.layout.width
28
28
import androidx.compose.foundation.layout.wrapContentSize
29
29
import androidx.compose.foundation.lazy.LazyColumn
30
30
import androidx.compose.foundation.text.KeyboardActions
@@ -45,15 +45,14 @@ import androidx.compose.material.icons.filled.ChevronLeft
45
45
import androidx.compose.material.icons.filled.Visibility
46
46
import androidx.compose.material.icons.filled.VisibilityOff
47
47
import androidx.compose.runtime.Composable
48
- import androidx.compose.runtime.Providers
48
+ import androidx.compose.runtime.CompositionLocalProvider
49
49
import androidx.compose.runtime.mutableStateOf
50
50
import androidx.compose.runtime.remember
51
51
import androidx.compose.ui.Alignment
52
52
import androidx.compose.ui.Modifier
53
53
import androidx.compose.ui.focus.FocusState
54
54
import androidx.compose.ui.focus.onFocusChanged
55
55
import androidx.compose.ui.res.stringResource
56
- import androidx.compose.ui.text.SoftwareKeyboardController
57
56
import androidx.compose.ui.text.input.ImeAction
58
57
import androidx.compose.ui.text.input.PasswordVisualTransformation
59
58
import androidx.compose.ui.text.input.VisualTransformation
@@ -70,15 +69,15 @@ fun SignInSignUpScreen(
70
69
) {
71
70
LazyColumn (modifier = modifier) {
72
71
item {
73
- Spacer (modifier = Modifier .preferredHeight (44 .dp))
72
+ Spacer (modifier = Modifier .height (44 .dp))
74
73
Box (
75
74
modifier = Modifier
76
75
.fillMaxWidth()
77
76
.padding(horizontal = 20 .dp)
78
77
) {
79
78
content()
80
79
}
81
- Spacer (modifier = Modifier .preferredHeight (16 .dp))
80
+ Spacer (modifier = Modifier .height (16 .dp))
82
81
OrSignInAsGuest (
83
82
onSignedInAsGuest = onSignedInAsGuest,
84
83
modifier = Modifier
@@ -111,7 +110,7 @@ fun SignInSignUpTopAppBar(topAppBarText: String, onBackPressed: () -> Unit) {
111
110
},
112
111
// We need to balance the navigation icon, so we add a spacer.
113
112
actions = {
114
- Spacer (modifier = Modifier .preferredWidth (68 .dp))
113
+ Spacer (modifier = Modifier .width (68 .dp))
115
114
},
116
115
backgroundColor = MaterialTheme .colors.surface,
117
116
elevation = 0 .dp
@@ -124,14 +123,13 @@ fun Email(
124
123
imeAction : ImeAction = ImeAction .Next ,
125
124
onImeAction : () -> Unit = {}
126
125
) {
127
- lateinit var softwareKeyboardController: SoftwareKeyboardController
128
126
OutlinedTextField (
129
127
value = emailState.text,
130
128
onValueChange = {
131
129
emailState.text = it
132
130
},
133
131
label = {
134
- Providers (LocalContentAlpha provides ContentAlpha .medium) {
132
+ CompositionLocalProvider (LocalContentAlpha provides ContentAlpha .medium) {
135
133
Text (
136
134
text = stringResource(id = R .string.email),
137
135
style = MaterialTheme .typography.body2
@@ -148,13 +146,11 @@ fun Email(
148
146
}
149
147
},
150
148
textStyle = MaterialTheme .typography.body2,
151
- isErrorValue = emailState.showErrors(),
152
- onTextInputStarted = { softwareKeyboardController = it },
149
+ isError = emailState.showErrors(),
153
150
keyboardOptions = KeyboardOptions .Default .copy(imeAction = imeAction),
154
151
keyboardActions = KeyboardActions (
155
152
onDone = {
156
153
onImeAction()
157
- softwareKeyboardController.hideSoftwareKeyboard()
158
154
}
159
155
)
160
156
)
@@ -170,7 +166,6 @@ fun Password(
170
166
imeAction : ImeAction = ImeAction .Done ,
171
167
onImeAction : () -> Unit = {}
172
168
) {
173
- lateinit var softwareKeyboardController: SoftwareKeyboardController
174
169
val showPassword = remember { mutableStateOf(false ) }
175
170
OutlinedTextField (
176
171
value = passwordState.text,
@@ -189,7 +184,7 @@ fun Password(
189
184
},
190
185
textStyle = MaterialTheme .typography.body2,
191
186
label = {
192
- Providers (LocalContentAlpha provides ContentAlpha .medium) {
187
+ CompositionLocalProvider (LocalContentAlpha provides ContentAlpha .medium) {
193
188
Text (
194
189
text = label,
195
190
style = MaterialTheme .typography.body2
@@ -218,13 +213,11 @@ fun Password(
218
213
} else {
219
214
PasswordVisualTransformation ()
220
215
},
221
- isErrorValue = passwordState.showErrors(),
222
- onTextInputStarted = { softwareKeyboardController = it },
216
+ isError = passwordState.showErrors(),
223
217
keyboardOptions = KeyboardOptions .Default .copy(imeAction = imeAction),
224
218
keyboardActions = KeyboardActions (
225
219
onDone = {
226
220
onImeAction()
227
- softwareKeyboardController.hideSoftwareKeyboard()
228
221
}
229
222
)
230
223
)
@@ -238,7 +231,7 @@ fun Password(
238
231
@Composable
239
232
fun TextFieldError (textError : String ) {
240
233
Row (modifier = Modifier .fillMaxWidth()) {
241
- Spacer (modifier = Modifier .preferredWidth (16 .dp))
234
+ Spacer (modifier = Modifier .width (16 .dp))
242
235
Text (
243
236
text = textError,
244
237
modifier = Modifier .fillMaxWidth(),
@@ -257,7 +250,7 @@ fun OrSignInAsGuest(
257
250
horizontalAlignment = Alignment .CenterHorizontally
258
251
) {
259
252
Surface {
260
- Providers (LocalContentAlpha provides ContentAlpha .medium) {
253
+ CompositionLocalProvider (LocalContentAlpha provides ContentAlpha .medium) {
261
254
Text (
262
255
text = stringResource(id = R .string.or ),
263
256
style = MaterialTheme .typography.subtitle2
0 commit comments