Skip to content

Commit 4212a1c

Browse files
authoredFeb 23, 2021
Merge pull request android#398 from android/fm/jetsurvey_beta01
[Jetsurvey] Update to beta01 snapshot
2 parents 66fa1da + 5ecde53 commit 4212a1c

File tree

10 files changed

+78
-127
lines changed

10 files changed

+78
-127
lines changed
 

‎Jetsurvey/app/build.gradle

-10
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,4 @@ dependencies {
113113
implementation Libs.AndroidX.Compose.runtimeLivedata
114114

115115
implementation Libs.Accompanist.coil
116-
117-
// FIXME: only needed for Compose alpha12
118-
androidTestImplementation Libs.AndroidX.Activity.activityCompose
119-
120-
androidTestImplementation Libs.junit
121-
androidTestImplementation Libs.AndroidX.Test.core
122-
androidTestImplementation Libs.AndroidX.Test.espressoCore
123-
androidTestImplementation Libs.AndroidX.Test.rules
124-
androidTestImplementation Libs.AndroidX.Test.Ext.junit
125-
androidTestImplementation Libs.AndroidX.Compose.uiTest
126116
}

‎Jetsurvey/app/src/androidTest/java/com/example/compose/jetsurvey/ExampleInstrumentedTest.kt

-38
This file was deleted.

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import androidx.compose.foundation.layout.Column
2121
import androidx.compose.foundation.layout.Spacer
2222
import androidx.compose.foundation.layout.fillMaxSize
2323
import androidx.compose.foundation.layout.fillMaxWidth
24+
import androidx.compose.foundation.layout.height
2425
import androidx.compose.foundation.layout.padding
25-
import androidx.compose.foundation.layout.preferredHeight
2626
import androidx.compose.foundation.layout.wrapContentHeight
2727
import androidx.compose.material.Button
2828
import androidx.compose.material.ExperimentalMaterialApi
@@ -72,7 +72,7 @@ fun SignIn(onNavigationEvent: (SignInEvent) -> Unit) {
7272
onBackPressed = { onNavigationEvent(SignInEvent.NavigateBack) }
7373
)
7474
},
75-
bodyContent = {
75+
content = {
7676
SignInSignUpScreen(
7777
onSignedInAsGuest = { onNavigationEvent(SignInEvent.SignInAsGuest) },
7878
modifier = Modifier.fillMaxWidth()
@@ -83,7 +83,7 @@ fun SignIn(onNavigationEvent: (SignInEvent) -> Unit) {
8383
onNavigationEvent(SignInEvent.SignIn(email, password))
8484
}
8585
)
86-
Spacer(modifier = Modifier.preferredHeight(16.dp))
86+
Spacer(modifier = Modifier.height(16.dp))
8787
TextButton(
8888
onClick = {
8989
scope.launch {
@@ -120,7 +120,7 @@ fun SignInContent(
120120
val emailState = remember { EmailState() }
121121
Email(emailState, onImeAction = { focusRequester.requestFocus() })
122122

123-
Spacer(modifier = Modifier.preferredHeight(16.dp))
123+
Spacer(modifier = Modifier.height(16.dp))
124124

125125
val passwordState = remember { PasswordState() }
126126
Password(
@@ -129,7 +129,7 @@ fun SignInContent(
129129
modifier = Modifier.focusRequester(focusRequester),
130130
onImeAction = { onSignInSubmitted(emailState.text, passwordState.text) }
131131
)
132-
Spacer(modifier = Modifier.preferredHeight(16.dp))
132+
Spacer(modifier = Modifier.height(16.dp))
133133
Button(
134134
onClick = { onSignInSubmitted(emailState.text, passwordState.text) },
135135
modifier = Modifier
@@ -156,7 +156,7 @@ fun ErrorSnackbar(
156156
snackbar = { data ->
157157
Snackbar(
158158
modifier = Modifier.padding(16.dp),
159-
text = {
159+
content = {
160160
Text(
161161
text = data.message,
162162
style = MaterialTheme.typography.body2

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

+12-19
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import androidx.compose.foundation.layout.Row
2222
import androidx.compose.foundation.layout.Spacer
2323
import androidx.compose.foundation.layout.fillMaxSize
2424
import androidx.compose.foundation.layout.fillMaxWidth
25+
import androidx.compose.foundation.layout.height
2526
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
2828
import androidx.compose.foundation.layout.wrapContentSize
2929
import androidx.compose.foundation.lazy.LazyColumn
3030
import androidx.compose.foundation.text.KeyboardActions
@@ -45,15 +45,14 @@ import androidx.compose.material.icons.filled.ChevronLeft
4545
import androidx.compose.material.icons.filled.Visibility
4646
import androidx.compose.material.icons.filled.VisibilityOff
4747
import androidx.compose.runtime.Composable
48-
import androidx.compose.runtime.Providers
48+
import androidx.compose.runtime.CompositionLocalProvider
4949
import androidx.compose.runtime.mutableStateOf
5050
import androidx.compose.runtime.remember
5151
import androidx.compose.ui.Alignment
5252
import androidx.compose.ui.Modifier
5353
import androidx.compose.ui.focus.FocusState
5454
import androidx.compose.ui.focus.onFocusChanged
5555
import androidx.compose.ui.res.stringResource
56-
import androidx.compose.ui.text.SoftwareKeyboardController
5756
import androidx.compose.ui.text.input.ImeAction
5857
import androidx.compose.ui.text.input.PasswordVisualTransformation
5958
import androidx.compose.ui.text.input.VisualTransformation
@@ -70,15 +69,15 @@ fun SignInSignUpScreen(
7069
) {
7170
LazyColumn(modifier = modifier) {
7271
item {
73-
Spacer(modifier = Modifier.preferredHeight(44.dp))
72+
Spacer(modifier = Modifier.height(44.dp))
7473
Box(
7574
modifier = Modifier
7675
.fillMaxWidth()
7776
.padding(horizontal = 20.dp)
7877
) {
7978
content()
8079
}
81-
Spacer(modifier = Modifier.preferredHeight(16.dp))
80+
Spacer(modifier = Modifier.height(16.dp))
8281
OrSignInAsGuest(
8382
onSignedInAsGuest = onSignedInAsGuest,
8483
modifier = Modifier
@@ -111,7 +110,7 @@ fun SignInSignUpTopAppBar(topAppBarText: String, onBackPressed: () -> Unit) {
111110
},
112111
// We need to balance the navigation icon, so we add a spacer.
113112
actions = {
114-
Spacer(modifier = Modifier.preferredWidth(68.dp))
113+
Spacer(modifier = Modifier.width(68.dp))
115114
},
116115
backgroundColor = MaterialTheme.colors.surface,
117116
elevation = 0.dp
@@ -124,14 +123,13 @@ fun Email(
124123
imeAction: ImeAction = ImeAction.Next,
125124
onImeAction: () -> Unit = {}
126125
) {
127-
lateinit var softwareKeyboardController: SoftwareKeyboardController
128126
OutlinedTextField(
129127
value = emailState.text,
130128
onValueChange = {
131129
emailState.text = it
132130
},
133131
label = {
134-
Providers(LocalContentAlpha provides ContentAlpha.medium) {
132+
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
135133
Text(
136134
text = stringResource(id = R.string.email),
137135
style = MaterialTheme.typography.body2
@@ -148,13 +146,11 @@ fun Email(
148146
}
149147
},
150148
textStyle = MaterialTheme.typography.body2,
151-
isErrorValue = emailState.showErrors(),
152-
onTextInputStarted = { softwareKeyboardController = it },
149+
isError = emailState.showErrors(),
153150
keyboardOptions = KeyboardOptions.Default.copy(imeAction = imeAction),
154151
keyboardActions = KeyboardActions(
155152
onDone = {
156153
onImeAction()
157-
softwareKeyboardController.hideSoftwareKeyboard()
158154
}
159155
)
160156
)
@@ -170,7 +166,6 @@ fun Password(
170166
imeAction: ImeAction = ImeAction.Done,
171167
onImeAction: () -> Unit = {}
172168
) {
173-
lateinit var softwareKeyboardController: SoftwareKeyboardController
174169
val showPassword = remember { mutableStateOf(false) }
175170
OutlinedTextField(
176171
value = passwordState.text,
@@ -189,7 +184,7 @@ fun Password(
189184
},
190185
textStyle = MaterialTheme.typography.body2,
191186
label = {
192-
Providers(LocalContentAlpha provides ContentAlpha.medium) {
187+
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
193188
Text(
194189
text = label,
195190
style = MaterialTheme.typography.body2
@@ -218,13 +213,11 @@ fun Password(
218213
} else {
219214
PasswordVisualTransformation()
220215
},
221-
isErrorValue = passwordState.showErrors(),
222-
onTextInputStarted = { softwareKeyboardController = it },
216+
isError = passwordState.showErrors(),
223217
keyboardOptions = KeyboardOptions.Default.copy(imeAction = imeAction),
224218
keyboardActions = KeyboardActions(
225219
onDone = {
226220
onImeAction()
227-
softwareKeyboardController.hideSoftwareKeyboard()
228221
}
229222
)
230223
)
@@ -238,7 +231,7 @@ fun Password(
238231
@Composable
239232
fun TextFieldError(textError: String) {
240233
Row(modifier = Modifier.fillMaxWidth()) {
241-
Spacer(modifier = Modifier.preferredWidth(16.dp))
234+
Spacer(modifier = Modifier.width(16.dp))
242235
Text(
243236
text = textError,
244237
modifier = Modifier.fillMaxWidth(),
@@ -257,7 +250,7 @@ fun OrSignInAsGuest(
257250
horizontalAlignment = Alignment.CenterHorizontally
258251
) {
259252
Surface {
260-
Providers(LocalContentAlpha provides ContentAlpha.medium) {
253+
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
261254
Text(
262255
text = stringResource(id = R.string.or),
263256
style = MaterialTheme.typography.subtitle2

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ package com.example.compose.jetsurvey.signinsignup
1919
import androidx.compose.foundation.layout.Column
2020
import androidx.compose.foundation.layout.Spacer
2121
import androidx.compose.foundation.layout.fillMaxWidth
22-
import androidx.compose.foundation.layout.preferredHeight
22+
import androidx.compose.foundation.layout.height
2323
import androidx.compose.material.Button
2424
import androidx.compose.material.ContentAlpha
2525
import androidx.compose.material.LocalContentAlpha
2626
import androidx.compose.material.MaterialTheme
2727
import androidx.compose.material.Scaffold
2828
import androidx.compose.material.Text
2929
import androidx.compose.runtime.Composable
30-
import androidx.compose.runtime.Providers
30+
import androidx.compose.runtime.CompositionLocalProvider
3131
import androidx.compose.runtime.remember
3232
import androidx.compose.ui.Modifier
3333
import androidx.compose.ui.focus.FocusRequester
@@ -55,7 +55,7 @@ fun SignUp(onNavigationEvent: (SignUpEvent) -> Unit) {
5555
onBackPressed = { onNavigationEvent(SignUpEvent.NavigateBack) }
5656
)
5757
},
58-
bodyContent = {
58+
content = {
5959
SignInSignUpScreen(
6060
onSignedInAsGuest = { onNavigationEvent(SignUpEvent.SignInAsGuest) },
6161
modifier = Modifier.fillMaxWidth()
@@ -82,7 +82,7 @@ fun SignUpContent(
8282
val emailState = remember { EmailState() }
8383
Email(emailState, onImeAction = { passwordFocusRequest.requestFocus() })
8484

85-
Spacer(modifier = Modifier.preferredHeight(16.dp))
85+
Spacer(modifier = Modifier.height(16.dp))
8686
val passwordState = remember { PasswordState() }
8787
Password(
8888
label = stringResource(id = R.string.password),
@@ -92,7 +92,7 @@ fun SignUpContent(
9292
modifier = Modifier.focusRequester(passwordFocusRequest)
9393
)
9494

95-
Spacer(modifier = Modifier.preferredHeight(16.dp))
95+
Spacer(modifier = Modifier.height(16.dp))
9696
val confirmPasswordState = remember { ConfirmPasswordState(passwordState = passwordState) }
9797
Password(
9898
label = stringResource(id = R.string.confirm_password),
@@ -101,15 +101,15 @@ fun SignUpContent(
101101
modifier = Modifier.focusRequester(confirmationPasswordFocusRequest)
102102
)
103103

104-
Spacer(modifier = Modifier.preferredHeight(16.dp))
105-
Providers(LocalContentAlpha provides ContentAlpha.medium) {
104+
Spacer(modifier = Modifier.height(16.dp))
105+
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
106106
Text(
107107
text = stringResource(id = R.string.terms_and_conditions),
108108
style = MaterialTheme.typography.caption
109109
)
110110
}
111111

112-
Spacer(modifier = Modifier.preferredHeight(16.dp))
112+
Spacer(modifier = Modifier.height(16.dp))
113113
Button(
114114
onClick = { onSignUpSubmitted(emailState.text, passwordState.text) },
115115
modifier = Modifier.fillMaxWidth(),

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import androidx.compose.foundation.Image
2121
import androidx.compose.foundation.layout.Column
2222
import androidx.compose.foundation.layout.fillMaxSize
2323
import androidx.compose.foundation.layout.fillMaxWidth
24+
import androidx.compose.foundation.layout.height
2425
import androidx.compose.foundation.layout.offset
2526
import androidx.compose.foundation.layout.padding
26-
import androidx.compose.foundation.layout.preferredHeight
2727
import androidx.compose.foundation.layout.wrapContentHeight
2828
import androidx.compose.material.Button
2929
import androidx.compose.material.ContentAlpha
@@ -32,7 +32,7 @@ import androidx.compose.material.MaterialTheme
3232
import androidx.compose.material.Surface
3333
import androidx.compose.material.Text
3434
import androidx.compose.runtime.Composable
35-
import androidx.compose.runtime.Providers
35+
import androidx.compose.runtime.CompositionLocalProvider
3636
import androidx.compose.runtime.getValue
3737
import androidx.compose.runtime.mutableStateOf
3838
import androidx.compose.runtime.remember
@@ -88,7 +88,7 @@ fun WelcomeScreen(onEvent: (WelcomeEvent) -> Unit) {
8888
.weight(1f)
8989
.onGloballyPositioned {
9090
if (brandingBottom == 0f) {
91-
brandingBottom = it.boundsInParent.bottom
91+
brandingBottom = it.boundsInParent().bottom
9292
}
9393
}
9494
)
@@ -110,7 +110,7 @@ private fun Modifier.brandingPreferredHeight(
110110
return if (!showBranding) {
111111
this
112112
.wrapContentHeight(unbounded = true)
113-
.preferredHeight(heightDp)
113+
.height(heightDp)
114114
} else {
115115
this
116116
}
@@ -162,7 +162,7 @@ private fun SignInCreateAccount(
162162
) {
163163
val emailState = remember { EmailState() }
164164
Column(modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally) {
165-
Providers(LocalContentAlpha provides ContentAlpha.medium) {
165+
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
166166
Text(
167167
text = stringResource(id = R.string.sign_in_create_account),
168168
style = MaterialTheme.typography.subtitle2,

‎Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import androidx.compose.foundation.layout.Row
2828
import androidx.compose.foundation.layout.Spacer
2929
import androidx.compose.foundation.layout.fillMaxSize
3030
import androidx.compose.foundation.layout.fillMaxWidth
31+
import androidx.compose.foundation.layout.height
3132
import androidx.compose.foundation.layout.padding
32-
import androidx.compose.foundation.layout.preferredHeight
3333
import androidx.compose.foundation.layout.width
3434
import androidx.compose.foundation.layout.wrapContentSize
3535
import androidx.compose.foundation.lazy.LazyColumn
@@ -51,7 +51,7 @@ import androidx.compose.material.icons.Icons
5151
import androidx.compose.material.icons.filled.AddAPhoto
5252
import androidx.compose.material.icons.filled.SwapHoriz
5353
import androidx.compose.runtime.Composable
54-
import androidx.compose.runtime.Providers
54+
import androidx.compose.runtime.CompositionLocalProvider
5555
import androidx.compose.runtime.getValue
5656
import androidx.compose.runtime.mutableStateOf
5757
import androidx.compose.runtime.remember
@@ -79,7 +79,7 @@ fun Question(
7979
contentPadding = PaddingValues(start = 20.dp, end = 20.dp)
8080
) {
8181
item {
82-
Spacer(modifier = Modifier.preferredHeight(44.dp))
82+
Spacer(modifier = Modifier.height(44.dp))
8383
val backgroundColor = if (MaterialTheme.colors.isLight) {
8484
MaterialTheme.colors.onSurface.copy(alpha = 0.04f)
8585
} else {
@@ -101,9 +101,9 @@ fun Question(
101101
.padding(vertical = 24.dp, horizontal = 16.dp)
102102
)
103103
}
104-
Spacer(modifier = Modifier.preferredHeight(24.dp))
104+
Spacer(modifier = Modifier.height(24.dp))
105105
if (question.description != null) {
106-
Providers(LocalContentAlpha provides ContentAlpha.medium) {
106+
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
107107
Text(
108108
text = stringResource(id = question.description),
109109
style = MaterialTheme.typography.caption,

0 commit comments

Comments
 (0)
Please sign in to comment.