Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quick View] Merging compose-latest to main #985

Merged
merged 43 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
40ad9dc
Merge pull request #919 from android/ben/merge_main_latest
bentrengrove Aug 5, 2022
c733b55
Upgrade to Compose 1.3
bentrengrove Aug 4, 2022
fbb1e66
Fix lint on JetNews
bentrengrove Aug 5, 2022
0f862df
Make reply work with upgrade script
bentrengrove Aug 5, 2022
f1ebfe3
Upgrade samples to compiler 1.3.0-rc02
bentrengrove Aug 8, 2022
12764b6
Merge pull request #918 from android/ben/1.3
JolandaVerhoef Aug 9, 2022
69f4ea7
Update compose-latest | Compose 1.3.0-alpha03 | Compiler 1.3.0 | Kotl…
JolandaVerhoef Aug 12, 2022
9302ed0
[compose-latest Crane] Bugfix for destinations not found in Crane (#939)
riggaroo Aug 15, 2022
dc6d23c
Merge branch 'main' into compose-latest
riggaroo Aug 23, 2022
58d8728
Main into Compose-latest (#965)
JolandaVerhoef Aug 24, 2022
d3aa517
[compose-latest] Update samples on compose-latest branch to Compose 1…
simona-anomis Aug 29, 2022
7a9fa37
[Jetsurvey] Converted to use Material 3 (#954) (#971)
IanGClifton Sep 2, 2022
c6812c6
Update to Compose 1.3.0-beta02 (#974)
bentrengrove Sep 10, 2022
172bd85
[All] Updated to Compose 1.3.0-beta03, AGP 7.3.0 (#979)
IanGClifton Sep 23, 2022
8ecabc5
main > compose-latest (#984)
JolandaVerhoef Sep 30, 2022
b83ce65
Ben/merge main into latest (#988)
bentrengrove Oct 3, 2022
4d17b11
Merge branch 'main' into ben/merge_main_into_latest2
bentrengrove Oct 5, 2022
f21dbbe
Merge main into latest (#991)
bentrengrove Oct 5, 2022
90145a6
[All] Update to 1.3.0-rc01-SNAP
astamato Sep 30, 2022
148b4d8
[All] Update to 1.3.0-rc01-SNAP
astamato Oct 5, 2022
734ab7f
[All] Update to 1.3.0-rc01-SNAP
astamato Oct 5, 2022
7bf22ba
[All] Update to 1.3.0-rc01-SNAP - Compose compiler 1.3.2
astamato Oct 5, 2022
90ee320
[All] Update Accompanist to 0.26.5-rc
astamato Oct 6, 2022
fab8511
[All] Update to 1.3.0-rc01 (#983)
astamato Oct 6, 2022
c278506
Updating Material3 to RC01
florina-muntenescu Oct 7, 2022
67e1e32
[All] Update all to material3 and compose-materialWindow to rc01
astamato Oct 7, 2022
1079eaa
Fix snapshot script not working on unix runners
bentrengrove Oct 7, 2022
b20ef93
Fix snapshot script not working on unix runners (#994)
bentrengrove Oct 7, 2022
b94906f
[All] Update to collectAsStateWithLifecycle to latest alpha
astamato Oct 8, 2022
fd05483
[All] Update to collectAsStateWithLifecycle to latest alpha
astamato Oct 8, 2022
0a3ac4d
Updating Material3 to RC01 (#993)
florina-muntenescu Oct 8, 2022
0a38a42
Update Jetcaster/README.md with correct refdoc
astamato Oct 10, 2022
9dad1d8
[All] Update to collectAsStateWithLifecycle to latest alpha (#995)
astamato Oct 10, 2022
316b8c6
[Jetsurvey] Removed Slider workaround for M3 bug
IanGClifton Oct 11, 2022
e56a368
[Jetsurvey] Removed Slider workaround for M3 bug (#998)
IanGClifton Oct 11, 2022
07b0a26
Merge remote-tracking branch 'origin/main' into compose-latest
JolandaVerhoef Oct 20, 2022
9c8064e
[All] Update non-compose dependencies
JolandaVerhoef Oct 20, 2022
2389cf5
[All] Update Compose dependencies to Snapshot
JolandaVerhoef Oct 20, 2022
47f4777
[All] Update dependencies to use Compose BOM
JolandaVerhoef Oct 20, 2022
1933558
[All] Update dependencies to use Compose BOM
JolandaVerhoef Oct 20, 2022
d526aaa
Merge main into compose-latest (#1002)
JolandaVerhoef Oct 20, 2022
7484956
[All] Revert faulty Androidx window library version update
JolandaVerhoef Oct 24, 2022
7659a1d
Update Compose version (#1003)
JolandaVerhoef Oct 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Jetsurvey] Converted to use Material 3 (#954) (#971)
This updates Jetsurvey from Material 2 to Material 3. All Compose components now use Material 3 instead of Material 2. The date picker is currently still using the MaterialDatePicker DialogFragment the same as before this change. This also fixes the visibility of the status bars when in light mode and updates the screenshot and animated gif.

Before: https://raw.githubusercontent.com/android/compose-samples/70d05efe9c5de6d3788ac3c6023caa20761d410a/Jetsurvey/screenshots/survey.gif
After: https://raw.githubusercontent.com/android/compose-samples/ede93fc907ad32c61bd7f3d55a33af48e782ea2a/Jetsurvey/screenshots/survey.gif
  • Loading branch information
IanGClifton authored Sep 2, 2022
commit 7a9fa37965968c59ae7ece6ec628c89d6c038daf
3 changes: 2 additions & 1 deletion Jetsurvey/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ dependencies {
implementation(libs.google.android.material)

implementation(libs.androidx.compose.foundation.layout)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.runtime.livedata)
debugImplementation(libs.androidx.compose.ui.tooling)

implementation(libs.accompanist.permissions)
implementation(libs.accompanist.systemuicontroller)

implementation(libs.coil.kt.compose)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.example.compose.jetsurvey.signinsignup

import android.content.res.Configuration.UI_MODE_NIGHT_NO
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand All @@ -24,15 +26,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.Button
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Snackbar
import androidx.compose.material.SnackbarHost
import androidx.compose.material.SnackbarHostState
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -48,7 +50,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.compose.jetsurvey.R
import com.example.compose.jetsurvey.theme.JetsurveyTheme
import com.example.compose.jetsurvey.theme.snackbarAction
import com.example.compose.jetsurvey.util.supportWideScreen
import kotlinx.coroutines.launch

Expand All @@ -59,7 +60,7 @@ sealed class SignInEvent {
object NavigateBack : SignInEvent()
}

@OptIn(ExperimentalMaterialApi::class)
@OptIn(ExperimentalMaterial3Api::class) // Scaffold is experimental in m3
@Composable
fun SignIn(onNavigationEvent: (SignInEvent) -> Unit) {

Expand Down Expand Up @@ -157,7 +158,6 @@ fun SignInContent(
}
}

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ErrorSnackbar(
snackbarHostState: SnackbarHostState,
Expand All @@ -171,16 +171,16 @@ fun ErrorSnackbar(
modifier = Modifier.padding(16.dp),
content = {
Text(
text = data.message,
style = MaterialTheme.typography.body2
text = data.visuals.message,
style = MaterialTheme.typography.bodyMedium,
)
},
action = {
data.actionLabel?.let {
data.visuals.actionLabel?.let {
TextButton(onClick = onDismiss) {
Text(
text = stringResource(id = R.string.dismiss),
color = MaterialTheme.colors.snackbarAction
color = MaterialTheme.colorScheme.inversePrimary
)
}
}
Expand All @@ -193,18 +193,11 @@ fun ErrorSnackbar(
)
}

@Preview(name = "Sign in light theme")
@Preview(name = "Sign in light theme", uiMode = UI_MODE_NIGHT_NO)
@Preview(name = "Sign in dark theme", uiMode = UI_MODE_NIGHT_YES)
@Composable
fun SignInPreview() {
JetsurveyTheme {
SignIn {}
}
}

@Preview(name = "Sign in dark theme")
@Composable
fun SignInPreviewDark() {
JetsurveyTheme(darkTheme = true) {
SignIn {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,20 @@ import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.ContentAlpha
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedButton
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ChevronLeft
import androidx.compose.material.icons.filled.Visibility
import androidx.compose.material.icons.filled.VisibilityOff
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
Expand All @@ -60,17 +56,18 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.compose.jetsurvey.R
import com.example.compose.jetsurvey.theme.JetsurveyTheme
import com.example.compose.jetsurvey.theme.stronglyDeemphasizedAlpha

@Composable
fun SignInSignUpScreen(
onSignedInAsGuest: () -> Unit,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(),
content: @Composable() () -> Unit
content: @Composable () -> Unit
) {
LazyColumn(
modifier = modifier,
Expand All @@ -96,13 +93,13 @@ fun SignInSignUpScreen(
}
}

@OptIn(ExperimentalMaterial3Api::class) // CenterAlignedTopAppBar is experimental in m3
@Composable
fun SignInSignUpTopAppBar(topAppBarText: String, onBackPressed: () -> Unit) {
TopAppBar(
CenterAlignedTopAppBar(
title = {
Text(
text = topAppBarText,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center)
Expand All @@ -112,19 +109,19 @@ fun SignInSignUpTopAppBar(topAppBarText: String, onBackPressed: () -> Unit) {
IconButton(onClick = onBackPressed) {
Icon(
imageVector = Icons.Filled.ChevronLeft,
contentDescription = stringResource(id = R.string.back)
contentDescription = stringResource(id = R.string.back),
tint = MaterialTheme.colorScheme.primary
)
}
},
// We need to balance the navigation icon, so we add a spacer.
actions = {
Spacer(modifier = Modifier.width(68.dp))
},
backgroundColor = MaterialTheme.colors.surface,
elevation = 0.dp
)
}

@OptIn(ExperimentalMaterial3Api::class) // OutlinedTextField is experimental in m3
@Composable
fun Email(
emailState: TextFieldState = remember { EmailState() },
Expand All @@ -137,12 +134,10 @@ fun Email(
emailState.text = it
},
label = {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.email),
style = MaterialTheme.typography.body2
)
}
Text(
text = stringResource(id = R.string.email),
style = MaterialTheme.typography.bodyMedium,
)
},
modifier = Modifier
.fillMaxWidth()
Expand All @@ -152,7 +147,7 @@ fun Email(
emailState.enableShowErrors()
}
},
textStyle = MaterialTheme.typography.body2,
textStyle = MaterialTheme.typography.bodyMedium,
isError = emailState.showErrors(),
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = imeAction,
Expand All @@ -162,12 +157,13 @@ fun Email(
onDone = {
onImeAction()
}
)
),
)

emailState.getError()?.let { error -> TextFieldError(textError = error) }
}

@OptIn(ExperimentalMaterial3Api::class) // OutlinedTextField is experimental in m3
@Composable
fun Password(
label: String,
Expand All @@ -191,14 +187,12 @@ fun Password(
passwordState.enableShowErrors()
}
},
textStyle = MaterialTheme.typography.body2,
textStyle = MaterialTheme.typography.bodyMedium,
label = {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = label,
style = MaterialTheme.typography.body2
)
}
Text(
text = label,
style = MaterialTheme.typography.bodyMedium,
)
},
trailingIcon = {
if (showPassword.value) {
Expand Down Expand Up @@ -231,7 +225,7 @@ fun Password(
onDone = {
onImeAction()
}
)
),
)

passwordState.getError()?.let { error -> TextFieldError(textError = error) }
Expand All @@ -247,7 +241,7 @@ fun TextFieldError(textError: String) {
Text(
text = textError,
modifier = Modifier.fillMaxWidth(),
style = LocalTextStyle.current.copy(color = MaterialTheme.colors.error)
color = MaterialTheme.colorScheme.error
)
}
}
Expand All @@ -261,20 +255,17 @@ fun OrSignInAsGuest(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally
) {
Surface {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.or),
style = MaterialTheme.typography.subtitle2,
modifier = Modifier.paddingFromBaseline(top = 25.dp)
)
}
}
Text(
text = stringResource(id = R.string.or),
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = stronglyDeemphasizedAlpha),
modifier = Modifier.paddingFromBaseline(top = 25.dp)
)
OutlinedButton(
onClick = onSignedInAsGuest,
modifier = Modifier
.fillMaxWidth()
.padding(top = 20.dp, bottom = 24.dp)
.padding(top = 20.dp, bottom = 24.dp),
) {
Text(text = stringResource(id = R.string.sign_in_guest))
}
Expand All @@ -284,8 +275,12 @@ fun OrSignInAsGuest(
@Preview
@Composable
fun SignInSignUpScreenPreview() {
SignInSignUpScreen(
onSignedInAsGuest = {},
content = {}
)
JetsurveyTheme {
Surface {
SignInSignUpScreen(
onSignedInAsGuest = {},
content = {}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material.Button
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
Expand All @@ -38,6 +36,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.compose.jetsurvey.R
import com.example.compose.jetsurvey.theme.JetsurveyTheme
import com.example.compose.jetsurvey.theme.stronglyDeemphasizedAlpha
import com.example.compose.jetsurvey.util.supportWideScreen

sealed class SignUpEvent {
Expand All @@ -47,6 +46,7 @@ sealed class SignUpEvent {
object NavigateBack : SignUpEvent()
}

@OptIn(ExperimentalMaterial3Api::class) // Scaffold is experimental in m3
@Composable
fun SignUp(onNavigationEvent: (SignUpEvent) -> Unit) {
Scaffold(
Expand Down Expand Up @@ -104,12 +104,11 @@ fun SignUpContent(
)

Spacer(modifier = Modifier.height(16.dp))
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.terms_and_conditions),
style = MaterialTheme.typography.caption
)
}
Text(
text = stringResource(id = R.string.terms_and_conditions),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = stronglyDeemphasizedAlpha)
)

Spacer(modifier = Modifier.height(16.dp))
Button(
Expand Down
Loading